splittext
 splittext | 
   
  Purpose
 
 
 Split a text string.
 
 
  Synopsis
 
 function splittext(ts:text, sep:string):list of text
 function splittext(ts:text, sep:string, mxe:integer):list of text
 function splittext(qt:integer, ts:text, sep:string):list of text
 function splittext(qt:integer, ts:text, sep:string, mxe:integer):list of text
 
  Arguments
 
 | 
     
     qt 
       | 
   
     
     Quoting type (see parameter
     sys_qtype, default: -1 for no quoting)
       | 
  
| 
     
     ts 
       | 
   
     
     Text string to process
       | 
  
| 
     
     sep 
       | 
   
     
     Separator string
       | 
  
| 
     
     mxe 
       | 
   
     
     Maximum number of elements to collect (default:
     0 for no limit)
       | 
  
  Return value
 
 
 The list of identified items.
 
  Example
 
 
 The following statements:
 
 write(splittext("some/path/to/a.file","/",-2))
writeln(splittext(2,'cv1,"cv""2""",cv3',","))
 result in this display:
 [some/path/to,a.file][cv1,cv"2",cv3]
 
 
  Further information
 
 
 1. This function splits the input text string
 ts using the string
 sep as the field delimiter and returns the identified items as a list of texts. The argument
 mxe defines a maximum number of elements to put into this result list. If this limit is reached while the input string has not been entirely processed the last added item includes the remaining part of the input data as a single record.
 
 
 2. When the quoting type is not specified or when it is set to
 -1 the separator string may be an empty string and the maximum number of elements may take a negative value. With an empty separator the input text is split into individual characters. If the maximum number of elements is negative the decomposition is performed from the end of the string.
 
 
 3. When quoting is active (
 i.e.
 qt is not
 -1) a parsing error may occur: in this case the system status it set to a non-zero value (see
 getsysstat) and the parsing is interrupted (typically after an error the last item added to the result list is not valid).
 
 
  Related topics
 
  
  Module
 
 
