These functions allow you to manipulate strings and convert various data types to and from strings. The basic functions offer basic functionality inspired by the C string manipulation functions. If you need more advanced functions, you can use the following User defined functions, that can be imported into your project. These contain a lot of useful functions that you can use.
SetBlockStr
Declaration | SetBlockStr(block b, long pos, long size, string x) |
Function | Writes the string x to block b from the position pos where the count starts at 0. Size is the number of bytes to be written. |
Cross | GetBlockNum, GetBlockStr |
Example | block b b := newblock(128) setblocknum(b, 0, 1, 6, false) setblockstr(b, 1, 6, ‘ABCDEF’) |
Substr
Declaration | string SubStr(string source, long pos, long len) |
Function | Copies from the string source from the position pos len bytes. Source is not changed. |
Cross | StrDel, StrIns, StrLen, StrToken |
Example | string s s := ‘AAABBBCCC’ debug(‘The first three are : ‘ + substr(s, 0, 3)) |
Strdel
Declaration | string StrDel(string source, long pos, long len) |
Function | Deletes from the string source from the position pos len bytes and returns the result. Source is not changed. |
Cross | SubStr, StrIns, StrLen, StrToken |
Example | string s s := ‘ABCDxxxEFGH’ debug(strdel(s, 4, 3)) |
StrIns
Declaration | string StrIns(string source, string ins, long pos) |
Function | Inserts the string into the string source from the pos position and returns the result. Source is not changed. |
Cross | SubStr, StrLen, StrToken |
Example | string s s := ‘ABCFGH’ debug(strins(s, ‘DE’, 3)) |
Strlen
Declaration | long StrLen(string source) |
Function | Returns the length of the source string without the final null character. |
Cross | Token |
Example | string s s := “Internal:String1” while strlen(s)< 20 do s := s + ” enddo |
StrLower
Declaration | string StrLower(string source) |
Function | Converts all uppercase letters of the source string to lowercase and returns the result. Source is not changed. The letters A – Z are converted. |
Cross | StrUpper |
Example | string s s := ‘ABcDEfGH’ debug(strlower(s)) |
Strpos
Declaration | long StrPos(string source, string find) |
Function | Finds the string source after the first occurrence of the find string. If an occurrence is found, the position is returned, otherwise -1 |
Cross | SubStr, StrToken |
Example | string s s := ‘ABCDEFGH’ if strpos(s, ‘DE’) >= 0 then debug(‘DE is included in string’) Endif |
Strtod
Declaration | double StrToD(string source) |
Function | Converts the source-designated string to a floating-point number |
Cross | DToStr, LToStr, StrToL |
Example | double d d := strtod(‘-1.7567E+02’) |
Strtoken
Declaration | string StrToken(string source, string delim, long n) |
Function | Reads the nth word from the string source. All characters found in the delim string are used as separators. |
Cross | SubStr, StrDel, StrPos |
Example | string s s := ‘one,two,three,four,fuenf’ debug(strtoken(s, ‘,’, 3) |
StrTokenCnt
Declaration | long StrTokenCnt(string source, string delim) |
Function | Determine the number of delimiters delim in the string source. |
Cross | SubStr, StrDel, StrPos, StrToken, StrTokenEx |
Example | string s s := ‘one,two,three,four,fuenf’ debug(ltostr(strtokencnt(s, ‘,’), 10)) |
StrTokenEx
Declaration | string StrTokenEx(string source, string delim, long n, long cnt) |
Function | Reads from the string source from the nth word cnt words. All characters found in the delim |
Cross | SubStr, StrDel, StrPos, StrToken, StrTokenCnt |
Example | string s s := ‘one,two,three,four,fuenf’ debug(strtokenex(s, ‘,’, 3, 2)) |
Strtol
Declaration | long StrToL(string source) |
Function | Converts the source-designated string to a long value |
Cross | DToStr, LToStr, StrToD |
Example | long l l := strtol(‘-1’) |
StrTrim
Declaration | string StrTrim(string source) |
Function | Deletes all spaces from the source string and returns the result. Source is not changed. |
Cross | StrLower, StrUpper |
Example | string s s := ‘ ABC DE FGH ‘ debug(strtrim(s)) |
StrUpper
Declaration | string StrUpper(string source) |
Function | Converts all lowercase letters of the source string to uppercase and returns the result. Source is not changed. The letters A – Z are converted. |
Cross | StrLower |
Example | string s s := ‘ABcDEfGH’ debug(strupper(s)) |