| Function | Parameter | Return value | Description |
|---|---|---|---|
| ord | character | ASCII code | Converts a single character to its ASCII value |
| chr | ASCII code | character | Converts an ASCII value to its corresponding character value |
| string |
|
string | Converts the value of an expression to a string |
| number |
|
integer | Converts the characters of a string or a floating-point value to an integer value. A boolean value is converted to 0 for invalid expressions (false) or 1 for valid (true) expressions. |
| float |
|
float | Converts the characters of a string or an integer value to a floating-point value. A boolean value is converted to 0.0 for invalid expressions (false) or 1.0 for valid (true) expressions |
ConvertFunc = "chr" "(" Expr ")"
| "ord" "(" Expr ")"
| "string" "(" Expr ")"
| "number" "(" Expr ")"
| "float" "(" Expr ")"
| "boolean" "(" Expr ")". Alphanumeric characters after digits are ignored.
dcltrans
transaction TMain
var
I : number;
f : float;
s : string(14) init "ProductName";
s1 : string(14);
b1 : boolean;
begin
I := ord('x'); // --> i: 120
s[1] := chr(I+1); // --> s[1]: 'y'
I := ord(s[2]); // --> i: 114
I := 123;
s := string(I*10+1000); // --> s: "2230"
I := number(s); // --> i: 2230
s := "-123.99";
I := number(s); // --> i: -123
s := "123aby";
I := number(s); // --> i: 123
s := "x123.99";
I := number(s); // --> i: 0
s := "A" + string(I); // --> s: "A0"
s := "-129.77";
f := float(s); // --> f: -129.77
I := 20500;
f := float(I); // --> f: 20500.0
b1 := boolean("TRUE"); // --> b1: true
s := string(b1); // --> s: "TRUE"
i := number(b1); // --> i: 1
end TMain;