Decision tables: Difference between revisions

→‎{{header|REXX}}: added visual comments and removed two other comments, showed an alternative requirement format. -- ~~~~
m (→‎{{header|REXX}}: added a screen scraping for the possible responses. -- ~~~~)
(→‎{{header|REXX}}: added visual comments and removed two other comments, showed an alternative requirement format. -- ~~~~)
Line 743:
<lang rexx>/*REXX pgm demonstrates a decision table and possible corrective actions*/
/*REXX pgm demonstrates a decision table and possible corrective actions*/
/*If this is part of a holistic solution, then the first question */
/*that should be asked: Are you having a problem with the printer?*/
ask.=
ask.1='Does the printer not print?'
Line 754 ⟶ 752:
set=set-1 /*adjust SET (number of ? asked)*/
 
act.= /* Y = yes N = no not letter = don't care. */
act.1 = 'y n y' ; pos.1 = 'Check the power cable.'
act.2 = 'y . y' ; pos.2 = 'check the printer-computer cable.'
act.3 = '. . y' ; pos.3 = 'Ensure printer software is installed.'
act.4 = '. y .' ; pos.4 = 'Check/replace ink.'
act.5 = 'y . n' ; pos.5 = 'Check for paper jam.'
 
/* ┌───────◄ answer to 1st question. */
do i=1 for set
/* │┌──────◄ answer to 2nd question. */
call asker i
/* ││┌─────◄ answer to 3rd question. */
/* │││ */
/* ↓↓↓ */
act.1 = 'y n yyny' ; pos.1 = 'Check the power cable.'
act.2 = 'y . y' ; pos.2 = 'check the printer-computer cable.'
act.3 = '. . y' ; pos.3 = 'Ensure printer software is installed.'
act.4 = '. y .' ; pos.4 = 'Check/replace ink.'
act.5 = 'y . n' ; pos.5 = 'Check for paper jam.'
/* act.2 could be also be set to: ynyYNY (lower/upper/mixed case).*/
 
do i=1 for set /*get responses from the prompts.*/
call asker i /*display question, get response.*/
end /*i*/
say
possible=0 /*we'll be counting possible sols*/
possible=0
 
do k=1 while act.k\=='' /*filter answers via decision tab*/
do j=1; d=wordsubstr(act.k,j,1); upper d
jm=j//set; if jm==0 then jm=set
if d=='' ' then leave
if \datatype(d,'U') then iterate
if d\==ans.jm then iterate k
if j==set then leave
end /*j*/
say pos.k /*this could be a possible sol. */
say pos.k
possible=possible+1 /*count num of possible solutions*/
end /*k*/