Anonymous user
Decision tables: Difference between revisions
→{{header|REXX}}: added/changed whitespace and comments, elided deadcode, added highlighting to the output, added a template for the output section.
(→{{header|REXX}}: added/changed whitespace and comments, elided deadcode, added highlighting to the output, added a template for the output section.) |
|||
Line 1,758:
::* a method of allowing the user to quit (opt-out of) the interrogation
<lang rexx>/*REXX program demonstrates a (query) decision table and possible corrective actions.*/
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▼
action.= /* Y=yes N=no if character isn't a letter = don't care.*/
Line 1,769 ⟶ 1,768:
/* │││ */
/* ↓↓↓ */
action.1 = 'yny' ; pos.1 =
action.2 = 'y.y' ; pos.2 =
action.3 = '..y' ; pos.3 =
action.4 = '.y.' ; pos.4 =
action.5 = 'y.n' ; pos.5 =
do i=1
end /*i*/; Q.0= i - 1 /*adjust Q.0 for the DO loop indexing. */
say /*display a blank line before questions*/
possible=
do k=1 while action.k\=='' /*filter the answers via decision table*/
do j=1; d= substr(action.k, j, 1); upper d
jm= j//Q.0;
if d==' ' then leave
if \datatype(d, 'U') then iterate
if d\==ans.jm then iterate k
end /*j*/
say pos.k /*this could be a possible solution. */
possible= possible +
end /*k*/
if possible==0 then say '
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
asker: arg ?; oops= 0;
howTo = '(You can answer with a Yes or No [or Quit])'
do forever
if oops then do; say; say right(howTo, 79); say; oops=
if
if
say 'invalid response: ' x; oops= 1
end /*forever*/</lang>
<pre style="height:50ex">
D:\►rexx decision
Line 1,819 ⟶ 1,820:
n
D:\►rexx decision
Line 1,829 ⟶ 1,830:
yes
═════════ Ensure printer software is installed.
D:\►rexx decision
Line 1,839 ⟶ 1,840:
n
═════════ Check/replace ink.
D:\►rexx decision
Line 1,849 ⟶ 1,850:
yes
═════════ Ensure printer software is installed.
═════════ Check/replace ink.
D:\►rexx decision
Line 1,860 ⟶ 1,861:
no
═════════ Check for paper jam.
D:\►rexx decision
Line 1,870 ⟶ 1,871:
y
═════════ Check the power cable.
═════════ check the printer-computer cable.
═════════ Ensure printer software is installed.
D:\►rexx decision
Line 1,882 ⟶ 1,883:
n
═════════ Check/replace ink.
═════════ Check for paper jam.
D:\►rexx decision
Line 1,893 ⟶ 1,894:
y
═════════ check the printer-computer cable.
═════════ Ensure printer software is installed.
═════════ Check/replace ink.
D:\►
|