This example is based on the BUILD_JOB Program described in detail in CDF-386. The Code fragments in this example are incomplete, but anyone interested in the actual code can look at the Build_Job CMS Library. The BUILD_JOB Program basically operates in Command Line Mode, but uses Menus extensively in order to define the valid responses at various stages of the execution. BUILD_JOB uses a UIPACK Definition File, a portion of which is used in this example. The Example File defines the Verbs QUIT (which exits the program), SET (which sets some attribute of the program) and SHOW (which displays the setting of some attribute). QUIT takes no parameters or qualifiers. SET has the following legal Parameter Names - FILENAME and UTILITIES. These legal Parameters are therefore defined as another Verb Group. SHOW has the following legal Parameter Names - FILENAME, UTILITIES and VERSION. These are again defined within another Verb Group. Most of these Commands take some Qualifiers and thus the legal Commands are:-
QUIT Quit the Program SET FILENAME <Filename> Specify a new Filename SET FILENAME/DEFAULT Restore Default Filename SET UTILITIES/YBOS=<On/Off> Enable or Disable YBOS SET UTILITIES/YHIST=<On/Off> Enable or Disable YHIST SET UTILITIES/DEFAULT Restore Default On/Off SHOW FILENAME Display Current Filename SHOW UTILITIES Display Utilities SHOW VERSION Display Program Version
!--------------- EXAMPLE 3 Definition File ----------------
!
! This Verb Group contains all User accessible
! Verbs & Menus
Group 100 (1)
Verb Quit
Verb Set
Verb Show
Menu 1 /Title="BuildJob Commands"/Prompt="Build>"
Button 1 /Description="Display Something" -
/Response="Show"
Button 2 /Description="Set Something" -
/Response="Set"
Button 4 /Description="Display Output Filename" -
/Response="Show Filename"
Button 5 /Description="Display Utilities" -
/Response="Show Utilities"
Button 7 /Description="Specify Output Filename" -
/Response="Set Filename"
Button 9 /Description="Quit Program"/Response=Quit
Lock 12345 (2)
! SET Command Verb Group
! ======================
!
! This Group contains all valid Parameters
! for the SET Command
Group 101
Verb Filename/Default
Verb Utilities/YBOS=OnOff/YHIST=OnOff
Menu 2/Title="SET Actions"/Prompt="What:"
Button 1 /Description="Set Output Filename" -
/Response=Filename
Button 2 /Description="Restore Default Output Filename" -
/Response="Filename/Default"
Button 4 /Description="Set YBOS On/Off" -
/Response="Utilities/YBOS="
Button 5 /Description="Set YHIST On/Off" -
/Response="Utilities/YHIST="
Button 6 /Description="Restore Default Utilities On/Off" -
/Response="Utilities/Default"
Lock 2345
! SHOW Command Verb Group
! =======================
!
! This Group contains all valid Parameters
! for the SHOW Command
Group 102 (3)
Verb Filename
Verb Utilities
Verb Version
Menu 3/Title="SHOW Actions"/Prompt="What:"
Button 1 /Description="Show Output Filename" -
/Response=Filename
Button 2 /Description="Show Utilities" -
/Response=Utilities
Lock 2345
!------------ End of EXAMPLE 3 Definition File ------------
C------------------ EXAMPLE 3 CODE ------------------------
PROGRAM BJMAIN
C ==============
C
C Description:-
C =============
C Main Program for BUILDJOB (EXAMPLE ONLY)
C
$$If VAX
Implicit None
$$Endif
$$Include 'BuildJob$Library:BJPack.Inc' (4)
$$Include 'UIPack$Library:UIParam.Inc'
$$Include 'UIPack$Library:UIError.Inc'
C
C External Declarations:-
C =======================
C
INTEGER UIINIT
INTEGER UIFINI
INTEGER UIDFFI
INTEGER UIACME
C
C Local Declarations:-
C ====================
C
INTEGER STATUS
CHARACTER*4 VERB
C
C Executable Code:-
C =================
C
STATUS = UIINIT(UIPRMD) (5)
IF (STATUS .EQ. UISUCC) THEN
C
C Define Dictionary of Allowed Verbs etc.
C =======================================
C
STATUS = UIDFFI(BJDFIL) (6)
C
C Loop awaiting User Input & Branching as necessary
C =================================================
C
100 CONTINUE
IF (STATUS .EQ. UISUCC) THEN
C
C Await User Input
C ================
C
STATUS = UIACME(BJPMEN,VERB) (7)
IF (STATUS .EQ. UISUCC .OR.
& STATUS .EQ. UIQUPR) THEN
IF (VERB .EQ. 'QUIT') THEN
C
C "QUIT" Command
C ==============
C
STATUS = UIFINI() (8)
STATUS = UIEOF
ELSEIF (VERB .EQ. 'SET ') THEN
C
C "SET" Command
C =============
C
CALL BJSET
STATUS = UISUCC
ELSEIF (VERB .EQ. 'SHOW') THEN
C
C "SHOW" Command
C ==============
C
CALL BJSHOW
STATUS = UISUCC
ENDIF
ENDIF
GO TO 100
ENDIF
ENDIF
C
C Program Termination
C ===================
C
STOP
END
SUBROUTINE BJSET
C ================
C
C Description:-
C =============
C This is the Handler for the "SET" Command.
C This Command takes one Parameter:-
C
C What: Object to be Set
C
C where the following Objects are valid:-
C
C FILENAME Set current Output Filename
C
C UTILITIES Set current Utilities enabled
C
C Global Declarations:-
C =====================
C
$$If VAX
Implicit None
$$Endif
$$Include 'BuildJob$Source:BJPack.Inc'
$$Include 'UIPack$Library:UIError.Inc'
C
C External Declarations:-
C =======================
C
INTEGER BJFILE
INTEGER BJUTIL
INTEGER UIACME
C
C Local Declarations:-
C ====================
C
INTEGER STATUS
CHARACTER*4 VERB
C
C Executable Code:-
C =================
C
C Pickup Object to be Displayed
C =============================
C
STATUS = UIACME(BJSEME,VERB) (9)
IF (STATUS .EQ. UISUCC .OR.
& STATUS .EQ. UIQUPR) THEN
IF (VERB .EQ. 'FILE') THEN
C
C "SET FILENAME" Command
C ======================
C
CALL BJFILE
ELSEIF (VERB .EQ. 'UTIL') THEN
C
C "SET UTILITIES" Command
C =======================
C
CALL BJUTIL
ENDIF
ENDIF
C
C Return to Caller
C ================
C
RETURN
END
SUBROUTINE BJFILE
C =================
C
C
C Description:-
C =============
C This Subroutine is the Handler for the
C "SET FILENAME" Command. This Command
C takes one Parameter:-
C
C Filename: Output Filename
C
C OR the following Qualifier:-
C
C /DEFAULT
C
C where this latter restores the Default Filename.
C
C Global Declarations:-
C =====================
C
$$If VAX
Implicit None
$$Endif
$$Include 'UIPack$Library:UIError.Inc'
C
C External Declarations:-
C =======================
C
INTEGER UIGTFI
INTEGER UIGTQU
C
C Local Declarations:-
C ====================
C
INTEGER STATUS
INTEGER FILLEN
CHARACTER*4 QUAL
CHARACTER*132 FILNAM
C
C Executable Code:-
C =================
C
DEFALT = .FALSE.
C
C Pickup any Qualifiers attached to the Verb
C ==========================================
C
STATUS = UIQUPR
100 CONTINUE
IF (STATUS .NE. UIQUAB) THEN (10)
STATUS = UIGTQU(QUAL)
IF (STATUS .EQ. UIQUPR .OR. (11)
& STATUS .EQ. UIQUNE .OR.
& STATUS .EQ. UIQUVA .OR.
& STATUS .EQ. UIQUDF) THEN
IF (QUAL .EQ. 'DEFA') THEN
C
C "DEFAULT" Qualifier
C ===================
C
DEFALT = .TRUE.
ENDIF
ENDIF
GO TO 100
ENDIF
IF (DEFALT) THEN
C
C "SET FILENAME/DEFAULT" Command - Restore Default
C ================================================
C
FILNAM = ..... (12)
FILLEN = LEN(FILNAM)
ELSE
C
C "SET FILENAME <Filename>" Command - Pickup Filename
C ===================================================
C
FILNAM = ..... (13)
STATUS = UIGTFI('Filename',FILNAM,FILLEN) (14)
ENDIF
C
C Save New Output Filename
C ========================
C
...... (15)
C
C Return to Caller
C ================
C
RETURN
END
SUBROUTINE BJUTIL
C =================
C
C Description:-
C =============
C This Subroutine is the Handler for the
C "SET UTILITIES" Command. This Command
C takes no Parameters, but must be accompanied
C by ate least one of the following Qualifiers:-
C
C /DEFAULT Setup Default States
C
C /YBOS[=On/Off] Enable/Disable YBOS Utility
C
C /YHIST[=On/Off] Enable/Disable YHIST Utility
C
C Global Declarations:-
C =====================
C
$$If VAX
Implicit None
$$Endif
$$Include 'BuildJob$Source:BJPack.Inc'
$$Include 'UIPack$Library:UIError.Inc'
C
INTEGER DUMMY
C
C External Declarations:-
C =======================
C
INTEGER UIGTON
INTEGER UIGTQU
INTEGER UIUSLE
C
C Local Declarations:-
C ====================
C
INTEGER STATUS
LOGICAL STATE
CHARACTER*4 QUAL
C
C Executable Code:-
C =================
C
C Pickup any Qualifiers attached to the Verb
C ==========================================
C
STATUS = UIQUPR
100 CONTINUE
IF (STATUS .NE. UIQUAB) THEN
STATUS = UIGTQU(QUAL) (16)
IF (STATUS .EQ. UIQUPR .OR.
& STATUS .EQ. UIQUNE .OR.
& STATUS .EQ. UIQUVA .OR.
& STATUS .EQ. UIQUDF) THEN
IF (QUAL .EQ. 'DEFA') THEN
C
C "SET UTILITIES/DEFAULT" Command - Setup Defaults
C ================================================
C
..... (17)
IF (QUAL .EQ. 'YBOS') THEN
C
C "SET UTILITIES/YBOS" Command - Pickup new On/Off State
C ======================================================
C
STATE = ..... (18)
IF (STATUS .EQ. UIQUVA) THEN
STATUS = UIGTON('YBOS Utility',STATE)
ENDIF
..... (19)
ELSEIF (QUAL .EQ. 'YHIS') THEN
C
C "SET UTILITIES/YHIST" Command - Pickup new On/Off State
C =======================================================
C
STATE = ..... (20)
IF (STATUS .EQ. UIQUVA) THEN
STATUS = UIGTON('YHIST Utility',STATE)
ENDIF
..... (21)
ENDIF
GO TO 100
ENDIF
C
C Return to Caller
C ================
C
RETURN
END
SUBROUTINE BJSHOW
C =================
C
C
C Description:-
C =============
C This Subroutine is the Handler for the
C "SHOW" Command. This Command takes one Parameter:-
C
C What: Object to be shown
C
C where the following Objects are valid:-
C
C FILENAME Show current Output Filename
C
C UTILITIES Show current Utilities enabled
C
C Global Declarations:-
C =====================
C
$$If VAX
Implicit None
$$Endif
$$Include 'BuildJob$Source:BJPack.Inc'
$$Include 'UIPack$Library:UIError.Inc'
C
C External Declarations:-
C =======================
C
INTEGER UIACME
C
C Local Declarations:-
C ====================
C
CHARACTER*4 VERB
C
C Executable Code:-
C =================
C
C Pickup Object to be Displayed
C =============================
C
BJSHOW = UIACME(BJSHME,VERB) (22)
IF (BJSHOW .EQ. UISUCC .OR.
& BJSHOW .EQ. UIQUPR) THEN
IF (VERB .EQ. 'FILE') THEN
C
C "SHOW FILENAME" Command
C =======================
C
..... (23)
ELSEIF (VERB .EQ. 'UTIL') THEN
C
C "SHOW UTILITIES" Command
C ========================
C
..... (24)
ELSEIF (VERB .EQ. 'VERS') THEN
C
C "SHOW VERSION" Command
C ======================
C
..... (25)
ENDIF
ENDIF
C
C Return to Caller
C ================
C
RETURN
END
C ------------------- END OF EXAMPLE 3 ---------------------
Notes: