Home | About SQeeL | Document | DownLoad | Mail Japanese
Home > Document > SQeeL Reference

String function

  • Built-in function
  • asc()
    Description
    Returns character code in decimal
    Syntax
    ret = asc(string)
    Parameters
    string:length 1 of character string
    Return Value
    number:Character code
    0:Error
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // 1:83
    // 2:83
    //
    
    run()
    exit
    
    function run()
    	print(asc('S'))
    	print(asc('SQeeL'))
    endfunction
    
    
    Topへ
    chr()
    Description
    Converts character code (e.g. a number, date) to a string
    Syntax
    ret = chr(n)
    Parameters
    n:Integer
    Return Value
    string:Converted character string
    System Return Value
    ERROR
    0Success
    1Argument error
    See Also
    Example
    //[result example]
    //
    //POPWEB
    //
    
    run()
    exit
    
    function run()
    	print(chr(0x50) & chr(0x4f) & chr(0x50) & chr(0x57) & chr(0x45) & chr(0x42))
    endfunction
    
    
    Topへ
    eval()
    Description
    Evaluates the EXPRESSION lexically and returns it.
    This can be executed in the lexical context of the SQeeL.
    Syntax
    ret = eval(expression)
    Parameters
    expression:Expression (character string)
    Example
    //[result example]
    //
    // hello world
    //
    
    run()
    exit
    
    function run()
    
    	local data1 = 'print(\'hello world\', stdout)'
    
    	eval(data1)
    
    endfunction
    
    
    Topへ
    instr()
    Description
    Starts searching STRING2 from the Nth letter in STRING. It returns the position of the Mth occurrence of SEARCH_STRING in STRING.
    If the length of SEARCH_STRING is longer than 1, it returns the location of the first letter.
    If N is negative, it start searching from the end of STRING. The value of M must be pisitive.
    The default of both N and M is 1. This starts searching SEARCH_STRING from the beginning of STRING. It returns the position of the first occurrence of SEARCH_STRING in STRING.
    The return value is the exact position from the beginning of the letters, regardless of the value of N.
    If the search fails (e.x. there are not M occurrences of SEARCH_STRING in STRING after Nth letter), the return value is 0.
    Syntax
    ret = instr(string1,search_string,n,m)
    Parameters
    string1:Character string to be searched
    search_string:Search string
    n:Location to start searching
    Default: 1
    m:Number of strings to be searched
    Default: 1
    Return Value
    integral number:Location found
    0:Search fails
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    // 1:6
    // 2:13
    //
    
    run()
    exit
    
    function run()
    	local a = 'data1;.data2;.data3;.data4'
    	print(instr(a, ';.', 1, 1))
    	print(instr(a, ';.', -8, 1))
    endfunction
    
    
    Topへ
    length()
    Description
    Returns the length in characters of the value of STRING.
    Syntax
    ret = length(string)
    Parameters
    string:Character string
    Return Value
    integral number:Length of character string
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    //"Insight" length:7
    //"Technology" length:9
    //"Insight Technology" length:17
    //
    
    run()
    exit
    
    function run()
    	local a = 'Insight'
    	local a = 'Technology'
    	local c = a & b
    	print('"' & a & '" length :' & length(a) & '\n',stdout)
    	print('"' & b & '" length :' & length(b) & '\n',stdout)
    	print('"' & c & '" length :' & length(c),stdout)
    endfunction
    
    
    Topへ
    lower()
    Description
    Converts character string to lower-case letters
    Syntax
    ret = lower(string)
    Parameters
    string:Character string to be converted to lower-case character
    Return Value
    string:Converted character string
    System Return Value
    ERROR
    0Success
    1Argument error
    See Also
    Example
    //[result example]
    //
    // insight technology
    //
    
    run()
    exit
    
    function run()
    	local a = 'INSIGHT TECHNOLOGY'
    	
    	print(lower(a),stdout)
    endfunction
    
    
    Topへ
    lpad()
    Description
    Pads the string specified by STRING2 to left side of STRING1. Returns the part of string specified by N parameters
    If the length in characters of the value of STRING1 is longer than N parameters, returns the part in STRING1 within N parameters.
    Syntax
    ret = lpad(string1,n,string2)
    Parameters
    string1:Character string to be converted
    n:Length of character string after conversion
    string2:Character string to be padded
    Default: single blank space
    Return Value
    string:Converted character string
    System Return Value
    ERROR
    0Success
    1Argument error
    See Also
    Example
    //[result example]
    //
    // 1:12345
    // 2:ab12345678
    //
    
    run()
    exit
    
    function run()
    	local a = '12345678'
    	local b = 'abcdefg'
    	print(lpad(a, 5,b))
    	print(lpad(a,10,b))
    
    endfunction
    
    
    Topへ
    ltrim()
    Description
    Delete characters from the left side of the character string until the specified character(deletion_char) is found.
    Delete blank space from the character string when the character(deletion_char) is not specified
    Syntax
    ret = ltrim(string,deletion_char)
    Parameters
    string:Character string to be converted
    deletion_char:Character string containing a letter to be deleted
    Default: single blank space
    Return Value
    string:Converted character string
    System Return Value
    ERROR
    0Success
    1Argument error
    See Also
    Example
    //[result example]
    //
    // XxyINSIGHT
    //
    
    run()
    exit
    
    function run()
    	local a = 'xyxyyXxyINSIGHT'
    	local b = 'yx'
    	print(ltrim(a, b))
    
    endfunction
    
    
    Topへ
    makepath()
    Description
    Concatenates all given character strings and returns the string to specify the file
    If needed, puts a delimiter between each string
    The letters('/' and '\') included in string are used as a delimiter of directory
    Syntax
    ret = makepath(string,{ … })
    Parameters
    string:Character string
    { … }:Character string
    Return Value
    string:Character string to identify a file
    System Return Value
    ERROR
    0Success
    Example
    //[result example]
    //
    // input words : to be or not to be that is the question
    // word[0] : to
    // word[1] : be
    // word[2] : or
    // word[3] : not
    // word[4] : to
    // word[5] : be
    // word[6] : that
    // word[7] : is
    // word[8] : the
    // word[9] : question
    //
    
    run()
    exit
    
    function run()
    
    	local input_str
    	local w_array, i
    
    	input_str = getopt('input words : ')
    	w_array = split(' ', input_str)
    
    	loop i=0; i<count(w_array); i++
    		print('word[${i}] : ${w_array[i]}', stdout)
    	endloop
    
    endfunction
    
    Topへ
    replace()
    Description
    Replace a character string(search_string) in the user variable to another one(replacement_string)
    If replacement_string is omitted, all character strings matching search_string will be removed. If search_string is not found, it returns search_string.
    Syntax
    ret = replace(string,search_string,replacement_string)
    Parameters
    string:Character string to be converted
    search_string:Search string
    replacement_string:Character string to be replaced
    Default: NULL
    Return Value
    string:Converted character string
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // 1:123DEFG
    // 2:DEFG
    //
    
    run()
    exit
    
    function run()
    	local a = 'ABCDEFG'
    	
    	print(replace(a,'ABC','123'),stdout)
    	print(replace(a,'ABC',''),stdout)
    endfunction
    
    
    Topへ
    rpad()
    Description
    Pads the string specified by STRING2 to right side of STRING1. Returns the part of string specified by N parameters
    If the length in characters of the value of STRING1 is longer than N bytes, returns the part in STRING1 within N parameters.
    Syntax
    ret = rpad(string1,n,string2)
    Parameters
    string1:Character string to be converted
    n:Length of character string after conversion
    string2:Character string to be padded
    Default: single blank space
    Return Value
    string:Converted character string
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // 1:12345
    // 2:12345678ab
    //
    
    run()
    exit
    
    function run()
    	local a = '12345678'
    	local b = 'abcdefg'
    	print(rpad(a, 5,b))
    	print(rpad(a,10,b))
    
    endfunction
    
    
    Topへ
    rtrim()
    Description
    Deletes the characters from the right side of the character string until the specified character(deletion_char) is found.
    Deletes blank space from the character string when the character(deletion_char) is not specified
    Syntax
    ret = rtrim(string,deletion_char)
    Parameters
    string:Character string to be converted
    deletion_char:Character string containing a letter to be deleted
    Default: single blank space
    Return Value
    string:Converted character string
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // xyxyyXxyINSIGHT
    //
    
    
    run()
    exit
    
    function run()
    	local a = 'xyxyyXxyINSIGHTxyy'
    	local b = 'yx'
    	print(rtrim(a, b))
    
    endfunction
    
    
    Topへ
    substr()
    Description
    Extracts a substring out of STRING. Returns the string started at the Mth position in STRING with the length specified by N parameters.
    If M is non-negative, search the first character in STRING, counting from the first of STRING.
    If M is negative, leaves that many characters off the end of the string.
    You cannot specify 0 to M parameter
    If N is omitted, returns everything to the end of the string.
    You cannot specify the value less than 1to N parameter
    Syntax
    ret = substr(string,m,n)
    Parameters
    string:Character string to be converted
    m:Start location
    n:Number of strings to be extracted
    Return Value
    string:Converted character string
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // 1:CD
    // 2:EF
    //
    
    run()
    exit
    
    function run()
    	local a = 'ABCDEFG'
    	
    	print(substr(a,3,2),stdout)
    	print(substr(a,-3,2),stdout)
    endfunction
    
    
    Topへ
    to_char()
    Description
    Converts a given number to a string with a specified format
    The following are format elements for the to_char function
    9 : Outputs value with the specified number of digits. If there is no number, it returns blank space.
    0 : Outputs value with the specified number of digits. It there is no number, it returns a zero.
    . : Outputs a decimal point, which is a period (.) in the specified position
    , : Outputs a comma (,) in the specified position
    s : Outputs the value with plus sign (+) or minus sign (-). If it (S) is specified in the first position of a number format model, it outputs the value with a leading sign.
    If it's specified in the last position, it outputs the value with a trailing sign.
    mi : If the value is negative, it outputs negative value with a trailing minus sign (-)
    pr : If the value is negative, it outputs negative value in
    eeee : Outputs number with fixed‐point part and two digit exponent part. Before 'e', it outputs fixed-point part. After 'e', it outputs plus (+) or minus (-) sign and exponential part.
    Syntax
    ret = to_char(num,format)
    Parameters
    num:Numerical value
    format:Format
    Return Value
    NULL:Fail or converted character string
    string:Converted character string
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // input number : 123456.07
    //    +123,456.070
    //
    
    run()
    exit
    
    function run()
    
    	local input_num
    	local output_num
    
    	input_num = getopt('input number : ')
    
    	output_num = to_char(input_num, 's999,999,990.000')
    
    	print(output_num, stdout)
    
    endfunction
    
    Topへ
    translate()
    Description
    Replace ""search_string"" in ""string"" with ""replacement_string
    If ""search_string"" in ""string"" is not found, it is not replaced.
    If search_string contains character strings more than replacement_string and if remaining character strings in search_string is found within string, these character strings are deleted and returned.
    Syntax
    ret = translate(string,search_string,replacement_string)
    Parameters
    string:Character string to be converted
    search_string:Character string containing a letter to be converted
    replacement_string:Character string containing a converted letter corresponding to from
    Return Value
    string:Converted character string
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    // 1:ABCDEFG@****
    // 2:
    //
    
    run()
    exit
    
    function run()
    	local a = 'ABCDEFG 1234'
    	local b = ' 0123456789'
    	local c = '1122334455'
    	print(translate(a, b, '@**********'))
    	print(translate(c, b, ''))
    
    
    endfunction
    
    
    Topへ
    upper()
    Description
    Converts character string to upper-case letters
    Syntax
    ret = upper(string)
    Parameters
    string:Character string
    Return Value
    string:Converted character string
    System Return Value
    ERROR
    0Success
    1Argument error
    Example
    //[result example]
    //
    // INSIGHT TECHNOLOGY
    //
    
    run()
    exit
    
    function run()
    	local a = 'insight technology'
    
    	print(upper(a),stdout)
    endfunction
    
    
    Topへ

    © Insight Technology, Inc. 1996-2003 All Rights Reserved.