LogiView

Function 'split'

     

This function is used to split up the forwarded string expression and to assign the individual substrings to a specified string array. The result of this function is the number of assigned substrings.

Using the third (optional) parameter the separator to be used and defaults for handling quotation marks, etc. can be defined. Spaces, quotation marks and brackets at the beginning and the end of each substring are removed.
 

Syntax:

 

{INT_VAR}= split ({STR_EXPR}, {STR_VAR}) or
{INT_VAR}= split ({STR_EXPR}, {STR_VAR}, {STR_EXPR})

 

I/O parameters:

{STR_EXPR} String to be split.
{STR_EXPR} Optional parameter used to define the separator and further adjustments
/SEPARATOR=, Optional setting of the separator (several characters can be used but not '/'). The standard setting is a colon ','

/BRACKET

Option to define the usage of brackets '(' and ')'. In this case the separators within brackets are ignored.
/SINGLE_QUOTE Option to define the usage of single quotation marks '. In this case the separators within a part included in single quotation marks are ignored.
/DOUBLE_QUOTE Option to define the usage of double quotation marks ". In this case the separators within a part included in double quotation marks are ignored.
{STR_VAR} String type array to be assigned with individual substrings.
 

Return value:

 
{INT_VAR} Integer value containing the number of forwarded substrings.
 

Example:

  Declaration of Variables
 
 10 DOCU_STRING_1 = "'1234;atc'; '1235;abb'; '1236;xcf'; '1237;uhg'"	

 20 DOCU_INT_1 = split(DOCU_STRING_1,DOCU_STRING_ARRAY_1[1],

                                       "/SEPARATOR=; /SINGLE_QUOTE")	

 30 DOCU_INT_2 = 1	

 40 while ( DOCU_INT_2 <= DOCU_INT_1 )	

 50   put(DOCU_STRING_ARRAY_1[DOCU_INT_2])	

 60   DOCU_INT_2=DOCU_INT_2+1	

 70 done	
  Result:
 

In this example the separators withing the substrings are ignored, because the single quotation marks are respected. However, the single quotation marks are removed.

Functions and commands: Editing Strings