ieval
is a program to interactively evaluate icon expressions. Input is read from the terminal until end-of-file (control-D) is entered. Each expression has its results sequence evaluated and printed (although see the !q
option below). Variables may be assigned to, and they are stored in a local environment, which may be printed by entering !env
. To link with library packages, use the -i
command line option. Packages can’t be imported interactively. To link with individual source files, use the -l
option.
An example session
$ ieval -i lang,graphics
> &version
"Object Icon Version 1234. Mon Aug 29 11:57:11 BST 2011"
> upto('aeiou', "The quick brown fox")
3
6
7
13
18
> w := Window()
object graphics.Window#1(ptr=136611152)
> w.close()
object graphics.Window#1(ptr=0)
> ^D
$
Input of an expression over several lines can be achieved by ending a line with a backslash character. The prompt changes to >>
and the next line is concatenated to the previous one.
ieval
accepts the following command-line options :-
-i
options may be given.-l
options may be given.Remaining arguments specify files which are processed before command line input commences. They should contain valid expressions (which may be compound expressions).
s
.n
.n
.n
.a[]
are then loaded as variables, as in sym()
.p
as variables.Prog.get_global
).c
.ObjectOutputStream
used to output results.OutputStream
of the terminal (or window if using the graphical interface).!env
), as a table.An existing program can conveniently be loaded with the load()
procedure. The executable search path is used to locate the given program. The loaded program’s error handler is set in order to catch any runtime errors.
Symbols in the loaded program can then be accessed using gg()
(which is just a shorthand for Prog.get_global
), or by setting chosen symbols as variables, using sym()
. For example :-
> p := load("ivib")
co-expression#75
> dir(p)
... list of the symbols in p
> sym(p, "CanvasIcon", "Custom")
CanvasIcon = class CanvasIcon
Custom = class Custom
> dir(CanvasIcon)
... details of that class
The calls to load
and sym
can conveniently be combined, as follows :-
> p := load("ivib", "CanvasIcon", "Custom")
CanvasIcon = class CanvasIcon
Custom = class Custom
co-expression#75
The variable names used may be different from the symbols they map to; any “.” is mapped to a “”, and an “” is appended if a clash with a symbol in the main program would hide the loaded symbol.
Please remember that oit
will remove symbols from a program if it decides they aren’t referenced. Procedures, methods and entire classes can thus be discarded, and will thus not be usable from ieval
. This process of culling can be averted by using the oit
option -f
, or from within a program by the invocable
declaration.
Unless ieval
is started with the -s
option, it keeps a history of entered expressions, and uses the following keyboard shortcuts :-
!hist
Goto a particular history number with ^P
typed after the number, eg
> 25^P
Search for a history item by typing ^R
(backward) or ^T
(forward) after a string prefix, eg
> cat^R
will search backwards for the next history item beginning with cat
.^_
performs an undo (^Z
on the graphics version).^Y
performs a redo.^A
or Home
goes to start of line.^E
or End
goes to end of line.^K
deletes to end of line (deletes whole line on the graphics version).^G
resets, ie abandon all edits and goes to end of history.TAB
produces a list of possible completions. This only works in gui mode, or in text mode if using flowterm as a terminal.PGUP
in gui mode, scrolls the history upPGDN
in gui mode, scrolls the history down