FRM
v1.4.2

std
Script emos_std_string_lib

CompiledModule
  |
  +--emos_std_string_lib

This library contains some useful string manipulation routines.

Tsl
emos_std_string_lib.tsl

Function Summary
 String alltrim(in str1)
           
 String arr2str(inout[] arr, in sep, in count, in start)
          This functions concatenates all elements of the array into a string.
 String index1(in s1, in s2)
           
 String index2(in s1, in s2, in n1)
           
 String join_path(in part1, in part2, in sep)
          Diese Funktion fügt zwei Pfadteile zusammen.
 String ltrim(in str1)
           
 String random_arr(inout[] arr1, in nnn)
           
 String replace(in str, in delchr, in insstr)
          Replaces all delchr characters with insstr string.
 String replace1(in s1, in s2, in s3)
           
 String split_path(in path, out dir, out file, in sep)
          Splits a path string into a directory and file parts.
 String split1(in s1, inout[] arr1, in s2)
           
 String strip_both(in str, in zap)
          Removes all occuences of zap from both sides of str (trim).
 String strip_front(in str, in zap)
          Removes all occuences of zap from the front of str (left trim).
 String strip_trail(in str, in zap)
          Removes all occuences of zap from the end of str (right trim).
 String substr1(in str1, in s1, in s2)
           
protected  String test_replace()
           
 String trim(in str1)
           
 String yyyymmdd_str(in time)
          Converts the integer returned by the get_time function to a string formatted as YYYYMMDD.
 

Function Detail

arr2str

public String arr2str(inout[] arr,
                      in sep,
                      in count,
                      in start)
This functions concatenates all elements of the array into a string. Elements are separated by sep.

NOTE! Iy the arr is not sequentially inexed (starting from 0), then either the count should NOT be defined (in operator will be used) or start must be defined (sequential from then on).

Parameters:
sep - (in) (optional) separator, [default: comma]
count - (in) (optional) number of elements in the array [default: 0]
start - (in) (optional) starting index [default: 0]
Returns:
streamed array

replace

public String replace(in str,
                      in delchr,
                      in insstr)
Replaces all delchr characters with insstr string.

NOTE1! This function internally uses split() to process the string. Unfortunatelly, split() has an undocumented "feature" that it trims blanks from the given string before splitting. This has the effect that replace() does the same. If you don't want the string to be trimmed, use replace1().

NOTE2! The replace() replaces each occurence of individual characters within delchr with the complete string insstr. It does NOT replace string delchr with the string insstr.

Parameters:
str - (in) string to be processed
delchr - (in) character(s) to be replaced
insstr - (in) string to be used as replacement
Returns:
converted string

test_replace

protected String test_replace()

strip_trail

public String strip_trail(in str,
                          in zap)
Removes all occuences of zap from the end of str (right trim).

Parameters:
str - (in) string to be processed
zap - (in) (optional) string to be removed [default: " "]
Returns:
converted string

strip_front

public String strip_front(in str,
                          in zap)
Removes all occuences of zap from the front of str (left trim).

Parameters:
str - (in) string to be processed
zap - (in) (optional) string to be removed [default: " "]
Returns:
converted string

strip_both

public String strip_both(in str,
                         in zap)
Removes all occuences of zap from both sides of str (trim).

Parameters:
str - (in) string to be processed
zap - (in) (optional) string to be removed [default: " "]
Returns:
converted string

split_path

public String split_path(in path,
                         out dir,
                         out file,
                         in sep)
Splits a path string into a directory and file parts. The path separator can be defined with sep (default: backslash)

NOTE! The function does not analyse whether the file part is indeed a file name. Anything following the last is treated as file. Anything before is treated as dir. NOTE2! dir does not end with sep.

Parameters:
path - (in) string to be processed
dir - (out) directory-part (up until the last sep)
file - (out) name-part (anything after the last sep)
sep - (in) (optional) separator (default: backslash)
Returns:
E_OK: success !E_OK: error (do not ust the out variables!)

join_path

public String join_path(in part1,
                        in part2,
                        in sep)
Diese Funktion fügt zwei Pfadteile zusammen. Dabei werden sep konvertiert "/-->\ bzw. \-->/). Standardmeßig werden \ durch / ersetzt. Eventuell nicht oder merfach vorhandene Separatoren in der Join-Stelle werden auf ein gesetzt.

EXAMPLE:

	join_path( "C:\aaa", "bbb.xxx" )   ==>  "C:/aaa/bbb.xxx"
	join_path( "C:\aaa\", "\bbb.xxx" ) ==>  "C:/aaa/bbb.xxx"
	join_path( "", "bbb.xxx" )         ==>  "/bbb.xxx"
	join_path( "C:/aaa" )              ==>  "C:/aaa/"

Parameters:
part1 - (in) erster Teil der Pfadangabe
part2 - (in) zweiter Teil der Pfadangabe
sep - (in) (optional) Pathseparator to use [default: /]
Returns:
concatenated path

trim

public String trim(in str1)

ltrim

public String ltrim(in str1)

alltrim

public String alltrim(in str1)

random_arr

public String random_arr(inout[] arr1,
                         in nnn)

replace1

public String replace1(in s1,
                       in s2,
                       in s3)

substr1

public String substr1(in str1,
                      in s1,
                      in s2)

index1

public String index1(in s1,
                     in s2)

index2

public String index2(in s1,
                     in s2,
                     in n1)

split1

public String split1(in s1,
                     inout[] arr1,
                     in s2)

yyyymmdd_str

public String yyyymmdd_str(in time)
Converts the integer returned by the get_time function to a string formatted as YYYYMMDD. This function converts the integer argument (time) returned by the get_time function to a string, in the format "YYYYMMDD" For example, the string "19981205", is the return value of the function.

Parameters:
time - (in) [optional] integer returned by get_time() or any other integer that is interpreted as number of seconds passes since 1.Jan.1970. [default: today]
Returns:
string formatted to YYYYMMDD or empty string if date could not be interpreted.

FRM
v1.4.2