Cind console application
A console application is a program executed inside system terminal, having only binary stream interface.
This kind of application is widely used as a basic program, which interacting via text,
usually by writing characters on the console display and reading input characters from the keyboard.
To create console application in the Cind language, compile it with
Basic console application
The Hello World application in the Cind language:
For more about language writing style see Code writing style.
For making a program see Compilation and execution.
Section
Every console application needs to have one
For example, while executing program:
text entered after the
For definition of parameters declaration in the Cind language see Parameters of function.
Main classes
The main classes of application should be added in the code,
above the
Notice, that any other classes can still be declared in any other place in the code.
For more about classes see Classes.
Host object
Object
method | parameters | description | result |
(...) | prints list of parameters to standard output, in given order, converting them to strings, and then writes in UTF-8 charset |
||
println | (...) | prints out parameters, as in above method, and also end-of-line character at the end |
|
openFile | (filename) | opens existing file for reading | file object |
createFile | (filename) | creates new file with given name, and opens it for writing (see below) |
file object |
exit | (exitCode) | exits console application with given exit value (see below) |
|
outputStream | () | returns standard output stream of console application as file object in write-only mode |
file object |
errorStream | () | returns standard error stream of console application as file object in write-only mode |
file object |
inputStream | () | returns standard input stream of console application as file object in read-only mode |
file object |
Caller object
In console application the
Accessing files
A file object represents data stream or file from the operating system,
from which it is possible to read or write data.
The file can be opened for read-only or for write-only mode,
and therefore, file object allows to access only read or write methods.
A file object can be received, for example,
from host's methods
Methods of the file object opened in write-only mode:
method | parameters | description | result |
write | (sheet s, int offset, int count) |
writes data to the stream, starting at given offset position, it will write count bytes or less, depending on the condition or capabilities of the file, and on the other circumstances |
int - number of written bytes |
writeByte | (byte b) | writes single byte to the stream | bool - true when ok, false means failed |
close | () | closes file (and releases any holded resources) | |
(...) | prints list of parameters in given order, converting them to strings, and then writes in UTF-8 charset |
||
println | (...) | prints out parameters, as in above method, and also end-of-line character at the end |
Methods of the file object opened in read-only mode:
method | parameters | description | result |
read | (int count) | reads data from the stream, it will try to read count bytes or less, depending on the condition or capabilities of the file, and on the other circumstances |
sheet - sheet with readed data |
readByte | () | reads single byte from the stream | byte - when ok, null means failed |
close | () | closes file (and releases any holded resources) |
A
For more about sheet data type see Sheet object.