In a procedure with logic, you can use REXX SAY and PULL statements to prompt for variable values.
Use a SAY statement, or a sequence of SAY statements, to display text on the screen. For example, if you use the SAY statements in Figure 152:
say 'Hello,' whoisuser'.' say 'Please enter the letter of the weekly report you would like, ' say 'or NONE to exit:' say say ' A. Sales results (Monday Only)' say ' B. Tax figures' say ' C. Cumulative salaries'
The following appears:
Hello, username.
Please enter the letter of the weekly report you would like,
or NONE to exit:
A. Sales results (Monday Only)
B. Tax figures
C. Cumulative salaries
Specify a REXX PULL statement to retrieve the input from the screen and place it in the REXX variable answer as shown in Figure 154.
/* This procedure can produce any of three weekly reports regularly produced by the Acme Company--Sales, Tax, Cumulative Salaries, Inventory. It prompts the user for the type of report wanted, runs the necessary queries, and checks for errors. */ arg report . /* get any arguments from RUN PROC */ ok = 'NO' /* set variable for do loop */ "GET GLOBAL (WHOISUSER = DSQAO_CONNECT_ID" /* identify user */ if report = '' then /* check to see if no arg entered */ /* if no arg entered, prompt user until A,B,C, or NONE is entered */ do until ok = 'YES' say 'Hello,' whoisuser'.' say 'Please enter the letter of the weekly report you would like, ' say 'or None to exit:' say say ' A. Sales results (Monday Only)' say ' B. Tax figures' say ' C. Cumulative salaries' pull answer /* get answer from user */ answer = strip(answer) /* strip any leading or trailing blanks */ if answer = 'NONE' then exit 3 /* exit immediately if NONE */ if pos(answer,'ABC') ¬= 0 then ok = 'YES' /* if invalid value, */ end /* keep prompting. */ else answer = report
The exit code 3 was selected here to indicate the exit condition when the user enters None. As with any exit code, you choose the number to indicate an exit condition.
[ Previous Page | Next Page | Contents | Index ]