From fcf90eff0a4f018f097300125a7489e506e29af6 Mon Sep 17 00:00:00 2001 From: Artemy Date: Mon, 29 Aug 2022 22:13:33 +0300 Subject: [PATCH] doc: timer example --- examples/timer.onla | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 examples/timer.onla diff --git a/examples/timer.onla b/examples/timer.onla new file mode 100644 index 0000000..f7a4e55 --- /dev/null +++ b/examples/timer.onla @@ -0,0 +1,28 @@ +[ + { + let: { + seconds: { toNumber: { input: "Enter the seconds to count down: " } }, + }, + }, + + { + loop: [ + { + if: { + condition: { comp: [{ var: "seconds" }, "<=", 0] }, + body: ["break"], + }, + }, + [{ var: "seconds" }, " seconds left"], + { + assign: { + seconds: { calc: [{ var: "seconds" }, "-", 1] }, + }, + }, + { sleep: 1000 }, + "clear", + ], + }, + + ["Time's up"], +]