Skip to content

Commit d166665

Browse files
committed
Man page updated with number literal formats, ERRORCODE, ERRORTEXT and EXTERNAL SUB-PROCEDUREs.
1 parent 53d4289 commit d166665

File tree

1 file changed

+78
-3
lines changed

1 file changed

+78
-3
lines changed

man/ldpl.1

+78-3
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ When you are done installing LDPL, go write some LDPL source code, say 'source.l
137137

138138

139139

140-
.SH LDPL COMPILER OPTIONS
140+
.SH LDPL COMPILER SWITCHES
141141

142142
You can import files to your LDPL compilation by using the '-i' flag. For example, say you have a library 'mylib.ldpl' and a source file 'mysource.ldpl', you can compile both and include the library by running 'ldpl -i=mylibrary.ldpl mysource.ldpl'. Multiple '-i=' can be used to import multiple files. Extensions can also be imported by using this flag; see the Extensions section.
143143

144144
By using '-r' you can just compile the project and print the C++ representation for that code.
145145

146146
You can set the output file for the compiled binary with the '-o' flag. For example, if you want to name your program "dog", you could compile it with 'ldpl -o=dog main.ldpl'.
147147

148-
On Linux and Windows platforms, LDPL builds static binaries by default. If you want to build non-static ones use the '-n' flag.
148+
On Linux and Windows platforms, LDPL builds static binaries by default. If you want to build non-static ones use the '-n' flag (or the alternative '--non-static' flag).
149149

150150
The '-c' flag tells LDPL to accept source code from the standard input.
151151

@@ -258,6 +258,8 @@ The NUMBER data type, as its name suggests, depicts numeric values. It's recomme
258258

259259
Both variables and numeric constants can be members of the NUMBER type.
260260

