Programs can reside in files (in the command directory, cf. 3.4) or in the initialization file. A program file can contain several programs. A program begins in the following way
:name n1 n2 mode1 mode2 ...
where name is the name of the program (don't forget the : before), and n1, n2, mode1, mode2,... are integers.
The first integer n1, is the number of arguments needed by the program.
The second integer n2 must be 0 or 1. If it is 0, the program will run silently, i.e. the successive instructions that it contains will not be printed on screen. This is useful if the program produces the execution of many instructions, if it contains loops for instance. It is possible to run silently only a part of a program, by using the command silence ... (cf. 11). It is also possible to print something on screen inside a silent program (or part of program), by using the commands echo, echoi and echof (cf. 11).
The integers mode1, mode2,... are the running modes where it is allowed to use the program (cf. 3.2). If the only mode -1 is put here, then the program can be used in all the running modes.
In a program file, a program ends when another one begins or when the file ends. A program can call other programs or command files.
Programs written in the initialization file will be loaded when the interpreter begins to run. Program files can be loaded using the command load. For instance the instruction
- interpcom -> load prog.cmd
will load the program file prog.cmd which resides in the command directory. If the program file contains a program with the same name as an already loaded program, the old program will be destroyed and replaced by the new and a message will be printed to indicate this.
- interpcom -> proglist
prints the list of all the loaded programs. If prog1 is one of them, the instruction
- interpcom -> proglist prog1
prints the list of all the instructions of the program prog1.
- interpcom -> delprog prog1
deletes the program prog1, unless it is a program defining objects or structures (cf. 6) or it comes from the initialization file (cf. 3.14).
Comments may be written in programs, using lines beginning with the character ; .