Top Navigational Bar

Macros - Using A Logical AND And OR
DocumentID: 651987
Revision Date: 29-Feb-96 8:29:12 PM

The information in this document applies to:
WordPerfect® 5.1 for DOS

Problem

Symptoms: The customer needs the ability to use a logical AND and OR in macros, specifically in the IF and WHILE statements. For example: {IF}{VARIABLE}1~=5 && {VARIABLE}2~=1 etc. (where && = Logical AND). The customer has found work arounds for most of the problems they have encountered, but they would like to see something permanent done about it in the program. Solutions: A Logical AND can be obtained with certain syntax logic. With the example above, turn it into: {IF}({VARIABLE}1~=5)&({VARIABLE}2~=1)~.
The logic here is, if variable one is 5 and variable two is equal to 1, then the statement would be taking the AND of -1 and -1 which is equal to -1 (because the statement would read {IF}(-1&-1)=-1~). Since -1 means True, the whole statement is true. True and True equals True. What the statement is saying is {IF}{VARIABLE}1~=5~ (that would return true "-1") and {IF}{VARIABLE}2~=1~ (that would return true "-1"). Then, take the AND of -1 and -1. The statement can be read as -1&-1=-1. Since -1 equals 1111111111111111, the AND is taking the AND of

-1 1111111111111111
-1 1111111111111111
= ________________
-1 1111111111111111

The example above is read as follows: look a the first column on the right and say, "Is 1 on the top equal to 1 AND is the one on the bottom equal to 1?" If it is, put a 1 on the very bottom for the answer. Continue this process with all the rest of the columns going right to left (total of 16 columns) until finished. The answer comes out to be 1111111111111111, which is true as stated before.

Lets say variable one equals 5 and variable two equals 10. Also, we want to use a logical OR for this example. We want the statement to be true if variable 1 is equal to 5 OR variable 2 is equal to 1. If we write the command this way:
{IF}({VARIABLE}1~=5)|({VARIABLE}2~=1)~.
This command would return true if variable one equals 5 OR variable two equals 1. The statement can be translated as: -1|0=-1? Since variable one equals 5, it returns true (-1) and since variable two equals 10, the statement would return false (0). Again, what is happening here is this:

-1 1111111111111111
0 0000000000000000
= ________________
-1 1111111111111111

This example is read as follows: (in the right most
column) "Is the top number a 1 OR the bottom number a 1?" This would be true because the top number is a 1. Since it is true, write a 1 on the answer line. What is mentioned in the manual and here, in this explanation, gives the customer a lot of flexibility in their expression logic, especially for macros.

Answer:

Details:


Product specifications, packaging, technical support and information (*Specifications*) refer to theUnited States retail English version only. Specifications for other versions may vary. All Specifications, claims, features, representations, and/or comparisons provided are correct to the best of our knowledge of the date of publication, but are subject to change without notice.OUR MAXIMUM AGGREGATE LIABILITY TO YOU AND THAT OF OUR DEALERS AND SUPPLIERS IS LIMITED. IT SHALL NOTEXCEED THE AMOUNT YOU PAID TO ACCESS THE INFORMATION. SEE LEGAL DISCLAIMER.