Contents - Index


Print

 

The Print command can be used with the assignment statements in Internal Functions and Procedures to output intermediate results.  The format of the Print command is

 

Print 'filename' x, y, z

 

Filename is the name of the text file into which the values of the designated variables will be written.  Filename can be a string constant or a string variable

 

x, y, and z are names of variables within the Function or Procedure for which the values will be written to the designated file.  The Print command will allow one or more variable names to be specified.  The values of the variables appearing in the Print command must be defined before the Print command is executed.

 

The Print command will write to file each time the Print command is executed, creating a new row in the file output.  The first column of each row will show the name of the function or procedure followed by the number of times the function or procedure has been called since the start of the calculations in parentheses.  See the example below.

 

The file will be cleared at the start of the calculations unless the Print command is followed by the /A option.  In this case, the new information will be appended to the existing file; e.g.,

 

Print/A 'filename', x, y, z

 

Example:  The following function will output values of i, x, and y in text file 'text.txt'.  

 

function test(x,y)

t=x+y

F$='text.txt'

i=0

repeat

     i=i+1

     print  F$, i,x,y

until (i>=t)

test=t

end

 

g=test(2,3)

 

 

Listing of file Text.txt after running the above program.

"test(1)" 1 2 3

"test(1)" 2 2 3

"test(1)" 3 2 3

"test(1)" 4 2 3

"test(1)" 5 2 3