Split text with a separator

Sometimes the situation arises that a string is transferred which contains several pieces of information. For example: "123|328|984". In this case, you can determine the substring by "splitting" the text at the separator. For this purpose, there is a routine in which you can specify which of these "parts" you want to have.

C     Split text with a separator

C     

C call:

C     CALL PST154 (TEXTVAR,'|',1,CFELD,IERR)

C     

C     The separator must be specified as the second parameter.

C     The third parameter specifies which substring is to be determined

C     . In the example above it is the first substring.

C     

C     The following variables must be defined beforehand:

C     

C     TEXTVAR : Text from which the substring is to be determined

C     CFELD   : Partial string that is returned

C     IERR   : is not evaluated, but must be specified

C     

C     NOTE: The text variables TEXT and CFELD must be declared in the program header

C              !

C     CHARACTER *80 TEXTVAR, CFELD

C     

C     Example:

C     ----------------

C     Split text

C     ----------------

      TEXTVAR = "Hund|Katze|Maus"

C     

      CALL PST154 (TEXTVAR,'|',1,CFELD,IERR)

C     

C     The output with the instruction:

      WRITE(6,*)CFELD

C     

C     produces: Hund

C