Advanced Command
Prompting
Part 18
Presentation Copyright 2008, Bryan Meyers, [Link]
Reviewing the Prompt Facility
Command prompting allows user control over
how a command is executed
Invoke interactively by pressing F4
Or by preceding command with ?
Simple Command Prompting
Preceding a command with a ? Invokes simple
command prompting
Works within interactive CL program
Similar to pressing F4 on command line
?SAVLIB
Simple Command Prompting
Specifying a parameter value prevents
prompter from changing value
User can change other parameter values
?SAVLIB LIB(MYLIB)
Command Prompting Restrictions
Prompting not valid in batch program
Cannot prompt commands executed as part of
IF, ELSE, MONMSG
But can prompt commands in DO group
MONMSG CPF9810 EXEC(DO)
?ADDPFM
ENDDO
Command Prompting Restrictions
CL structural commands do not allow
prompting
CALL ELSE OTHERWISE
CALLPRC ENDDO PGM
CALLSUBR ENDPGM RCVF
CHGVAR ENDRCV RETURN
COPYRIGHT ENDSELECT RTNSUBR
DCL ENDSUBR SELECT
DCLF GOTO SNDF
DCLPRCOPT IF SNDRCVF
DO ITERATE SUBR
DOFOR LEAVE WAIT
DOUNTIL MONMSG WHEN
DOWHILE
Exit from Command Prompt
User might press F3 or F12 key in response to
prompt
Generates escape message CPF6801
?CRTLIB
MONMSG MSGID(CPF6801)
Selective Prompting
Program may prompt individual command
parameters selectively
And control how user can modify parameters
Prompt Value Displayed Input Allowed?
??KEYWORD() Default
??KEYWORD(value) Value
?*KEYWORD() Default
?*KEYWORD(value) Value
?-KEYWORD() Parameter not displayed;
command will use default
?-KEYWORD(value) Parameter not displayed;
command will use specified value
Selective Prompting
If command is not preceded by question mark,
only specified parameters will be show by
prompter
DSPLIB ??LIB(MYLIB) ?*OUTPUT(*PRINT)
Selective Prompting
If parameter uses ?- prompt character,
parameter is not displayed
Command must be preceded with ?
?DSPLIB ??LIB() ?-OUTPUT(*PRINT)
Selective Prompting Restrictions
Command must use keyword notation
Blanks not allowed between prompting
characters and keyword
If keyword value is not specified, default will
be used
If prompted parameter value is a variable,
variable value will not change even if user
changes parameter value
Command will use value supplied by user