EBSILON®Professional Online Documentation
EbsScript / EbsScript Functions / String Functions
In This Topic
    String Functions
    In This Topic

    String Functions


    These functions are used for retrieval of special strings and for string operations. The string retrieval functions ("get...") can be used in text fields as well.

    Note that these functions do not change their arguments, but give their result as return value. For instance, a command

                stringLower (s);
    

    will not change s anyway. To modify s, you have to write

                s := stringLower (s)
    

    which writes the result of "stringLower (s)" back to the variable s.

    Name

    Purpose

    Arguments

    Return value

    Example

    PrintToString

    stores the result of a print command to a string

    several arguments, same syntax as the command "print"

    STRING

    s:=printToString ("DSP.MEASM = ", DSP.MEASM);

    StringCharAt

     

    retrieves the character of a string at a specified position

    1: STRING: string to be edited

    2: INTEGER: Position (starting with 1)

    CHAR

    c2:=stringCharAt (s, 2);

    StringComp

     

    compares two strings under consideration of capital and small letters

    1: STRING:
    2: STRING:

    INTEGER:
    0 if both the strings are identical

    -1 if string 1 is lexically before string 2,

    1 if string 1 is lexically after string 2

    i:=stringComp ("abc","ABC");
    gives 1, because ASCII code for "a" is > ASCII code for "A"

    StringCompNoCase

     

    compares two strings without considering the capital and small letters

    1: STRING:
    2: STRING:

    INTEGER:
    0 if both the strings are identical (except for capital and small letters),

    -1 if string 1 is lexically before string 2,

    1 if string 1 is lexically after string 2

    i:=stringCompNoCase ("abc", "ABC");
    gives 0

    StringDelete

     

    Deletes specific characters from a string

    1: STRING: string to be edited

    2: INTEGER: Position (starting with 1)

    3: INTEGER (optional): Number of characters to be deleted (default is 1)

    STRING: modified string

    s:=stringDelete ("ABC", 2);
    gives “AC”

    s:=stringDelete ("ABCDEF", 3, 2);
    gives “ABEF”

    StringFind

     

    Finds a sub-string in a larger string

    1: STRING: string to be edited

    2: STRING: sub-string to be searched

    3: INTEGER (optional): Start position for the search (default is 1)

    INTEGER: Position, at which the sub-string starts (starting with 1),

    0 if the sub-string is not found

    i:=stringFind ("ABC", "C");
    gives 3
    i:=stringFind ("ABCABC", "BC", 4);
    gives 5

    StringFindOneOf

     

    Finds the first matching character of a set

    1: STRING: string to be edited

    2: STRING: set of characters to be searched

    INTEGER: Position of the first occurrence of a character from the character set,

    0 if the string does nit contain any character from the set

    i:=stringFindOneOf ("ABC", "HFB");
    gives 2,
    i:=stringFindOneOf ("ABC", "XYZ");
    gives 0

    StringInsert

     

    insert a sub-string at a given position within the string

    1: STRING: string to be edited

    2: INTEGER: Position, at which the sub-string is inserted (starting with 1)

    3: STRING: sub-string to insert into string

    STRING: modified string

    s:=stringInsert ("ABC", 1, "XY"); gives “XYABC”

    StringLeft

     

    extracts the left part of a string

    1: STRING: string to be edited

    2: INTEGER: Number of characters to be extracted

    STRING: extracted string

    s:=stringLeft ("ABC", 2);
    gives “AB”

    StringLen

     

    returns the length of a string

    1: STRING: string to be edited

    INTEGER: Length of the string (0 for an empty string)

    i:=stringLen ("ABCDEF");
    gives 6

    StringLower

     

    Converts a string in lower case letters (includes German umlauts)

    1: STRING: string to be edited

    STRING: modified string

    s:=stringLower ("ABC");
    gives “abc”

    StringMid

     

    Extracts a specified part of a string

    1: STRING: string to be edited

    2: INTEGER: Position, at which the extraction is to start (starting with 1)

    3: INTEGER (optional): Number of characters to be extracted, if –1, the remainder of the string is extracted (default)

    STRING: extracted string

    s:=stringMid ("ABCDEF", 4);
    gives “DEF”
    s:=stringMid("ABCDEF", 4, 2);
    gives “DE”

    StringReplace

     

    replaces indicated characters of the string with the specified characters

    1: STRING: string to be edited

    2: STRING: string to be replaced

    3: STRING: string to be used for replacement

    STRING: modified string

    s:=stringReplace ("ABCABC", "B", "XY");
    gives “AXYCAXYC”

    StringReverse

     

    reverses the sequence of the characters in the string.

    1: STRING: string to be edited

    STRING: reversed string

    s:=stringReverse ("ABC");
    gives “CBA”

    StringRight

     

    extracts the right part of a string

    1: STRING: string to be edited

    2: INTEGER: Number of characters to be extracted

    STRING: extracted string

    s:=stringRight ("ABC", 2);
    gives “BC”

    StringSpanExcluding

     

    extracts a subset that contains only the characters not in a set

    1: STRING: string to be edited

    2: STRING: set of the characters that indicate the end of extraction

    STRING: extracted string

    s:=stringSpanExcluding ("ABC.DEF", ".,;" );
    gives “ABC”

    StringSpanIncluding

     

    extracts a subset that contains only the characters in a set

    1: STRING: string to be edited

    2: STRING: set of the characters that are allowed in the extracted string

    STRING: extracted string

    s:=stringSpanIncluding ("45;48;52", "0123456789" );
    gives “45”

    StringTrim

    trims leading and trailing white space characters from a string

    1: STRING: string to be edited

    STRING: modified string

    s:=stringTrim("  ABC  ");
    gives “ABC”

    StringTrimLeft

    trims leading white space characters from a string

    1: STRING: string to be edited

    STRING: modified string

     

    s:=stringTrimLeft("  ABC  ");
    gives “ABC  “

    StringTrimRight

     

    trims trailing white space characters from a string

    1: STRING: string to be edited

    STRING: modified string

     

    s:=stringTrimRight("  ABC  ");
    gives “  ABC”

    StringUpper

     

    Converts a string in upper case characters (including German umlauts, but ß remains unchanged)

    1: STRING: string to be edited

    STRING: modified string

     

    s:=stringUpper("abc");
    gives “ABC”