Console
Structural Elements of a Program
 
The console is a system interface intended to communicate with the user by means of the command line. It is an advantage of the console that it makes it possible for the program to display a data succession, which can be redirected, for instance into a file. In the same manner the user input may be redirected from a file. A console may be common for several programs. The main utilization of a console consists in the batch starting of several programs (by means of the BAT file).
 
Important note: In the console mode the keyboard and mouse operation and the graphic outputs are not operational. The command of waiting for the key press will not be carried out and the program will keep on running. All user inputs must be implemented by means of the console text input.
 
Image bm994.GIF console mode
 
The console mode command switches the console mode on. It is recommended to use this command at the very beginning of the main function. No elements (even no comment) may stand in front of it. In this case the translator will translate the program as a console application. By doing this it will be ensured that the system will use the already existing console window (e.g. the command line window) when starting the program, and then it will be waiting for the program completion. If the command is not used at the beginning of the main function, a new console window will be created for the program; when starting by means of the BAT batch file the system will not be waiting for the program completion, but it will continue starting another program.
 
By repeated usage of the console mode command the console mode may be switched off and on. The switch over will manifest itself in the fact that the console window remains permanently displayed, and the program's main graphic window will be switched on and off. It is, however, not recommended to switch the console mode off. By doing this, the main advantages of the console mode will get lost, and the mode usage is getting objectionable. (In the full-screen mode the new active window must be activated manually after switching over.) In case an information listing for the user must be done in the program window, it is more suitable to use an editing dialog window for this purpose.
 
Image bm995.GIF text output to console
 
The text output to console command results in writing out the text, entered as a parameter, on the console. This output can be, when called up from a command line (or from the BAT batch file), redirected to a file or to another device. The text outputting takes place into one line. If a line has to be terminated and the following line has to be used, then this can be done by means of the text constant for the next line.
 
Image bm996.GIF error text output to console
 
The error text output to console command causes the text, entered as a parameter, to be written out to the console in a similar manner as the previous command, the difference being in the fact that the text serves as an error message, which cannot be redirected into a file. The text outputting takes place into one line. If a line has to be terminated and the following line has to be used, then this can be done by means of the text constant for the next line.
 
Image bm997.GIF text input from console
 
The text input from console function reads a text from the user and returns it as text data. The text entering is to be closed by pressing Enter. The Enter key code will not be included in the text. When calling up from the command line (or from the BAT batch file) the text input from the console can be redirected from a file.

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