SUBROUTINE GSUBS (SRCSTR, IPOS, SEPCH, RESSTR, LSTR, IEOS) C***************************************************************************** C C Description : Routine to get a substring out of a string, starting at C a given position and ending with the first occurrance of the C separating character. C Leading and trailing spaces are deleted C If the first and last characters of the result string are C quotes then the quotes are omitted; this is the only way C to get leading and trailing spaces in the result string. C C Arguments : SRCSTR = STRING containing source-string C IPOS = input: C INTEGER position in SCRSTR where RESSTR starts C output: C INTEGER position plus 1 of separating character C in SRCSTR, or C position of end-of-string character (=zero byte) C SEPCH = STRING containing the separating character C RESSTR = STRING containing the result-string C LSTR = INTEGER the maximum number of characters placed C into RESSTR C IEOS = INTEGER end of string flag: C 0 - normal return C -1 - end of string detected C C Author : F.A.Minkema C AKZO PHARMA, Oss Holland C dept. SDA C C Version : V2.0 Date : 12-jan-1983 C C Module name : GSUBS.FTN C C Package : RSX-LIBRARY C C Compilation/Linking : FOR/F4P/TR:NONE GSUBS C C Updates : name version C R. Beetz V2.0 C C description : .no maximum in RESSTR C .LSTR argument added C .quote handling C C***************************************************************************** BYTE SRCSTR(1),SEPCH(1),RESSTR(1),HLPSTR(128) C C RESSTR(1)=0 N1=IPOS !start of substring N2=IPOS !end of substring C C search separating character C 1 IF (SRCSTR(N2) .EQ. SEPCH(1)) 3,4,4 C THEN 3 IPOS=N2+1 IEOS=0 GOTO 10 C ELSE 4 IF (SRCSTR(N2) .EQ. 0) 5,6,6 C THEN 5 IPOS=N2 IEOS=-1 GOTO 10 C ENDIF C ENDIF 6 N2=N2+1 GOTO 1 10 N2=N2-1 C C trim leading spaces C 20 IF (N1 .GT. N2) GOTO 90 IF (SRCSTR(N1) .EQ. ' ') 22,30,30 C THEN 22 N1=N1+1 GOTO 20 C ENDIF C C trim trailing spaces C 30 IF (SRCSTR(N2) .EQ. ' ') 32,40,40 C THEN 32 N2=N2-1 GOTO 30 C ENDIF C C quote handling C 40 IF (N1 .EQ. N2) GOTO 50 IF (SRCSTR(N1).EQ.39 .AND. SRCSTR(N2).EQ.39) 42,50,50 C THEN 42 N1=N1+1 N2=N2-1 C ENDIF C C copy result C 50 CALL SCOPY(SRCSTR(N1),RESSTR,MIN0(N2-N1+1,LSTR)) 90 RETURN END