'Case' logic is a more complex extension of the If/Then/Else logic discussed earlier.  The term 'Case' derives from the sentence "In CASE a certain value(s) is (are) THIS, then do this"

   Case logic is especially useful for comparing multiple values, multiple combinations of values, and for determining values in a cascading fashion.

If/Then/Else statements contain  basically two result sections: the True part and the False part. It is 'linear' in structure, reading from left to right, "If this value is X, then do this, else do this.

'Case' logic allows many result sections. It is 'stacked' in structure, and reads from top to bottom. Example (read the commas as "then"):

Case
   Combination 1, A action
   Combination 2, B action
   Combination 3, C action
   etc.

'Combination' above refers to the choices made in a preceding <<*AskOptions*>> display. The combinations refer to the positions of the selections made. (Caveats: If the display was from an <<*AskOptions(radio)*...>> call, only one position, not combinations of positions, will be 'analyzed'. Ditto If the display was from an <<*AskOptional*. . .>> call.)

When multiple values are involved, multiple considerations must be handled. Here's how we do it.

The answer combination is always converted to a positional number. So, if five items are in the list of choices, and the user selects the second and fifth item, Pathagoras will 'see' the answer numerically as 2 and 5.

If all the choices must be present in order to trigger the case event (but others can be as well), just type the qualifying choices, separating multiple choices with commas.

If only the exact choices listed must be present to trigger the case event (and none others), enclose the choices within curly braces. (The choices themselves must still be separated by commas.)

If any one of the listed choices will trigger the case event, separate the choices with '/OR'.

   When the first true value is reached, the line is processed and the routine ends.

   The Case list can be endless.

   Below is an example that demonstrates how the initial selection of items (in this example, salad fixings) can lead to a cascading of subsequent selections including the salad name and the utensils needed to consume the salad.

   You can  copy and paste this example into a document and process it. Pathagoras will ask you the first question dealing with the salad's "ingredients". If the user selects a predesignated combination of ingredients, Pathagoras will automatically return the common name of the salad and the utensil commonly used to consume it. Otherwise, the AskOptions questions (the final entry in the Case list) are presented.

<<*AskOptions*!Ingredients!Celery sticks/Julienne Carrot Strips/Raisins/Apples/Bananas/Cream Cheese/Peanut Butter/Crackers*>>

<<*Case*
!Ingredients!= “1,6”,!Salad!=“1”
!Ingredients!= “2,3”,!Salad!=“2”
!Ingredients!= “1,2”,!Salad!=“3”
!Ingredients!= “3,4,5”,!Salad!=“4”
<<*AskOptions*!Salad!Stuffed Celery/Carrot and Raisin Salad/Sliced Veggies/Fruit Salad/Unappetizing mismash*>>
>>

