Mid$

mid$ extracts a sub-string defined by the position and a number of characters out of a CLOB or a string.

Syntax

   mid$(EXP_STRING,EXP_POS,EXP_NB)

Examples

   # Extraction Of 3 characters from latin alphabet
   Local Char ALPHABET(26), DEF(20), WXYZ(20)
   ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
   DEF=mid$(ALPHABET,4,3) : # DEF contains "DEF"
   WXYZ=mid$(ALPHABET,23,10) : # DEF contains "WXYZ"

   # inserts a space between every character in a string
   MY_TITLE="WELCOME"
   MY_TITLE=sigma(I=1,len(MY_TITRE),mid$(TITRE,I,1)+" ")
   # Now MY_TITLE contains "W E L C O M E "

Description

The function mid$(EXP_STRING,EXP_POS,EXP_NB) extracts up to EXP_NB characters from the EXP_STRING string starting at the position EXP_POS.

The type of result is Char.

Comments

Associated errors

Error codeDescription
10The arguments type are not correct.
50The position or the length is negative.

See also

right$, left$, seg$, len.