|
This function splits up a forwarded string into individual substrings which are assigned to corresponding variables according to the type by means of conversion. The result is the number of sucessfully assigned variables. The function is aborted if the format character string has been comletely processed or if a field in the input string is not appropriate to the conversion specifications. A substring extends to the next space, tab (\t) or line break (\n) or to an explicitely specified field width. Every conversion specification starts with the % character and ends with a conversion character. The space between % and the conversion character could contain the following (in sequence):
|
||||||||||||||||||||||||||||||
The following letters are used as conversion characters: | |||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
![]() |
If a substring in the input string does not correspond to a conversion character, the function is aborted. However, in this case no error is returned because the function only returns the number of successfully converted fields. In general, the 'scan' function could be compared with the 'sscanf' function of the C programming language. This function must be called in the action part only! |
||||||||||||||||||||||||||||||
Syntax: |
|||||||||||||||||||||||||||||||
{INT_VAR}= scan({STR_EXPR},{STR_EXPR},{VAR_LIST}) | |||||||||||||||||||||||||||||||
I/O parameters: |
|||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
Example 1: |
|||||||||||||||||||||||||||||||
Declaration of Variables | |||||||||||||||||||||||||||||||
10 DOCU_STRING_1 = "45.5 |ABCD 4711 | 33mm" 20 DOCU_INT_1 = scan(DOCU_STRING_1,"%f %*s %4s | %i", DOCU_FLOAT_1, DOCU_STRING_2,DOCU_INT_2) 30 put(DOCU_FLOAT_1,DOCU_STRING_2,DOCU_INT_2) |
|||||||||||||||||||||||||||||||
Result: | |||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
Besides the conversion information '%i', '%f', '%l' and '%s' also regular expressions contained in the C standard function 'sscanf' are supported. A LogiView string variable must always be included as related output argument. The following conversion information can be used:
|
|||||||||||||||||||||||||||||||
Example 2: |
|||||||||||||||||||||||||||||||
Declaration of Variables | |||||||||||||||||||||||||||||||
10 DOCU_STRING_1 = "abc*\defg" 20 C -- No special characters must be used 30 DOCU_INT_1 = scan(DOCU_STRING_1,"%[A-Za-z0-9]", DOCU_STRING_2) 40 put(DOCU_STRING_2) |
|||||||||||||||||||||||||||||||
Result: | |||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||
![]() |
Functions and commands: Editing Strings |