<<*Case*
!Salad!= “1”,!Utensils!=“4”
!Salad!= “2”,!Utensils!=“2”
!Salad!= “3”,!Utensils!=“4”
!Salad!= “4”,!Utensils!=“4”
>>

 
(The top part of this document is the 'Ask Table'. The below is the 'actual' document.

Below are six ‘primary ingredients’ for making a side dish of some sorts.

 

INGREDIENTS:
 

<<*Options*!Ingredients!*Celery sticks, / Julienne Carrot Strips, /Raisins, /Apples, /Bananas, /Cream Cheese/Peanut Butter/Crackers>>

 

Objective:

We want Pathagoras to select the specific salad (below) if a known combination is selected from among the ingredients above. So, if a pre-determined combination of ingredients is selected, the proper return will be made. Otherwise, Pathagoras will present a question allowing you to manually select the answer. Then, once the kind of appetizer is determined, Pathagoras will determine (or provide a list for you to select) the utensil to be used to consume the appetizer.

 

The type of SALAD made from the above ingredients is:
 

<<*Options*!Salad!*Stuffed Celery/Carrot and Raisin Salad/Sliced Veggies/Fruit Salad/Unappetizing mismash>>

 

For the above side dish, we will need the following UTENSILS:
 

<<*Options*!Utensils!*Knife and Fingers/Fork/Spoon/Fingers>>

 

 

   A reminder: the answers that Pathagoras is analyzing in the Case list are positional. "1,6" refer to the first and sixth positions in the ingredients list (celery and cream cheese). For <<*AskOptional*>> commands, a 'yes' answer is assigned a '1' value, a 'no' answer a '0' value.

  Creating a Case Logic List.

1.Display the Logic Wizard (previous section).

2.Make all selections as before, but check the box in the middle of the screen that reads "Create Case Logic Block"

3.After you have created your first Case Logic item, click the Transfer button. The initial formula will be copied into the clipboard and the screen will close. Navigate to the position in the Ask Table where you want the Case Block to appear and click Paste (Ctrl-V).

4.Note: You can only create the structure for the case block, which will consist of the Case title, one (and only one) Case entry PLUS the Ask associated with the primary element selected at the right (this Ask must be the last entry, as it is the 'default item' if no prior Cases are true when document processing occurs).

5.You can (and should) add as many additional 'tests' as you wish, following the pattern shown in the transferred Case Logic Block.

6.If all selections must be met, enclose the selections within {curly braces}. Otherwise, the default 'one or more of the choices must match' will apply.'

   Here is another, perhaps more 'practical' example. The clauses <<wil100>>, etc are clauses that shipped with the program. Therefore, you can copy and paste this example into a document and actually process it.

 

Objective:

    To automatically select specific clauses based on choices made by the user from an Options or AskOptions block.

 

   In the below example, a variety of family structure elements are presented. These choices are presented to the user once document processing starts. Once the user makes selection, the choices are evaluated by subsequent ‘Case’ blocks. (That is if any are provided. Case is optional. Pathagoras can evaluate the AskOptions answer just fine for other Options blocks further in the document Case is used for its ability to set a second or third value that will be used elsewhere.. This is called 'conditional branching'.)

 

   If a pre-determined combination of choices has been made (all selections based simple on position—1,2,3 etc in the Options list), the designated return of a clause will be made. If a pre-determined combination was not selected, the ‘default’ value provided in the ‘Case’ block will be chosen. (The default value is always the last choice provided. That is because once a line in the case block evaluates 'true', the Case block is exited. If the last line is reached, it is the only one left.  In the example below,  the last choice is the same as if “Married, w/Children” had been selected for !Family Structure! group and “No Minor Children” for the !Guardian!.group.)

 

   More explanations provided below.

==================================================

<<*AskOptions(radio)*!Sex of Client!Male/Female*>>

<<*AskOptions(case)*!Family Structure!(1)Married/(2)No Children/(3)Child/(4)Children/(5)Minor children*>>

<<*Case*

!Family Structure!= “1,2”,!Clauses!=“1”

!Family Structure!= “1,3”,!Clauses!=“2”

!Family Structure!= “1,4”,!Clauses!=“3”

!Family Structure!= “2”,!Clauses!=“4”

!Family Structure!= “3”,!Clauses!=“5”

!Family Structure!= “4”,!Clauses!=“6”

!Clauses!= “3”

>>

<<*Case*

!Family Structure!= “5”,!Guardian!=“True”

!Guardian!="False"

>>

==================================================

The above text  is the ‘administrative section’ of the document. It comprises the 'Ask Table' and the Case processing section. The Ask Table asks the questions when the document is called up via the Document Assembly screen or a DropDown List (or if you ‘fake’ processing via Alt-P. The below is the 'actual' document.

 

If you want to suppress the "and" "or" "space" "none" connector options that typically appear below any AskOptions control, just append '(case)' after "AskOptions".

 

Here we add another element to the example, and that is the ability of Pathagoras to call in clauses set out in double angle brackets. All clauses to be inserted in the example below are actual clauses. They are part of the DemoData clauses (Wills clauses) that shipped as part of the Pathagoras installation package. Of course, you can substitute real text in lieu of  'wil100'. etc.

 

Here, the ‘Preamble’ (wil100) will be inserted regardless of family structure (no ‘if’ or ‘Options’ or ‘Optional’  assigned to it.

==================================================

<<wil100>>

==================================================

Here, depending upon the selections made regarding family structure, one of the following clauses will be inserted. The 'Family Structure' choice made at the outset set a ‘Clauses’ value. That value is used as a 'position' in the below list of Clauses.

==================================================

<<*Options*!Clauses!*<<wil110(m,c0)>>/<<wil110(m,c1)>>/<<wil110(m,c2+)>>/<<wil110(s,c0)>>/<<wil110(s,c1)>>/<<wil110(s,c2+)>>>>

 

==================================================

Now, throw in a few more standard clauses:

==================================================

 

<<wil120>>

<<wil130>>

==================================================

If ‘minor child’ was selected in the Family Structure ask, the Guardian clause will be inserted. Otherwise it will be omitted. (This is controlled by the 5th element of the family structure questions as analyzed by the second  “Case” block  above.)

==================================================

 

<<*Optional*!Guardian!*I hereby name [Guardian] to be the guardian of my minor children.>>

==================================================

Now, finish up with a few standard closing elements and the signature block based on the answer to the opening Ask prompt 'Sex of Client'.

==================================================

 

<<wil180>>

<<wil190>>

<<*Options*!Sex of client!*<<wil300m>>/<<wil300f>>>>

Created with Help & Manual 7 and styled with Premium Pack Version 2.70 © by EC Software