1. Home
  2. QLIST procedure

QLIST procedure

Gets the user to select a response interactively from a list (R.W. Payne).


HELP = text Help information for the QUESTION


ALTERNATIVES = texts Alternatives from which each choice is to be made
CODES = texts Codes to use to represent each set of alternatives
PREAMBLE = texts Preamble for the question used to select from each set of alternatives
CHOICE = texts Alternative chosen from each set
NCHOICE = scalars Numbers of the chosen alternatives (0 if exit has been chosen instead)


The QUESTION procedure provides a convenient way of getting the user to choose a response from a short list. However, the size constraints of the standard computer screen mean that this does not work effectively for lists of more than about 16 items. QLIST overcomes this limitation by repeated calls of QUESTION. Each call displays 16 choices, together with the option of exiting without making a selection or, after all the choices have been displayed, of repeating the list.

Option: HELP.



QLIST makes repeated use of the QUESTION procedure until a response is obtained.

See also

Directive: QDIALOG.


Commands for: Program control, Calculations and manipulation.


CAPTION     'QLIST example',\
            'Evaluate various functions of the numbers 1-9.';\
QLIST    !t('print 2!','print square root of 2','print log (base 10) of 2',\
            'print 3!','print square root of 3','print log (base 10) of 3',\
            'print 4!','print square root of 4','print log (base 10) of 4',\
            'print 5!','print square root of 5','print log (base 10) of 5',\
            'print 6!','print square root of 6','print log (base 10) of 6',\
            'print 7!','print square root of 7','print log (base 10) of 7',\
            'print 8!','print square root of 8','print log (base 10) of 8',\
            'print 9!','print square root of 9','print log (base 10) of 9');\
            PREAMBLE='Please select an action?'; NCHOICE=nchoice
CALCULATE   number = INTEGER((nchoice + 5) / 3)
&           action = (MOD(nchoice - 1; 3) + 1) * (number > 1)
IF action == 1
  CALCULATE fact = FACTORIAL(number)
  PRINT     [IPRINT=*] number,'! is',fact; FIELD=2,4,8; SKIP=1,0,1;\
            DECIMALS=0,*,0; JUSTIFICATION=right,left,left
ELSIF action == 2
  CALCULATE sqrt = SQRT(number)
  PRINT     [IPRINT=*] 'Square root of',number,'is',sqrt; FIELD=14,2,2,8;\
            DECIMALS=*,0,*,*; JUSTIFICATION=right,left,left,left
ELSIF action == 3
  CALCULATE log = LOG10(number)
  PRINT     [IPRINT=*] 'Log (base 10) of',number,'is',log; FIELD=16,2,2,8;\
            DECIMALS=*,0,*,*; JUSTIFICATION=right,left,left,left
  PRINT     'No action selected.'
Updated on March 6, 2019

Was this article helpful?