summaryrefslogtreecommitdiff
path: root/ipl/mprogs/recordev.icn
blob: 4ad0f8f7339fe25dbc1648200cc10a7841b5e319 (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
69
############################################################################
#
#	File:     recordev.icn
#
#	Subject:  Program to record events
#
#	Author:   Ralph E. Griswold
#
#	Date:     August 16, 1994
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  This program records events in a file.  Event information is stored
#  by using image(), so some information may be lost.
#
#  This program is called as
#
#	recordev <options> tp args
#
#  The options supported are:
#
#	-o s	write event history to the file named s; default standard
#		   output.
#
#	-c s	prefix the event history with a comment event whose value
#		   is s.
#
#  Warning:  If -o is not given and tp also writes to standard output,
#  the event history file will be corrupted.
#
#  If args contains options, use -- to prevent recordev from consuming them,
#  as in
#
#	recordev -o history -- tp args
#
############################################################################
#
#  Requires:   Version 9.0 MT Icon with event monitoring
#
############################################################################
#
#  Links: evinit, options
#
############################################################################

link evinit
link options

procedure main(args)
   local file, output, opts

   opts := options(args, "c:o:")
   if file := \opts["o"] then {
      output := open(file, "w") | stop("*** cannot open ", image(file))
      }
   else output := &output

   write(output, image("#"), "\n", image(\opts["c"]))

   EvInit(args) | stop("*** cannot load TP")

   while EvGet() do 
      write(output, image(&eventcode), "\n", image(&eventvalue))

end