aboutsummaryrefslogtreecommitdiff
path: root/tut11_3_2.icl
diff options
context:
space:
mode:
Diffstat (limited to 'tut11_3_2.icl')
-rw-r--r--tut11_3_2.icl35
1 files changed, 35 insertions, 0 deletions
diff --git a/tut11_3_2.icl b/tut11_3_2.icl
new file mode 100644
index 0000000..a959b60
--- /dev/null
+++ b/tut11_3_2.icl
@@ -0,0 +1,35 @@
+module tut11_3_2
+
+// ********************************************************************************
+// Clean tutorial example program.
+//
+// This program creates a simple program that uses the stopwatch process.
+// The program only has a menu to open the stopwatch and control it.
+// ********************************************************************************
+
+import StdEnv, StdIO
+import tut11_3_2_stopwatch
+
+Start :: *World -> *World
+Start world
+# (stopwatchId, world) = openRId world
+= startIO SDI Void (initialise stopwatchId) [] world
+
+initialise :: (RId StopwatchCommands) (PSt .l) -> PSt .l
+initialise stopwatchId pst
+# (error, pst) = openMenu Void mdef pst
+| error <> NoError = closeProcess pst
+| otherwise = openProcesses (stopwatch stopwatchId) pst
+where
+ mdef = Menu "&Stopwatch" (MenuItem "&Reset" [MenuFunction (noLS (send Reset))] :+:
+ MenuItem "&Pause" [MenuFunction (noLS (send Pause))] :+:
+ MenuItem "C&ontinue" [MenuFunction (noLS (send Continue))] :+:
+ MenuItem "&Close" [MenuFunction (noLS (send Close))] :+:
+ MenuSeparator [] :+:
+ MenuItem "&Quit" [MenuFunction (noLS (closeProcess o (send Close)))]) []
+ where
+ send msg pst
+ # (error, pst) = syncSend stopwatchId msg pst
+ | error <> SendOk = appPIO beep pst
+ | otherwise = pst
+