Last updated by Roedy Green ©1985-1999 Canadian Mind Products.
( Figure 1 Abundance ) ( This program queries your motives for joining a health club. ) ( It demonstrates the use of Jaunting back in time. ) ( Anything in parentheses is a comment ) ( Note : the space after the " is intentional! ). <<<DEFINE " MFB" CHOICE Sexual-Preference ME ( Must Enter ) " M=prefer Males F=prefer Females B=prefer Both" EXPLAIN ( Declare a 1-byte variable that can have only the ) ( values M F or B ) 0 100 SMALL %-For-Health " What % of your reason for joining the club was to improve your health" EXPLAIN ( declare a 1-byte numeric variable ) ( Abundance transparently enforces the ) ( limits 0..100 ) 0 100 SMALL %-For-The-Males " What % of your reason for joining was to meet handsome males?" EXPLAIN 0 100 SMALL %-For-The-Females " What % of your reason for joining was to meet beautiful females?" EXPLAIN DEFINE>>> <<< VALIDATE-Percentages ( a procedure to validate all three percentages. ) CULPRIT Sexual-Preference ( Hint to compiler that misunderstanding the sexual preference ) ( question is likely the culprit if any subsequent MUST fails.) FROM %-For-Health %-For-The-Males + %-For-The-Females + ( postfix addition leaves the sum on the stack ) 100 = ( postfix comparison operator leaves True if the sum=100 ) " Percentages must add up to 100" MUST ( If MUST sees a false it jaunts back in time ) ( to where the culprit Sexual-Preference was keyed ) ( in the routine HEALTH-Club, [not to the CULPRIT statement] ) ( and issues the error message, otherwise it does nothing. ) ( The end user can go still further back in time than we ) ( take him, by hitting the Up arrow key. If we take him back ) ( too far, he can come forward in time by hitting the Down ) ( arrow key. ) >>> <<< HEALTH-Club ( The mainline procedure. ) ( At any point the end user can hit the Up-Arrow key and ) ( run the program back in time to the previous question. He ) ( can then answer differently.) ( Depending on how the end user answers the sexual ) ( preference question, he is asked different percentages ) KEYIN %-For-Health ( Abundance generates a prompt using the variable name ) ( %-For-Health, the EXPLAIN string " What % of your ) ( reason for joining the club was to improve your ) ( health", and the limits 0..100. It invokes a mini word ) ( processor to help the user enter the number. The ) ( number automatically stays right justified as it is ) ( entered. All conceivable validations are performed. ) ASK Sexual-Preference ( Similarly Abundance prompts for one of the letters ) ( M F or B leaving the result on the stack ) CASE ( examine character on the data stack ) _ M OF ( prefers males ) KEYIN %-For-The-Males CLEAR %-For-The-Females ENDOF _ F OF ( prefers females ) KEYIN %-For-The-Females CLEAR %-For-The-Males ENDOF _ B OF ( prefers both ) KEYIN %-For-The-Males %-For-The-Females ENDOF ENDCASE VALIDATE-Percentages ( invoke cross-field verification ) >>>
![]() |
![]() |
![]() | |
![]() |
Canadian Mind Products | You can get an updated copy of this page from http://mindprod.com/jglossa.html | The Mining Company's
Focus on Java Best of the Net Award |