Logical Look-Ahead
You may use the operators Logical And (&&) and Logical Or (||) to create Boolean rule sets as part of an expert system application. In this type of application, you combine rules with nodes that prompt the user for input information.
See Logical And.
See Logical Or.
For example, the following set of node definitions create part of an expert system that determines if a patient has a cold.
Cold:= Runny Nose&&Slight Fever
Runny Nose:=askyesno("Does the patient have a runny nose?")
Slight Fever:=Temperature>=99&&Temperature<=102
Temperature:=asknumber("What is the patient's temperature?")
The first definition contains a rule that is true if the patient both has a runny nose and has a slight fever. The next definition is a rule that defines slight fever. The remaining two definitions present questions to the user to ask for a numeric input (asknumber) or ask for the response to a Yes/No question (askyesno).
See asknumber.
See askyesno.
Suppose these definitions are part of a larger medical diagnostic system. In addition, assume the user had previously answered the Temperature question and indicated the patient's temperature is 104. Then, when evaluating the node Cold, you would like the application to recognize that Cold can never be true, so do not ask if the patient has a runny nose. You can accomplish this using Logical Look-Ahead.
Logical Look-Ahead is a feature of DScript that controls how the Logical And and Logical Or operators behave. Specifically, this feature prevents applications from prompting the user for information that is not needed.
In evaluating a Boolean expression, DScript scans the entire logic tree to determine if there is any way to calculate a result without asking the user for input. If it is not possible to calculate a solution, DScript asks one question and then repeats the scan.
Logical Look-Ahead lets you build rule-based applications without worrying about the order in which questions are posed to the user. In addition, you do not have to worry about redundant logic. DScript only asks questions that are necessary.
See Boolean Operators.