||Numbers of the channels to which the files are attached, or identifiers of texts used for input (which, after “closing”, can then be re-read)|
||Type of each file (
||Whether to delete the file on closure (
Once you have finished using a file,
CLOSE can be used to release the channel to which it is attached, so that the channel is available for use with some other file. Parameters
FILETYPE indicate the channel number and the type of file, as in the
OPEN directive. The
DELETE parameter is useful if you are using files to store data temporarily, perhaps to release workspace within Genstat. When you have finished with the file you can set
DELETE=yes to request that it be deleted on closure so that disk space is not wasted. For example,
OPEN 'temp.bin'; CHANNEL=3; FILETYPE=unformatted
"... and later on when you wish to retrieve the data ..."
CLOSE 3; FILETYPE=unformatted; DELETE=yes
You cannot close a channel to which the keyboard or screen are attached, nor the current input or output channels. Also you cannot use
CLOSE to delete files that have been opened with
ACCESS=readonly or that are protected by the computer’s file system. However, you do not need to close every file before you stop running Genstat; files are automatically closed at the end of every Genstat program.
Commands for: Input and output.
" Example STOR-2: Storing in multiple subfiles Store the Plan and data (sugar %) from a sugar experiment at Kings Lynn in a subfile called KLYNN" VARIATE PLOT; VALUES=!(1...30); DECIMALS=0 UNIT PLOT FACTOR [LEVELS=!(0,1,2,3,4)] K2O FACTOR [LEVELS=!(0,1)] NACL OPEN '%gendir%/examples/STOR-2.DAT'; CHANNEL=2; FILETYPE=input READ [CHANNEL=2] K2O,NACL READ [CHANNEL=2] S% " Open a new storage file." OPEN 'STOR-2.GBS'; CHANNEL=1; FILETYPE=backingstore " Store plan and data from Kings lynn site in subfile KLYNN " STORE [CHANNEL=1; PRINT=catalogue; SUBFILE=KLYNN] K2O,NACL,S% " Delete all structure read in" DELETE [REDEFINE=YES] K2O,NACL,S% " Do the same for the IPSWICH site" FACTOR [LEVELS=!(0,1,2,3,4)] K2O FACTOR [LEVELS=!(0,1)] NACL READ [CHANNEL=2] K2O,NACL READ [CHANNEL=2] S% CLOSE CHANNEL=2; FILETYPE=input " Store the plan and data from Ipswich site in subfile IPSWICH " STORE [CHANNEL=1; SUBFILE=IPSWICH] K2O,NACL,S% " List the subfiles and structure in the file." CATALOGUE [CHANNEL=1; LIST=ALL] " Close and delete the backing-store file." CLOSE CHANNEL=1; FILETYPE=backingstore; DELETE=yes