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"], +]