I am checking regkey value for installed app version. If the regkey does not not exist, then value 0 is displayed in a meter that uses MeasureTestReg output. I want to modify the output value to "Not Installed" if the regkey does not exist. After some testing I found that IfCondition does not check string value, so the below works only if the reg value is numeric, if it is a string, then "Not Installed" is incorrectly set. What is a better way of doing this? I have tried IfMatch=0 without success
VirtAlloc wrote: ↑January 19th, 2023, 6:10 am
I am checking regkey value for installed app version. If the regkey does not not exist, then value 0 is displayed in a meter that uses MeasureTestReg output. I want to modify the output value to "Not Installed" if the regkey does not exist. After some testing I found that IfCondition does not check string value, so the below works only if the reg value is numeric, if it is a string, then "Not Installed" is incorrectly set. What is a better way of doing this? I have tried IfMatch=0 without success
Try IfMatch=^$, obviously along with IfMatchAction=[!SetOption MeterTestAppValue Text "Not Installed"].
The ^$ expression mean that the string is empty. ^ represents the beginig, while $ is the end of the string. If the begining of the string is followed immediately by its end, the string is empty. In this case the IfMatchAction is executed, setting "Not installed" as Text of the [MeterTestAppValue] meter.
balala wrote: ↑January 19th, 2023, 10:36 am
Try IfMatch=^$, obviously along with IfMatchAction=[!SetOption MeterTestAppValue Text "Not Installed"].
The ^$ expression mean that the string is empty. ^ represents the beginig, while $ is the end of the string. If the begining of the string is followed immediately by its end, the string is empty. In this case the IfMatchAction is executed, setting "Not installed" as Text of the [MeterTestAppValue] meter.
Hey I tried this as follows, unfortunately it displays value 0 if the key does not exist
VirtAlloc wrote: ↑January 20th, 2023, 3:01 am
Hey I tried this as follows, unfortunately it displays value 0 if the key does not exist
(P.S.: You didn't specify the RegHKey value, so it is assuming HKEY_CURRENT_USER. Is that what you want?)
If the key is not found, the registry measure will return a default value, which is 0 (and the string "0"). Testing for an empty string does not work in this case. You need to test for zero (the number, using an IfCondition) or "0" (the string, using an IfMatch). My assumption is that your original problem is that you are looking at the wrong reg hive, not that your code isn't working.
SilverAzide wrote: ↑January 20th, 2023, 3:23 am
If the key is not found, the registry measure will return a default value, which is 0 (and the string "0"). Testing for an empty string does not work in this case. You need to test for zero (the number, using an IfCondition) or "0" (the string, using an IfMatch).
Didn't check this previously, however if you are right (and you are), there is no way to distinguish between the case in which the key doesn't exist and the case it exists, but is 0.