summaryrefslogtreecommitdiff
path: root/ipl/procs/usage.icn
blob: f381c86d41d7fc41c9bef6aa7e7ec05bd937b85b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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