CFPRIME INMENU                                                          INMENU      1
C***********************************************************************RIGHTE      1
C*                                                                     *RIGHTE      2
C*        Extended Transient-Midterm Stability Program (ETMSP)         *RIGHTE      3
C*        ====================================================         *RIGHTE      4
C*                                                                     *RIGHTE      5
C*       Copyright (C) (1993) Electric Power Research Institute        *RIGHTE      6
C*                                                                     *RIGHTE      7
C* EPRI reserves all rights in the software and associated             *RIGHTE      8
C* documentation as delivered. The software and its associated         *RIGHTE      9
C* documention or any portion thereof may not be reproduced in any form*RIGHTE     10
C* whatsoever without the consent of EPRI, except as explicity provided*RIGHTE     11
C* for by license. Licensee shall submit a detailed description to EPRI*RIGHTE     12
C* of any changes or modifications to the software within two (2)      *RIGHTE     13
C* months after such changes or modifications are made. At EPRI's sole *RIGHTE     14
C* discretion, the software, as changed or modified, shall be given a  *RIGHTE     15
C* new designation sufficiently different from its then current        *RIGHTE     16
C* designation as to prevent mistake,confusion, or deception as between*RIGHTE     17
C* the current software as changed or modified.                        *RIGHTE     18
C*                                                                     *RIGHTE     19
C* A license under EPRI's rights in the software can be obtained       *RIGHTE     20
C* directly from EPRI.                                                 *RIGHTE     21
C*                                                                     *RIGHTE     22
C* This program and supporting materials may be independently available*RIGHTE     23
C* from Electric Power Software centre (EPSC) for an appropriate       *RIGHTE     24
C* distribution fee. The EPSC is a service of                          *RIGHTE     25
C*                                                                     *RIGHTE     26
C*                    Power Computing Company                          *RIGHTE     27
C*                    1930 Hi Line                                     *RIGHTE     28
C*                    Dallas, Tx 75207                                 *RIGHTE     29
C*                                                                     *RIGHTE     30
C* NEITHER EPRI, ANY MEMBER OF EPRI, NOR ANY PERSON OR  ORGANIZATION   *RIGHTE     31
C* ACTING ON BEHAVE OF THEM:                                           *RIGHTE     32
C*                                                                     *RIGHTE     33
C* 1. MAKE ANY WARRANTY OR REPRESENTATION WHATSOEVER, EXPRESS OR       *RIGHTE     34
C*    IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS OR *RIGHTE     35
C*    ANY PURPOSE WITH RESPECT TO THE SOFTWARE OR ITS ASSOCIATED       *RIGHTE     36
C*    DOCUMENTATION; OR                                                *RIGHTE     37
C*                                                                     *RIGHTE     38
C* 2. ASSUMES ANY LIABILITY WHATSOEVER WITH RESPECT TO ANY USE OF THE  *RIGHTE     39
C*    SOFTWARE OR ITS ASSOCIATED DOCUMENTATION OR ANY PORTION THEREOF  *RIGHTE     40
C*    OR WITH RESPECT TO ANY DAMAGES WHICH MAY RESULT FROM SUCH USE.   *RIGHTE     41
C*                                                                     *RIGHTE     42
C* THIS NOTICE MAY NOT BE REMOVED FROM THE SOFTWARE BY ANY USER        *RIGHTE     43
C* THEREOF.                                                            *RIGHTE     44
C*                                                                     *RIGHTE     45
C***********************************************************************RIGHTE     46
      SUBROUTINE INMENU(STRING,ISTAT)                                   INMENU      3
CD                                                                      INMENU      4
CD    TO ENTER THE MENU INTERFACE MODE AT THE ROOT LEVEL OF ETMSP.      INMENU      5
CD                                                                      INMENU      6
      INCLUDE 'CNLSTA.INS'                                              INMENU      7
      INCLUDE 'CNKEYW.INS'                                              INMENU      8
C                                                                       INMENU      9
      CHARACTER*80 LINE,STRING,MSG                                      INMENU     10
      CHARACTER*7 SUBPMT                                                INMENU     11
      CHARACTER*3 HELPT                                                 INMENU     12
