Seg$
seg$
extracts a substring defined by the starting position and the ending position out of a CLOB or a string.
seg$(EXP_STRING,EXP_POS1,EXP_POS2)
EXP_STRING
is an expression returning a CLOB or string value.EXP_POS1
is an expression returning an integer value that is the position of the first character to be extracted.EXP_POS2
is an expression returning an integer value that is the position of the last character to be extracted. # Extraction Of 3 characters from latin alphabetLocal Char ALPHABET(26), DEF(20), WXYZ(20)ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"DEF=seg$(ALPHABET,4,6) : # DEF contains "DEF"WXYZ=mid$(ALPHABET,23,26) : # DEF contains "WXYZ"# inserts a space between every character in a stringMY_TITLE="WELCOME"MY_TITLE=sigma(I=1,len(MY_TITRE),mid$(TITRE,I,I)+" ")# Now MY_TITLE contains "W E L C O M E "
The function seg$(EXP_STRING,EXP_POS,EXP_NB)
extracts characters from the EXP_STRING
string starting at the position EXP_POS1
until the position EXP_POS2
.
The type of result is Char.
EXP_POS1
is greater than the length of the string, seg$(EXP_STRING,EXP_POS1,EXP_POS2)
returns the null string ""
.EXP_POS2
is greater than the length of the string, only the remaining characters will be extracted, and the length of the result will be smaller than EXP_POS2-EXP_POS1+1
.EXP_POS2
is smaller than EXP_POS1
, seg$(EXP_STRING,EXP_POS1,EXP_POS2)
returns the null string ""
.seg$(EXP_STRING,EXP_POS1,EXP_POS2)
is equivalent to mid$(EXP_STRING,EXP_POS1,EXP_POS2-EXP_POS1+1)
.Error code | Description |
---|---|
10 | The type of argument is not correct. |
50 | At least one of the positions is negative. |