Difference between revisions of "Logical tests"
m |
m |
||
Line 17: | Line 17: | ||
N.B - this test uses 'lazy execution' meaning that if the logical condition is already determined by one of the sub-checks, the other sub-checks will not be performed. For example, we might want to check that c:\Program Files\Application exists and that c:\Program Files\Application\App.exe also exists. If a test finds that the directory doesn't exist, there's no way that the result of the logical 'and' can be true so it returns false immediately. In the above example (c:\fileA, c:\fileB), if c:\fileA exists no test is performed for c:\fileB. Likewise, if an 'at least' test requires four of eight tests to pass, the routine returns 'true' as soon as it finds a fourth true check whether or not it has attempted all of them. | N.B - this test uses 'lazy execution' meaning that if the logical condition is already determined by one of the sub-checks, the other sub-checks will not be performed. For example, we might want to check that c:\Program Files\Application exists and that c:\Program Files\Application\App.exe also exists. If a test finds that the directory doesn't exist, there's no way that the result of the logical 'and' can be true so it returns false immediately. In the above example (c:\fileA, c:\fileB), if c:\fileA exists no test is performed for c:\fileB. Likewise, if an 'at least' test requires four of eight tests to pass, the routine returns 'true' as soon as it finds a fourth true check whether or not it has attempted all of them. | ||
+ | |||
+ | = Other examples = | ||
+ | |||
+ | Firefox can have a different entry in "Software Add/Remove": | ||
+ | * if version 2.0 was installed first, and then updated to 2.0.0.2, version shown will be still 2.0 | ||
+ | * if version 2.0.0.2 was installed first, version shown will be 2.0.0.2 | ||
+ | |||
+ | <check type="logical" condition="or"> | ||
+ | <check type="uninstall" condition="exists" path="Mozilla Firefox (2.0)"> | ||
+ | <check type="uninstall" condition="exists" path="Mozilla Firefox (2.0.0.2)"> | ||
+ | </check> | ||
+ | |||
[[category:Documentation]] | [[category:Documentation]] |
Revision as of 11:59, 2 March 2007
Logical tests feature (implemented in WPKG 0.9.6) allows nested checks:
<check type="logical" condition="or"> <check type="file" condition="exists" path="c:\fileA"/> <check type="file" condition="exists" path="c:\fileB"/> </check>
I.e. the outer check will return 'true' if either c:\fileA or c:\fileB exist. Nests within nests are acceptable.
New tests which have been added:
- not - returns the inverse of the nested check. Fails with an error if the number of nested checks is not one.
- and - returns the logical 'and' of all the nested checks. (See note below about lazy execution.)
- or - returns the logical 'or' of all the nested checks. (See note below about lazy execution.)
- atleast - returns true if at least value of the nested checks are true. (See note below about lazy execution.)
- atmost - returns true if no more than value of the nested checks are true. (See note below about lazy execution.)
N.B - this test uses 'lazy execution' meaning that if the logical condition is already determined by one of the sub-checks, the other sub-checks will not be performed. For example, we might want to check that c:\Program Files\Application exists and that c:\Program Files\Application\App.exe also exists. If a test finds that the directory doesn't exist, there's no way that the result of the logical 'and' can be true so it returns false immediately. In the above example (c:\fileA, c:\fileB), if c:\fileA exists no test is performed for c:\fileB. Likewise, if an 'at least' test requires four of eight tests to pass, the routine returns 'true' as soon as it finds a fourth true check whether or not it has attempted all of them.
Other examples
Firefox can have a different entry in "Software Add/Remove":
- if version 2.0 was installed first, and then updated to 2.0.0.2, version shown will be still 2.0
- if version 2.0.0.2 was installed first, version shown will be 2.0.0.2
<check type="logical" condition="or"> <check type="uninstall" condition="exists" path="Mozilla Firefox (2.0)"> <check type="uninstall" condition="exists" path="Mozilla Firefox (2.0.0.2)"> </check>