C                                                                       INMENU     13
      ISTAT=0                                                           INMENU     14
C                                                                       INMENU     15
      SUBPMT='  MENU '                                                  INMENU     16
    1 CONTINUE                                                          INMENU     17
C                                                                       INMENU     18
C    ...................................................................INMENU     19
C    : Display menu option on screen                                   :INMENU     20
C    :                                                                 :INMENU     21
      WRITE(LOUT,5010)                                                  INMENU     22
 5010 FORMAT(1X,79('.'),//,                                             INMENU     23
     19X,'                    MENU MODE                        ',//,    INMENU     24
     16X,'SELECT A COMMAND BY THE NUMBER OR BY TYPING THE COMMAND ',    INMENU     25
     1'KEYWORD',/,                                                      INMENU     26
     16X,'(WITH PARAMETERS IF ANY). TO GET HELP ON A SPECIFIC ',        INMENU     27
     1'COMMAND, TYPE',//,                                               INMENU     28
     19X,'         HELP <COMMAND NUMBER OR KEYWORD>            ',//,    INMENU     29
     16X,'TO QUIT FROM MENU MODE, TYPE QUIT OR MENU.         ',/)       INMENU     30
      I=1                                                               INMENU     31
   10 J=5*I                                                             INMENU     32
      WRITE(LINE,5000) (K,KEYW(K),K=J-4,J)                              INMENU     33
      GOTO (11,12,13,14,15,20,20,20), I                                 INMENU     34
   11 WRITE(LINE(26:26),'(A)') '*'                                      INMENU     35
      WRITE(LINE(43:43),'(A)') '*'                                      INMENU     36
      WRITE(LINE(59:59),'(A)') '*'                                      INMENU     37
      WRITE(LINE(75:75),'(A)') '*'                                      INMENU     38
      GOTO 20                                                           INMENU     39
   12 WRITE(LINE(13:13),'(A)') '*'                                      INMENU     40
      WRITE(LINE(26:26),'(A)') '*'                                      INMENU     41
      WRITE(LINE(71:71),'(A)') '*'                                      INMENU     42
      GOTO 20                                                           INMENU     43
   13 WRITE(LINE(44:44),'(A)') '*'                                      INMENU     44
      WRITE(LINE(60:60),'(A)') '*'                                      INMENU     45
      WRITE(LINE(30:30),'(A)') '*'                                      INMENU     46
      GOTO 20                                                           INMENU     47
   14 WRITE(LINE(75:75),'(A)') '*'                                      INMENU     48
      GOTO 20                                                           INMENU     49
   15 WRITE(LINE(14:14),'(A)') '*'                                      INMENU     50
      GOTO 20                                                           INMENU     51
   20 WRITE(LOUT,'(A)') LINE                                            INMENU     52
      I=I+1                                                             INMENU     53
      IF (J.LT.INSTAL) GOTO 10                                          INMENU     54
 5000 FORMAT(5(1X,:,'(',I2,') ',A8,1X))                                 INMENU     55
