FUNCTION FXPARPOS, KEYWRD, IEND, BEFORE=BEFORE, AFTER=AFTER ; ON_ERROR,2 ;Return to caller ; ; Check the number of parameters. ; IF N_PARAMS() NE 2 THEN MESSAGE, $ 'Required parameters are KEYWRD and IEND' ; ; If the AFTER keyword has been entered, then find the location. ; IF N_ELEMENTS(AFTER) EQ 1 THEN BEGIN KEY_AFTER = STRING(REPLICATE(32B,8)) STRPUT,KEY_AFTER,STRUPCASE(STRTRIM(AFTER,2)),0 ILOC = WHERE(KEYWRD EQ KEY_AFTER,NLOC) IF NLOC GT 0 THEN RETURN, (MAX(ILOC)+1) < IEND ENDIF ; ; If AFTER wasn't entered or found, and if the BEFORE keyword has been ; entered, then find the location. ; IF N_ELEMENTS(BEFORE) EQ 1 THEN BEGIN KEY_BEFORE = STRING(REPLICATE(32B,8)) STRPUT,KEY_BEFORE,STRUPCASE(STRTRIM(BEFORE,2)),0 ILOC = WHERE(KEYWRD EQ KEY_BEFORE,NLOC) IF NLOC GT 0 THEN RETURN,ILOC[0] ENDIF ; ; Otherwise, simply return IEND. ; RETURN,IEND END