Question files


Question files are files of the command directory that one can read with the command  question.... With this command it is possible to ask questions to the user, to get the value of some variables, or to define character strings to be used later in the program. For example a file called   quest.cmd  of the command directory may contain the following lines :

5
Number  of  points :
n _points
Initial  value :
x _min
Final  value :
x _max
Name  of  first  string :
$1
Name  of  second  string :
$2

In this example we see that the first line of  quest.cmd  contains a number. It is the number of pairs of lines that follow. The pairs of lines are of two types : pairs 1,2,3 contain a string of characters, and a second string that will be the name of a variable of the expression evaluator, and pairs 4,5 contain a string of characters followed by a $ and a number. The question file  quest.cmd  is called by the command

interpreter -> question   question.cmd

Then the program will print on screen the first line of the first pair, and wait for an answer. The answer of the user will be parsed by the expression evaluator and assigned to the variable  n_points . The two next pairs will be treated in the same way. For the fourth, the program will print the string

Name  of  first  string :

and the character string entered by the user will be assigned to the string variable number 1. The second string variable will be assigned in the same way. The maximal number of string variables is fixed in the section   !param  of the initialization file (cf. section 2.1). The first string variable can be accessed later by using the expression  $(1). For example if this variable contains abcd, the command

interpreter -> write   X$(1)Y   2.5

will open (or create) the file  XabcdY  of the result directory 1 (cf. section 8 for the command  write ) and write to it the number 2.5. Interactively it is only possible to use the string variables inside arguments (of programs, commands or command files), i.e. they must not be in the first term of an instruction. But inside a program, string variables can be put also in the first term. For example a program may contain the line

AA$(1)BB=25.

and its execution will create (or modify) the variable  AAabcdBB  of the expression evaluator, and give it the value 25.

It is possible to use the command  question  with no arguments. In this case it is only possible to enter string variables. For example, after the command

interpreter -> question

the user will have to enter a positive number, which is the number of string variables to be fixed. Then the user will have to give the string and the corresponding numbers. For example

3
aaaXXX
$1
qsqsqsq
$5
AzWWW
$2

As explained in section 3.6.3 when the command  question  without arguments is used inside a program, the user is not asked to give the answers. They are read in the program after the command. For example the program can contain the lines

question
3
aaaXXX
$1
qsqsqsq
$5
AzWWW
$2
 
 
 
 
 


Main page
Chapters   1   2   3   4   5   6   7   8    9    10   11