C                                                                       INMENU     56
      WRITE(LOUT,5020 )                                                 INMENU     57
 5020 FORMAT(/,1X,'1-7 SESSION CONTROL   8-24,27 DATA PREPARATION  '    INMENU     58
     1,'26,29 SIMULATION CONTROL',/,1X,'* REPEATABLE COMMANDS'          INMENU     59
     2,//,1X,79('.'))                                                   INMENU     60
C    :.................................................................:INMENU     61
C    ...................................................................INMENU     62
C    : Get selection from the user                                     :INMENU     63
C    :                                                                 :INMENU     64
      MSG='MENU MODE IS ACTIVE. ENTER YOUR SELECTION:'                  INMENU     65
      CALL REDLIN(LOUT,LIN,IOERR,42,MSG,SUBPMT,'MEN',STRING,RECORD,     INMENU     66
     &IREC,KLAYER,KEND,KREAD,PLAYBA)                                    INMENU     67
C    :.................................................................:INMENU     68
C    ...................................................................INMENU     69
C    : If quit, toggle menu mode off and return to command mode        :INMENU     70
C    :                                                                 :INMENU     71
      IF (STRING(1:3).EQ.'QUI'.OR.STRING(1:3).EQ.'qui') THEN            INMENU     72
         WRITE(STRING,'(A)') 'MENU'                                     INMENU     73
         GOTO 9999                                                      INMENU     74
      ENDIF                                                             INMENU     75
C    :.................................................................:INMENU     76
C    ...................................................................INMENU     77
C    : If help, check help number or keyword                           :INMENU     78
C    :                                                                 :INMENU     79
      IF (STRING(1:3).EQ.'HEL'.OR.STRING(1:3).EQ.'hel') THEN            INMENU     80
         IBLANK=INDEX(STRING,' ')                                       INMENU     81
         DO 100 I=IBLANK+1,80                                           INMENU     82
            IF (STRING(I:I).NE.' ') THEN                                INMENU     83
               CALL ALPHAN(STRING,I,IOS)                                INMENU     84
               IF (IOS.NE.0) THEN                                       INMENU     85
                  READ(STRING(I:I+1),*,IOSTAT=IOS) IH                   INMENU     86
                  IF (IH.EQ.0.AND.IOS.EQ.0) THEN                        INMENU     87
                     HELPT='MEN'                                        INMENU     88
                  ELSE IF (IH.LE.INSTAL.AND.IOS.EQ.0) THEN              INMENU     89
                     HELPT=KEYW(IH)                                     INMENU     90
                  ELSE                                                  INMENU     91
                     WRITE(LOUT,'(/,A,/)')                              INMENU     92
     1               ' *** ERROR HELP NUMBER OUT OF RANGE'              INMENU     93
                     GOTO 1                                             INMENU     94
                  END IF                                                INMENU     95
               ELSE                                                     INMENU     96
                  HELPT=STRING(I:I+2)                                   INMENU     97
               END IF                                                   INMENU     98
               GOTO 110                                                 INMENU     99
            END IF                                                      INMENU    100
  100    CONTINUE                                                       INMENU    101
         HELPT='MEN'                                                    INMENU    102
  110    CALL HELPSC(HELPT,3)                                           INMENU    103
         MSG=' PRESS RETURN KEY TO CONTINUE:'                           INMENU    104
         CALL REDLIN(LOUT,LIN,IOERR,30,MSG,SUBPMT,'MEN',STRING,RECORD,  INMENU    105
     &   IREC,KLAYER,KEND,KREAD,PLAYBA)                                 INMENU    106
         GOTO 1                                                         INMENU    107
      ENDIF                                                             INMENU    108
C    :..........................................................:       INMENU    109
C    ............................................................       INMENU    110
C    : If non of the above, read the option number. Let command :       INMENU    111
C    : mode handle it if input is not a number.                 :       INMENU    112
C    : For some reason,'F' &'T' returns a '0' so ERR=9999 would :       INMENU    113
C    : not activate. Over come this manually.                   :       INMENU    114
C    :                                                          :       INMENU    115
      CALL ALPHAN(STRING,1,IOS)                                         INMENU    116
      IF(IOS.EQ.0) GOTO 9999                                            INMENU    117
      READ(STRING,*,IOSTAT=IOS) II                                      INMENU    118
      IF((II.LT.1).OR.(II.GT.INSTAL))THEN                               INMENU    119
         WRITE(LOUT,'(/,A,/)') ' ERROR MENU NUMBER OUT OF RANGE'        INMENU    120
         GOTO 1                                                         INMENU    121
      ENDIF                                                             INMENU    122
C    :..........................................................:       INMENU    123
C                                                                       INMENU    124
C    ............................................................       INMENU    125
C    : Form the command and let command mode do it's thing      :       INMENU    126
C    :                                                          :       INMENU    127
      WRITE(STRING,'(A)')KEYW(II)                                       INMENU    128
C    :..........................................................:       INMENU    129
C                                                                       INMENU    130
C                                                                       INMENU    131
 9999 CONTINUE                                                          INMENU    132
      RETURN                                                            INMENU    133
      END                                                               INMENU    134
