Anonymous user
Decision tables: Difference between revisions
m
→{{header|REXX}}: changed/added comments and whitespace, changed indentations.
m (added whitespace before the TOC, added a Task (bold) header.) |
m (→{{header|REXX}}: changed/added comments and whitespace, changed indentations.) |
||
Line 1,101:
=={{header|REXX}}==
This REXX example shows how one version of a decision table could be implemented,
<br>There was additional support added to the code for:▼
* a ''no solution found'' message▼
* a ''don't care'' requirement (regarding the decision table)▼
* a method of specifying requirements and not needing recoding for future queries▼
* used a minimalistic way in expressing the decision table ▼
* extra prompting when there was a user reponse error▼
* handles superfluous blanks and some punctuation.▼
* displaying of a countdown so user knows length of interrogation▼
* visual fidelity aids for postmortem analysis (as in logs)▼
* a method of allowing the user to quit the interrogation▼
<lang rexx>/*REXX pgm demonstrates a decision table and possible corrective actions*/▼
Q.1 = 'Does the printer not print?'▼
Q.2 = 'Is there a red light flashing on the printer?'▼
Q.3 = 'Is the printer unrecognized by the software?'▼
Q.0 = 3▼
act.= /* Y = yes N = no not letter = don't care. */▼
/* ┌───────◄ answer to 1st question (in upper\lower\mixed case). */▼
▲::* a ''no solution found'' message
/* │┌──────◄ " " 2nd " " " " " " */▼
▲::* a ''don't care'' requirement (regarding the decision table)
/* ││┌─────◄ " " 3rd " " " " " " */▼
▲::* a method of specifying requirements and not needing recoding for future queries
/* │││ */▼
▲::* used a minimalistic way in expressing the decision table
/* ↓↓↓ */▼
act.1 = 'yny' ; pos.1 = 'Check the power cable.'▼
▲::* handles superfluous blanks and some punctuation.
act.2 = 'y.y' ; pos.2 = 'check the printer-computer cable.'▼
▲::* displaying of a countdown so user knows length of interrogation
act.3 = '..y' ; pos.3 = 'Ensure printer software is installed.'▼
▲::* visual fidelity aids for postmortem analysis (as in logs)
act.4 = '.y.' ; pos.4 = 'Check/replace ink.'▼
▲::* a method of allowing the user to quit (opt-out of) the interrogation
act.5 = 'y.n' ; pos.5 = 'Check for paper jam.'▼
▲<lang rexx>/*REXX
▲Q.=; Q.1 = 'Does the printer not print?'
▲ Q.2 = 'Is there a red light flashing on the printer?'
▲ Q.3 = 'Is the printer unrecognized by the software?'
▲ Q.0 = 3
do
possible=0 /*we'll be counting possible solutions.*/
do k=1 while action.k\==''
do j=1; d=substr(action.k, j, 1); upper d
jm=j//Q.0; if jm==0 then jm=Q.0
if d==' ' then leave
if \datatype(d, 'U')
if d\==ans.jm then iterate k
if j==Q then leave
end /*j*/
say pos.k /*this could be a possible
possible=possible+1 /*count
end /*k*/
if possible==0 then say 'No solutions given for the information supplied.'
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
asker: arg ?; oops=0; Qprefix=copies('─', 9) '(question' ? "of" Q.0') '
howTo = '(You can answer with a Yes or No [or Quit])'
do forever
if oops then do; say;
say Qprefix Q.?; parse pull x /*ask
x=strip(space(x),,'.');
if words(x)==0 then iterate /*
if abbrev('QUIT',u,1) then exit /*
if (abbrev('YES',u)
say 'invalid response: ' x; oops=1
end /*forever*/</lang>
'''output''' (a screen scraping using a DOS prompt window for the possible responses)
DECISION.REX is the REXX program that produced this output.
<pre style="height:50ex
D:\►rexx decision
|