      SUBROUTINE PC.THEN(OBJ)
*PRE-COMPILER
*
*DEV TRIAL RT
*BASIC
*N
*     PRECISION 6
*
************************************************************************
************************************************************************
***                                                                  ***
*** PICK PARSING PRE-COMPILER SYSTEM                                 ***
***                                                                  ***
*** COPYRIGHT 1988 MODULAR SOFTWARE                                  ***
***                P.O. BOX 204                                      ***
***                ATLANTA, GA  30291                                ***
***                (404) 964 - 7171                                  ***
***                                                                  ***
*** THIS PROGRAM IS PROPRIETARY TO MODULAR SOFTWARE AND MAY NOT BE   ***
*** USED, COPIED, EXAMINED, OR DISCLOSED WITHOUT A VALID LICENSE     ***
*** FROM MODULAR SOFTWARE.                                           ***
***                                                                  ***
************************************************************************
************************************************************************
*
* Subroutine to process single line THEN / ELSE / LOCKED statements
*
* This routine will convert OBJ into a format that does not contain
* any single-line THEN/ELSE/LOCKED statements.
*
      $INCLUDE PC.COMMON
*
      THEN.WORDS = 'ENDýTHENýELSEýLOCKED'
      CMND.WORDS = 'IFýOPENýREADýREADUýREADVýREADVUýMATREADýMATREADUýREADTýWRITETýWEOFýREWINDýLOCATEýREADNEXT'
      NO.THEN.WORDS = DCOUNT(THEN.WORDS,VM)
      NO.CMND.WORDS = DCOUNT(CMND.WORDS,VM)
*
      NEW.OBJ = ''
      NO.END.STMTS = 0
      I1 = DCOUNT(OBJ,AM)
      FOR I = 1 TO I1
         FLG = NO
         FOR J = 1 TO NO.THEN.WORDS UNTIL FLG
            LOCATE THEN.WORDS<1,J> IN OBJ<I,1,1> SETTING DUMMY THEN FLG = YES
         NEXT J
         IF FLG THEN
            END.FLG = NO
            OBJ2 = ''
            OBJ3 = ''
            J1 = DCOUNT(OBJ<I,1>,SVM)
            FOR J = 1 TO J1
               T = OBJ<I,1,J>
               T2 = OBJ<I,1,J+2>
               T4 = OBJ<I,1,J+4>
               BEGIN CASE
                  CASE T = 'END' AND T2 = 'ELSE' AND T4 = 'IF'
                     OBJ2 = OBJ2 : SVM : 'END ELSE IF'
                     J = J + 4
                  CASE T = 'END' AND T2 = 'ELSE'
                     IF J+2 <> J1 THEN
                        OBJ2 = OBJ2 : AM : 'END ELSE' : AM
                        NO.END.STMTS = NO.END.STMTS + 1
                     END ELSE
                        OBJ2 = OBJ2 : SVM : 'END ELSE'
                     END
                     J = J + 2
                  CASE T = 'END' AND T2 = 'CASE'
                     OBJ2 = OBJ2 : AM : 'END CASE'
                     J = J + 2
                  CASE 1
                     LOCATE T IN THEN.WORDS<1,1> SETTING DUMMY THEN
                        IF NOT(FLG) THEN
                           OBJ2 = OBJ2 : AM : 'END' : SVM : ' '
                           NO.END.STMTS = NO.END.STMTS - 1
                        END
                        OBJ2 = OBJ2 : SVM : T
                        END.FLG = YES
                        FLG = NO
                     END ELSE
                        IF TRIM(T) <> '' THEN
                           IF END.FLG THEN
                              NO.END.STMTS = NO.END.STMTS + 1
                              OBJ2 = OBJ2 : AM
                              END.FLG = NO
                           END
                        END
*
                        LOCATE T IN CMND.WORDS<1,1> SETTING DUMMY THEN
                           FLG = YES
                        END
                        OBJ2 = OBJ2 : SVM : T
                        IF OBJ<I,2,J> <> '' THEN
                           T0 = DCOUNT(OBJ2,AM)
                           T1 = DCOUNT(OBJ2<T0,1>,SVM)
                           OBJ3<T0,2,-1> = OBJ<I,2,J>
                        END
                     END
               END CASE
            NEXT J
            IF OBJ3 <> '' THEN
               J1 = DCOUNT(OBJ3,AM)
               FOR J = 1 TO J1
                  OBJ2<J,2> = OBJ3<J,2>
               NEXT J
            END
            NEW.OBJ<-1> = OBJ2[2,32000]
         END ELSE
            NEW.OBJ<-1> = OBJ<I>
         END
      NEXT I
*
      FOR I = 1 TO NO.END.STMTS
         NEW.OBJ = NEW.OBJ : AM : 'END'
      NEXT I
*
      OBJ = NEW.OBJ
*
      RETURN
*
      CW = '(C) Copyright 1985-1989 Modular Software.  All rights reserved.'
   END
