Some sections of the initialization file are optional.
The 1st number is the maximal number of programs that the interpreter can store. Don't forget to modify this number if you use a lot of programs.
The 2nd number is the maximal number of instructions that a program can have.
The 3rd number if the maximal number of commands that the interpreter can accept. Don't forget to modify this number if you add a lot of commands.
The 4th number is the maximal number of lines that the greeting message can have (cf. section 2.8).
The 5th number is the maximal number of messages that the interpreter can store (cf. section 2.9).
The 6th number is the maximal number of files that the interpreter can hold (cf. section 8, commands read and write). Of course the user can use other files inside the program using the command interpreter.
The 7th number is the maximal number of running modes (cf. section 2.2).
The 8th number is the maximal number of programs or command files actually running. This is a kind of stack parameter.
The 9th number is the maximal number of conditions that the program can hold. There are two kinds of conditional jumps that can be used in programs understood by the command interpreter (cf. section 3.4).
The 10th number is the maximal number of object types that the interpreter can accept (cf. section 5).
The 11th number is the maximal number of arguments of a command.
The 12th number is the maximal number of structure types that the interpreter can accept (cf. section 5).
The 13th number is the maximal number of labels that can be in a program understood by the interpreter (cf. section 3). Each loop in a program is counted as two labels.
The 14th number is the maximal number of string variables in question files (cf. section 7).
The 15th number is the maximal number of preceeding commands stored
by the interpreter (cf. section
4, and section
8, commands history and numcom).
Example :
!param
; maximal
number of stored programs
100
; maximal
number of lines in a program
200
; maximal
number of commands
250
; maximal
number of lines in the greeting message
20
; maximal
number of messages
500
; maximal
number of open files
10
; maximal
number of running modes
5
; maximal
number of voices
20
; maximal
number of conditions
20
; maximal
number of object types
20
; maximal
number of function arguments
10
; maximal
number of structure types
10
; maximal
number of labels in a program
100
; maximal
number of strings
10
; number
of known preceeding commands
10
.
If there are several running modes, the first that is defined as number 0, the second number 1, etc. The actual running mode is contained in the global variable mode_fonct_ . It controls the prompt that is printed when the program is waiting for a command, and which programs, commands, objects and structures can be used. The user must provide commands to go from a running mode to another. Such a command will change the global variable mode_fonct_ and may perform some initializations before entering the new running mode.
When the interpreter begins the running mode is the first (number 0).
When several running modes are needed it is a good idea to keep this first
mode empty, that is to use it only to go into the useful running modes.
In this case the user should also provide an end command to leave the useful
running modes and to go in mode 0.
Example : Here 3 running modes are defined in the initialization file :
!mode
----- Mode 0
---->
!mode
----- Mode 1
---->
!mode
----- Mode 2
---->
nptx
1000
is given, the value 1000 is associated to the name nptx . Inside a C-program using the command interpreter, the value 1000 can be recovered from the name nptx by something like
int
k;
k = S_convert_int("nptx");
After that, the integer variable k has value 1000 (see
sections 5.3,
6.1
or 9
for a more detailed description of the function S_convert_int).
Example :
!rep
; command
directory
./commands/
; result
directory
./res/
; data
directory
1
./data/
; data
directory 2
./operators/
.
defobj1 Obj_x
will create an object of this type whose name is Obj_x . Of course there is a way to recover the array from the name Obj_x , to use it (cf. section 5). Objects can be also deleted. When an object is created, the appropriate allocations of memory are made and the name is associated to the array.
The definition of an object type begins with a line containing the name of the command that will create these objects.
In the next line is the list of running mode numbers (cf. section 2.2) where the objects will be used. If this line contains the unique number -1, the objects can be used in all the running modes.
The next line contains an integer which must be 0, 1, 2, 3, 4, 5, 6 or 7. It defines the type of data that will be contained in the objects of this type. For example, 0 means that the objects are arrays of integers (see section 5).
The next line contains a positive integer, which is the number of dimensions of the objects (i.e. of the corresponding arrays).
The next line contains a description of the object type. It is used by the command list that gives the list of names of all the objects and structures that have been defined. For example this line may contain
Objects of type 1 :
and the command list will print on the screen
Objects
of type 1 :
Obj_x
if the object Obj_x of this type has been defined.
There must be then one line for each dimension of the arrays. Each line contains the name of the corresponding dimension. The way to associate an integer to a name an to recover an integer from a name is explained in section 5. A dimension name can also be one of the parameter names defined in the section !var of the initialization file (cf. section 2.3). The dimension names must actually be associated to positive integers when a command of creation of an object is executed. This indirect way to fix the size of the objects allows two objects of the same type to be of different sizes. It is also possible to fix a size depending on the context. Of course there is a way to recover the type, number of dimensions and dimensions of an object from its name (cf. section 5).
The last line of the set of lines describing an object type is the maximal
number of objects of this type that can be defined. It can be a positive
integer, or a parameter name defined in the section !var
of
the initialization file (cf. section
2.3).
Example :
!def
;Objects
of type 1 (this line is a comment line, beginning with
a ;)
defobj1
-1
0
2
Objects
of type 1 :
ndim1_1
ndim1_2
nb1
;Objects
of type 2 (comment line)
defobj2
0
2
3
Objects
of type 2 :
ndim2_1
ndim2_2
ndim2_3
nb2
.
Here two object types are defined. The first type correspond to 2-dimensional arrays of integers, and the second to 3-dimensional arrays of double precision real numbers. The name of the command that creates objects of the first type is defobj1 , and the name of the command that creates objects of the second type is defobj2 .
Several such sections can appear in an initialization file.
A definition of an structure type will create a command understood by the interpreter. With this command, structures of this type can be created. For example, if the name of the command is defstruc1 , a command
defstruc1 Struc_x
will create a structure of this type whose name is Struc_x .
The definition of a structure type begins with a line containing the name of the command that will create the structures of this type.
In the next line in an integer which is the number of members of the structure. The members are object types or structure types previously defined.
Then there are pairs of lines, one pair for each member of the structure. The first line of a pair contains the name of the corresponding member, the second line contains the object (or structure) type of this member (i.e. the name of the command that defines objects (or structures) of this type).
The next line contains a description of the structure type. It is used by the command list that gives the list of names of all the objects and structures that have been defined. For example this line may contain
Structures of type 1 :
and the command list will print on the screen
Structures
of type 1 :
Struc_x
if the structure Struc_x of this type has been defined.
In the next line is the list of running mode numbers (cf. section
2.2) where the structures will be used. If the this line contains the
unique number -1, the structures can be used in all the running modes.
The last line of the set of lines describing a structure type is the maximal
number of structures of this type that can be defined. It can be a positive
integer, or a parameter name defined in the section !var
of the initialization file (cf. section
2.3).
Example :
!struct
; Structures
of the first type (this is a comment line)
defstruc1
2
member_1
defobj1
member_2
defobj2
Structures
1 :
-1
nb1
; Structures
of the second type (this is a comment line)
defstruc2
3
member_1b
defobj1
member_2b
defobj2
member_3b
defstruc1
Structures 1
:
0
nb2
.
Here two structure types are defined. The first has two members. The
name of the first member is member_1
, and it is an object of type defobj1
.
The name of the second member is member_2
,
and it is an object of type defobj2 .
The second structure has 3 members. The name of the first member is member_1b
, and it is an object of type defobj1 . The
name of the second member is member_2b , and
it is an object of type defobj2 . The name
of the third member is member_3b , and it is
a structure of type defstruc1 .
Each command consists of 3 lines.
In the first the name of the command is given.
The second line contains a positive integer, which is the minimal number of arguments of the command (including the name of the command). A command with not enough arguments will be rejected by the interpreter. But commands with a variable number of arguments are allowed. In this case the consistency of the arguments must be checked by the user in the function that realizes the command.
The third line contains a list of integers : the running modes where the command is allowed. If it contains the only integer -1, all the running modes will accept the command. This is the case of all the commands that are implemented in the library.
It is a good idea (but it is not necessary) to give the list of commands
in alphabetic order. Of course two commands cannot have the same name.
The program must contain somewhere the list of the functions associated
to the commands, and in the same order (cf. section
4).
Example : beginning of a section !func
!func
user_com1
4
-1
user_com2
4
-1
user_com3
2
-1
user_com4
4
-1
Several such sections can appear in an initialization file, for example
if a program is obtained by glueing several applications of the command
interpreter. The names of the built-in commands of the interpreter have
not to be defined in a section !func
(as in the version 1.1 of the command interpreter). Only the commands defined
by the user are concerned.
Example :
!greet
______________________________________________
!
!
!
!
!
Command interpreter
!
!
!
!_____________________________________________!
.
error_mess(4);
will print the message number four (i.e. the message on the fifth line
after the keyword !message ).
Example :
!message
; 0 (this
is a comment line, to remember the number of the message)
Message
number 0\n
; 1
Enter a
positive real number :
; 2
Invalid
parameter !\n
; 3
Incorrect
object name !\n
.
Several such sections can be used in an initialization file. Of course
in the case of multiple sections !message,
the message numbers will be determined by the order of appearance of these
sections.
Example :
!include
inc.ini
The end of the initialization file can contain programs understood
by the interpreter. The structure of these programs is exactly the same
as for programs that can be loaded during the execution (cf. section
3). The user should put here the programs that are frequently used.