Products Downloads


French version



 


ADELIA

VADELIA

SADELIA

WADELIA

EADELIA

(I/B)

(I/B) (C/S)

(B) (S)

(I/B) (C/S)

(B) (C/S)



User paragraph

All


Syntax

SPLIT_STRING SourceString SeparatorString AlphaList



SourceString

Alphanumeric variable | Alphanumeric constant

SeparatorString

Alphanumeric variable | Alphanumeric constant

AlphaList

List with a single ALPHA(n)-type field.


Description

This instruction splits the SourceString string into substrings in the AlphaList list according to the separator(s) contained in SeparatorString.

Then all the characters in SepratorString specify the possible delimiters of substrings to be found in SourceString (see example no. 3).

Note that if the search returns an empty substring, then the latter will not be added to the AlphaList list (see example no. 4).

The results list is emptied beforehand.

This instruction updates the reserved word *RETURN_CODE:

0: executed normally

1: at least one substring was truncated as the list field was too short to contain it

-1: internal error when processing the instruction


Example

Example no. 1

ALPHA(50) SUBSTRING

LIST RES_LST SUBSTRING

ALPHA(100) MY_STRING


MY_STRING = 'PAUL;PATRICK;DAVID'

SPLIT_STRING MY_STRING ';' RES_LST

* RES_LST contains 3 elements 'PAUL', 'JOHN', 'DAVID'

* *RETURN_CODE = 0


Example no. 2

ALPHA(4) SUBSTRING4

LIST RES_LST SUBSTRING4

ALPHA(100) MY_STRING


MY_STRING = 'PAUL;PATRICK;DAVID'

SPLIT_STRING MY_STRING ';' RES_LST

* RES_LST contains 3 elements 'PAUL', 'PATR', 'DAVI'

* *RETURN_CODE = 1


Example no. 3

ALPHA(50) SUBSTRING

LIST RES_LST SUBSTRING

ALPHA(100) MY_STRING


MY_STRING = 'PAUL;PATRICK;DAVID'

SPLIT_STRING MY_STRING ';I' RES_LST

* RES_LST contains 5 elements 'PAUL', 'PATR', 'CK', 'DAV', 'D'

* *RETURN_CODE = 0


Example no. 4

ALPHA(50) SUBSTRING

LIST RES_LST SUBSTRING

ALPHA(100) MY_STRING


MY_STRING = 'PAUL;;DAVID'

SPLIT_STRING MY_STRING ';' RES_LST

* RES_LST contains 2 elements 'PAUL', 'DAVID'

* *RETURN_CODE = 0


↑ Top of page

  • Aucune étiquette