261+
Valid number literals must begin with a decimal value (for example '5' or '0.12', '.12' wouldn't be a valid NUMBER) and may be preceded by a minus sign for negative numbers ('-5', '-567.912'). Numbers may not be preceded by a plus sign ('+5' is not a valid number literal). The literal '-0' is implicitly transformed into '0'.
262+
261263
The TEXT data type, as its name suggests, represents alphanumeric strings. In the interest of supporting as many locales as possible, LDPL should be utf-8 encoded to be compatible with Unicode. A TEXT maximum length is explicitly not defined and it should be limited only by the amount of available memory on the system. Strings in LDPL are enclosed between two '"'quotes'"' and can contain multiple escape sequences.
262264

263265
Both variables and string constants can be members of the TEXT type.
@@ -426,6 +428,26 @@ Naturally, if no arguments are passed to the program, the value of 'argc' will b
426428

427429

428430

431+
.SH ERRORCODE AND ERRORTEXT
432+
433+
Some LDPL operations may fail when executed. Maybe you tried LOADing a file that wasn't there or getting the ASCII value of a multi-byte emoji. These operations make use of the 'ERRORCODE' and 'ERRORTEXT' variables to tell you if they ran successfully or not.
434+
435+
The 'ERRORCODE' and 'ERRORTEXT' variables come declared by default. Some statements may modify their values to express their results.
436+
437+
The 'ERRORCODE' variable is a NUMBER variable. It will hold the value 0 if the statement ran successfully and any other number if it did not.
438+
439+
The 'ERRORTEXT' variable is a TEXT variable that will be empty if the statement ran successfully. If it did not, it will store a human readable description of what went wrong.
440+
441+
'ERRORCODE' and 'ERRORTEXT' can be read and written like any other LDPL variable.
442+
443+
-- Warning:
444+
.br
445+
When handling ERROR checks, please bear in mind that the content of the 'ERRORTEXT' variable may change in future releases of LDPL. The value stored in 'ERRORCODE', however, will not change and so that's the value that should be used to check whether an operation ran successfully or not.
446+
.br
447+
--
448+
449+
450+
429451
.SH ESCAPE SEQUENCES
430452

431453
LDPL strings can contain multiple escape sequences / control characters in them. Each escape sequence counts as only one character. The available escape sequences are:
@@ -509,7 +531,7 @@ The 'STORE' statement assigns a value to a variable.
509531

510532
Type Conversion Notes:
511533

512-
If the value to be stored is NUMBER and it's to be stored in a TEXT variable, the value will be converted to text, so '15' will be turned into '"15"'. If the value to be stored is a TEXT value two things can happen. If it contains any non-numeric characters (for example letters, or more than one minus sign or more than one decimal point, for example "--1.2" or "15a") the conversion will fail and 0 will be stored in the NUMBER variable. If the TEXT contains a proper number, though, for example "-416.419" or "89" it will be converted to its number equivalent and stored in the variable.
534+
If the value to be stored is NUMBER and it's to be stored in a TEXT variable, the value will be converted to text, so '15' will be turned into '"15"'. If the value to be stored is a TEXT value two things can happen. If it contains any non-numeric characters (for example letters, or more than one minus sign or more than one decimal point, for example '"--1.2"' or '"15a"') the conversion will fail and 0 will be stored in the NUMBER variable. If the TEXT contains a proper number, though, for example '"-416.419"' or '"89"' it will be converted to its number equivalent and stored in the variable. If a string literal depicting a number is preceded by leading zeros, these will be trimmed (turning '0005' into '5', '-0002.3' into '-2.3' and '00.23' into '0.23').
513535

514536

515537

@@ -1050,6 +1072,15 @@ The 'STORE CHARACTER CODE OF' statement stores the ASCII code of the character p
10501072
1 | STORE CHARACTER CODE OF <TEXT or TEXT-VAR> IN <NUMBER-VAR>
10511073
.br
10521074

1075+
.B Error codes:
1076+
1077+
Multi-byte characters (like emojis and non-ASCII characters) cannot be parsed by this statement. When trying to do so, the operation will fail and the following values will be returned into the 'ERRORCODE' and 'ERRORTEXT' variables:
1078+
1079+
.br
1080+
[*] 'ERRORCODE': 1
1081+
.br
1082+
[*] 'ERRORTEXT': "Multibyte character received (probably UTF-8). Can't be parsed into a single number."
1083+
10531084

10541085

10551086
.SH STORE QUOTE - IN
@@ -1222,6 +1253,15 @@ The 'LOAD FILE' statement loads the contents of a file into a text variable.
12221253
1 | LOAD FILE "myFolder/myTextFile.txt" IN myVariable
12231254
.br
12241255

1256+
.B Error codes:
1257+
1258+
If the LOAD operation should fail, the following values will be returned into the 'ERRORCODE' and 'ERRORTEXT' variables:
1259+
1260+
.br
1261+
[*] 'ERRORCODE': 1
1262+
.br
1263+
[*] 'ERRORTEXT': "Error: The file '<filename>' couldn't be opened."
1264+
12251265

12261266

12271267
.SH WRITE - TO FILE
@@ -1589,6 +1629,41 @@ Example:
15891629

15901630

15911631

1632+
.SH EXTERNAL SUB-PROCEDURES
1633+
1634+
Sometimes when writting C++ Extensions you'll find yourself in the need of declaring a function in C++ but coding it in LDPL. This is the opposite of writing C++ functions and calling them from LDPL, it's writing LDPL SUB-PROCEDUREs and calling them from C++.
1635+
1636+
These C++ calleable SUB-PROCEDUREs are called EXTERNAL SUB-PROCEDUREs, as they can be called from an EXTERNAL medium.
1637+
1638+
In order to declare an EXTERNAL SUB-PROCEDURE you must first declare it in your C++ source code. Say, for example, that you want to declare a SUB-PROCEDURE called 'helloWorld'. In your C++ you should write the following line:
1639+
1640+
1 | void HELLOWORLD();
1641+
.br
1642+
1643+
Note that EXTERNAL SUB-PROCEDUREs cannot receive any kind of parameters and must be declared as 'void'. You may then call the EXTERNAL SUB-PROCEDURE from C++ code like:
1644+
1645+
1 | int myCPPFunction(){
1646+
.br
1647+
2 | HELLOWORLD();
1648+
.br
1649+
3 | return 1;
1650+
.br
1651+
4 | }
1652+
.br
1653+
1654+
Once that's taken care of, you can declare your EXTERNAL SUB-PROCEDURE as any other SUB-PROCEDURE in LDPL by preppending the identifier EXTERNAL to the SUB-PROCEDURE declaration:
1655+
1656+
1 | EXTERNAL SUB-PROCEDURE helloWorld
1657+
.br
1658+
2 | #Code here...
1659+
.br
1660+
3 | END SUB-PROCEDURE
1661+
.br
1662+
1663+
These SUB-PROCEDUREs can be called from LDPL as any other SUB-PROCEDURE, but their names must follow the External Identifier Naming Scheme as any other C++ interfacing component.
1664+
1665+
1666+
15921667
.SH EXTERNAL VARIABLES
15931668

15941669
Variables defined in extensions can be accessed by prefacing their data type declaration with the 'EXTERNAL' keyword. This must occur in the DATA section of an LDPL program. Once an external variable is declared, it can be used just like any other LDPL variable.

0 commit comments

Comments
 (0)