Standard Library
Built IN functions:
| Function | Description |
|---|---|
| length | return capacity of the string |
| count | return number of true symbols and spaces except ending spaces |
| truncate | reduce the capacity of the string to specified dimension |
| fill | replace all characters in string with same periodic characters |
| erase | erase all characters in a string and replace them with spaces |
| find | search one sub-string in string |
| replace | replace a sub-string in a string with another |
| parse | convert a string in number |
| trim | remove spaces from start and end of a string |
| left | remove all spaces from left making string to align left |
| right | remove all spaces at the right making string to align right |
| center | move string in the middle of capacity and adding spaces left and right |
| indent | increase string count to specified length adding spaces to the left |
| pad | increase string count to specified length adding spaces to the right |
Standard streams
In computer programming, standard streams are input and output communication channels between a computer program and its environment. The three I/O connections are called standard input (stdin), standard output (stdout) and standard error (stderr). These channels are connected to the program when program starts.
When a program is executed via an interactive shell, the streams are typically connected to the text terminal on which the shell is running, but can be changed with redirection, using a pipeline.
Standard input
Standard input is stream data (often text) going into a program. The program requests data with the read procedure. Not all programs require standard input. A program may take command-line arguments, but perform its operations without any stream data.
Unless redirected, standard input is expected from the keyboard which started the program.
read lets a program ask the user to enter a value from the keyboard. It shows the prompt, waits until the user types the text and presses enter, and stores the text in its first argument. It has no result: it is a procedure, called as a statement.
procedure read(@v: String, prompt := "");
Example:
process main is
new v := ""; ** empty string
read(v, "input v:");
print "you entered:", v;
return;
Standard output
This is the stream where a program writes its output data. The program requests the transfer with the write and print procedures. Not all programs generate output; then the program is silent.
Unless redirected, standard output is the text terminal which initiated the program.
The procedure write() sends its arguments to standard output at the current position, as they are, and does not add a new line. The procedure print() does the same and adds a new line by default. Both are procedures, called as statements.
procedure write(*args: String, sep := "", eol := False);
procedure print(*args: String, sep := ",", eol := True);
parameters:
args: the strings to send, any number of them;sep: the text put between the arguments: a comma forprint, nothing forwrite;sep: " "separates them by a space. It works only between several arguments: a list given as one argument is printed as a list,(1,2,3), whateversepis;eol:Trueends the output with a new line,Falsedoes not.
A string can contain escapes. A backslash escapes the next character, \\ is one backslash, and &code; sends any HTML character code, such as < or λ. The end of line is written \n.
Usability
The write and print functions support only strings. It can not print anything else. Therefore developer must make a conversion to a string before sending the value to write.
Standard error
Is another output stream typically used by programs to write error messages or diagnostics. It is a stream independent of standard output and can be redirected separately.
Usage
It is normal for standard output and standard error to be directed to the same destination, such as the text terminal. Messages appear in the same order as the program writes them, unless buffering is involved.
For example, a common situation is when the standard error stream is un-buffered but the standard output stream is line-buffered; in this , text written to standard error later may appear on the terminal earlier, if the standard output stream buffer is not yet full.
Redirect
The usual destination is the text terminal which started the program to provide the best chance of being seen even if standard output is redirected (so not readily observed). For example, the output of a program in a pipeline is redirected to the input of the next program, but errors from each program still go directly to the text terminal.
Procedures
Two procedures output text to stderr, error() and warning(). Two more, log_err() and log_wrn(), are for the recover region of a process: they do not print, they append the message to a log file in the output folder ($EVE_OUT, out by default).
procedure error(message: String);
procedure warning(message: String);
procedure log_err(message: String);
procedure log_wrn(message: String);
When a primary aspect ends with an unhandled error, Eve writes the last error to stderr: the message with the call stack in debug mode, only the message otherwise.
The functions error and warning add the text "Error:" and "Warning:" before the actual message. They use same buffering as the print and write. This is to avoid interlacing messages on stdout when stdout is not redirected.
** example of error and warning
process main is
print "Test start";
error("This is an error");
warning("this is a warning");
raise {code: 200, message: "test error"};
finalize
print "Test end";
return;
Read next: System Library