bs String Functions

STRING FUNCTIONS

trim(var)

deletes blank spaces from the right

charadd(var1,var2,var3...)

combines placeholders

setvar=ls_string1=Hello

setvar=ls_string2=World

setvar=ls_result=%charadd(<ls_string1>,<ls_string2>)

ls_result = "HelloWorld"

lower

converts to lower-case

upper

converts to upper-case

ulower

transfer first letter to uppercase

cr2crlf

converts cr char to cr-lf char

crlf2cr

converts cr-lf char to cr char

ctlf2space

replace all cr-lf with space (delete all line breaks) beas 9.1 PL:08

replace(var,fromvalue,tovalue)

converts from the variable "var" all chars "fromvalue" to "tovalue" wandeln. "fromvalue" and "tovalue" can contain several chars and must not have the same length.

 

Example: delete all line feeds and replace this with a space

setvar=ls_test=hello<cr_lf>world
setvar=ls_test=%replace(<ls_test>,<cr_lf>,<char 32>)

len(var)

returns the length of the variable

intoken(var,starttoken,endtoken)

returns the string-sequence between start-token and end-token, e. g.

setitem=ls_value=Hello World [color:red] !
setitem=ls_color=%intoken(<ls_value>,[color:,])

ls_color is: "red"

pos(var1,var2)

Get the Pos from var2 in var1

Example

setvar=ls_string=Hello World
setvar=ls_search=World
setvar=ls_result=%pos(<ls_string>,<ls_search>)
messagebox=Pos: <ls_result>

Display: Pos: 7

len(var1)

Return the count of Letters

setvar=ls_string=Hello World
setvar=ls_result=%len(<ls_string>)
messagebox=Len: <ls_reslult>

Display: Len: 10

right(var1,count)

Get right Letters from the String

setvar=ls_string=Hello World
setvar=ls_result=%right(<ls_string>,5)

result = "World"

left(var1,count)

Get right Letters from the String

setvar=ls_string=Hello World
setvar=ls_result=%left(<ls_string>,5)
messagebox=<ls_result>

result = "Hello"

mid(var,start,length)

only chars starting with "start" with length "length"

setvar=ls_string=Hello big World
setvar=ls_result=%mid(<ls_string>,7,3)
messagebox=<ls_result>

result = "big"