7.2.8 I/O Facilities

Input and output of data are accessed through the use of IMPORT and EXPORT. As CSI(C&F) is not a general purpose programming language, it does not support any general I/O - functionality. At the moment we will only show the IMPORT and EXPORT of simple variables. Later we will treat the import and export of more complex objects like RULESET, PARAMETERSET, PSLIST, OPERATORSET, etc. For this reason we have the VARIABLES qualifier in our IMPORT statement, as we are importing variables in our data space.


LET number_of_factors = number_of_factors+1

LET factor[number_of_factors] = number_of_factors

LET product = 1

LET MyName$ = "Ulrich"

FOR i = 1 TO number_of_factors STEP 1

LET product = product*factor[i]


DELETE factor[5]



LET Message = "Only me"



where My_Vars.dat is a file with the following contents at the moment (1), (2), and (3) in our program:

Situation (1): Situation (2): Situation (3):

/* #: 6 */ /* #: 8 */ /* #: 1 */

number_of_factors 5 5 number_of_factors 6 6 Message "Only me" 0

factor[1] 1 1 factor[1] 1 1

factor[2] 2 2 factor[2] 2 2

factor[3] 3 3 factor[3] 3 3

factor[4] 4 4 factor[4] 4 4

factor[5] 5 5 factor[6] 6 6

product product*factor[i] 720

MyName$ "Ulrich" 0

The structure of My_Vars.dat implies something about the structure of variables in CSI(C&F). Each variable has a name, a formula (!), and a value. This can be useful, when we want to import formulas those evaluation can only be done at runtime, after that other variables referenced in these formulas were computed. More detailed information about this is given later.

Now we will discuss the last example. Before (1) the data space is empty. After the IMPORT statement our data space holds 6 variables as in (1). Then number_of_factors is incremented by the program and 2 new variables factor[6] and MyName$ are added to the data space. Finally the variable product is added with its formula. Before saving the data space in My_Vars.dat, factor[5] is deleted with the DELETE statement. Now our data space has the contents as in (2). DELETE ALL cleans up the whole data space. A new variable named Message is inserted and finally the data space is written to My_Vars.dat again (3).