Extracts a substring (nLen characters in length, beginning at position nStart) from a string.
If the start position is not within the string an error is raised. If the length specification exceeds the string’s length, the substring ends with the last character of the string.
Kernel.bdh
Substr( in sSource : string, out sDest : string, in nStart : number, in nLen : number): string;
copied substring
Parameter | Description |
---|---|
sSource | Source string |
sDest | Destination string |
nStart | Position of first character |
nLen | Length of substring |
dcltrans transaction TSubstr var sString, sPart: string; begin sString := "Hello world!"; write("string = "); write(sString); writeln; // extract substring "world" Substr(sString, sPart, 7, 5); write("part = "); write(sPart); writeln; end TSubstr;
string = Hello world! part = world