I/O Statements
DISPLAY
The DISPLAY statement outputs the values passed to the output stream. CRLF means line break and is a sugar syntax for the "\n" escape sequence.
Syntax:
1 | |
Example:
1 | |
PRINT
The PRINT statement outputs the values passed to the output stream and then prints a line break. It's
equivalent to using DISPLAY with a CRLF at the end.
Syntax:
1 | |
Example:
1 | |
ACCEPT _
The ACCEPT command is used to gather input from the user. If a TEXT variable is specified, anything the user enters before pressing the 'return' key will be accepted. If a NUMBER variable is specified, the user must enter a number (if any non-numeric key is entered, the error message "Redo from start" will be output and the ACCEPT command rerun).
Syntax:
1 | |
EXECUTE _
The EXECUTE statement executes the specified system command.
Syntax:
1 | |
Example 1:
1 2 3 4 | |
Example 2:
1 2 | |
EXECUTE _ AND STORE OUTPUT IN _
The EXECUTE - AND STORE OUTPUT IN executes the specified command and stores any resulting text in the passed variable.
Syntax:
1 | |
EXECUTE _ AND STORE EXIT CODE IN _
The EXECUTE - AND STORE EXIT CODE IN executes the specified command and stores the exit code in the passed variable.
Syntax:
1 | |
ACCEPT _ UNTIL EOF
The ACCEPT UNTIL EOF statement accepts input from standard input until an EOF state is reached and stores all data gathered in TEXT-VAR.
Syntax:
1 | |
LOAD FILE _ IN _
The LOAD FILE statement loads the contents of a file into a text variable.
Syntax:
1 | |
Example:
1 | |
Error Codes:
If the LOAD operation should fail, the following values will be returned into the ERRORCODE and ERRORTEXT variables:
ERRORCODE: 1ERRORTEXT: "The file '<filename>' couldn't be opened."
Warning
Always use the ERRORCODE variable to check if the operation was successful or not. Do not use ERRORTEXT for anything else than displaying the error found, as its contents may change in future releases of LDPL.
WRITE _ TO FILE _
The WRITE x TO FILE y statement writes the value of x to the file called y. If the file already exists, everything in it will be overwritten by x.
Syntax:
1 | |
Example:
1 | |
Error Codes:
If the WRITE operation should fail, the ERRORCODE and ERRORTEXT variables will be set to the following values:
ERRORCODE: 1ERRORTEXT: "Could not open '<filename>'"ERRORCODE: 2ERRORTEXT: "Could not write to '<filename>'"
APPEND _ TO FILE _
The APPEND x TO FILE y statement appends the value of x to the file called y. If the file already exists, x will be added at the end of its contents.
Syntax:
1 | |
Example:
1 | |
in this case, the file hello.txt (created in the example of the WRITE _ TO FILE _ function and modified as stated there) will contain the text
1 2 | |
Error Codes:
If the APPEND operation should fail, the ERRORCODE and ERRORTEXT variables will be set to the following values:
ERRORCODE: 1ERRORTEXT: "Could not open '<filename>'"ERRORCODE: 2ERRORTEXT: "Could not write to '<filename>'"