summaryrefslogtreecommitdiff
path: root/ipl/procs/usage.icn
diff options
context:
space:
mode:
Diffstat (limited to 'ipl/procs/usage.icn')
-rw-r--r--ipl/procs/usage.icn68
1 files changed, 68 insertions, 0 deletions
diff --git a/ipl/procs/usage.icn b/ipl/procs/usage.icn
new file mode 100644
index 0000000..f381c86
--- /dev/null
+++ b/ipl/procs/usage.icn
@@ -0,0 +1,68 @@
+############################################################################
+#
+# File: usage.icn
+#
+# Subject: Procedures for service functions
+#
+# Author: Ralph E. Griswold
+#
+# Date: July 19, 1991
+#
+############################################################################
+#
+# This file is in the public domain.
+#
+############################################################################
+#
+# These procedures provide various common services:
+#
+# Usage(s) stops executions with a message concerning the
+# expected form of usage of a program.
+#
+# Error(L[]) writes arguments to &errout and returns.
+#
+#
+# ErrorCheck(l,f) reports an error that has been converted to
+# failure.
+#
+# Feature(s) succeeds if feature s is available in the running
+# implementation of Icon.
+#
+# Requires(s) terminates execution is feature s is not available.
+#
+# Signature() writes the version, host, and features support in
+# the running implementation of Icon.
+#
+############################################################################
+
+procedure Usage(s)
+ stop("Usage: ",s)
+end
+
+procedure Error(L[])
+ push(L,"*** ")
+ push(L, &errout)
+ write ! L
+end
+
+procedure ErrorCheck(line,file)
+ if &errortext == "" then fail # No converted error
+ write("\nError ",&errornumber," at line ",line, " in file ",file)
+ write(&errortext)
+ write("offending value: ",image(&errorvalue))
+ return
+end
+
+procedure Feature(s)
+ if s == &features then return else fail
+end
+
+procedure Requires(s)
+ if not(Feature(s)) then stop(s," required")
+end
+
+procedure Signature()
+ write(&version)
+ write(&host)
+ every write(&features)
+end