Files
Structural Elements of a Program
 
The file servicing makes it possible to work with maximum two files at a time. From one file the data can only be read, and to the other one the data can only be written. The data cannot be read from and written into the same file at a time. When using the files, the name of the file which the data are to be read from and that of the file into which the data is be written into has to be set. During the first file data access the file will be opened. The file will be closed automatically, if not used, or when setting the file name anew. If an error arises during some file operations, the operation error flag will be set.
 
Image bm998.GIF active disk and folder
 
The active disc and folder element is used as a text variable (enabling reading and writing), indicating the default disk and folder (in form of "disk:\path"), which will be used to enter an incomplete specification of a file or a folder. When an invalid disk or folder is set, the operation error flag will be set.
 
Image bm999.GIF active file/folder for reading
 
The active file/folder for reading element is a text variable (with the possibility of reading and writing) indicating the name of a file or of a folder, from which it will be read or the parameters of which will be found out. When setting the name of the file (or folder) for reading into it the previously opened file for reading or writing will be closed (the operation error flag may be set at the same time), and the pointer of the file for reading will be set to 0. The file will be opened (and the name validity will possibly be checked) only during the first access to the file data. The data cannot be read from and written into the same file at a time.
 
Image bm1000.GIF active file/folder for writing
 
The active file/folder for writing element is a text variable (with the possibility of reading and writing) designating the name for the file or folder to which data will be written into, or the parameters of which will be set. When setting the name of the file (or folder) for writing into it the previously opened file for reading or writing will be closed (the operation error flag may be set at the same time), and the pointer in the file for writing will be set to 0. The file will be opened (and the name validity will possibly be checked) only during the first access to the file data. The data cannot be read from and written into the same file at a time.
 
Image bm1001.GIF operation error flag
 
The operation error flag element is a logic flag serving to indicate an error turning up during a file operation. The flag is set when an operation error appears. It must be switched off by the program before running any operations. This feature makes it possible to test the operation flag till after running several file operations at a time. The flag is only informatory, exerting no influence on the program functioning.
 
Image bm1002.GIF program execution
 
The program execution element serves to carry out a system command or to start a program. The program name is entered as a text parameter. Following the program name program parameters may be entered. If the program name contains spaces, then the name must be entered between quotes ("This is a program"). If a command cannot be carried out as a program, the command is passed on to the system for carrying it out (e.g. the "DIR" command). It is not waited to finish a running program.
 
Image bm1003.GIF program execution with waiting
 
The program execution with waiting element serves to carry out a system command or to start a program in a similar way as it is done by the previous element. A difference consists in the fact that this element will wait till a running program is finished, and will return a numeric value as the program's return code.
 
Image bm1004.GIF return code of the program
 
The return code of the program element is located in the local variables of the program main function (not in the basic elements). This is a positive integral variable enabling to pass on a numeric code to other programs that have called this program. It is a common usage of the return code that the 0 value represents a proper program execution, whereas values greater than 0 (integral numbers only) indicate an error code.
 
Image bm1005.GIF basic operations
Image bm1006.GIF data
Image bm1007.GIF attributes
Image bm1008.GIF disk

Full Html Context Help of The Peter - Gemtree Software & Children Programming