Mon Aug 25, 2014 6:47 pm
I have seen some misleading results from logic in the dude so you will have to verify every single step in the logic.
Note "negative 1" (-1) is logically true so you might need to take extra steps to deal with it. Since the execute function returns -1 if an error occurs.
Is the function actually getting called and what result is being sent to your probe? In the function you can add an if to get better detail of what is going on.
Here is how I would modify the function for testing "if the result is two, return two, otherwise return false".
if(array_element(execute("cscript.exe",concatenate("//NoLogo C:\dudescr\BatteryStatus.vbs ",User_Pass()),"C:\WINDOWS\system32\"),1)=2, 2, "False")
This way you can determine if the function is working or the result is being "incorrectly" evaluated as true in the error line of the probe.
In the probe line make sure Battery_Status is not False.
if(Battery_Status()<>"False",if(Battery_Status()=2, "", "Battery Power!!!"), "False battery status")
Since we deliberately sent "2" from the function, if it returned 2, then if you get anything else you know the function is not working correctly or the device is unreachable.
Once the testing is done...
If the logic is correct you could then execute the script "if" the script executes (not the greatest but it works fine).
if(array_element(execute("cscript.exe",concatenate("//NoLogo C:\dudescr\BatteryStatus.vbs ",User_Pass()),"C:\WINDOWS\system32\"),1), array_element(execute("cscript.exe",concatenate("//NoLogo C:\dudescr\BatteryStatus.vbs ",User_Pass()),"C:\WINDOWS\system32\"),1), "False")
OR
If the logic is correct and you want to handle negative 1 you could then execute the script "if" the script executes and is not -1 (still not the greatest but it should work fine).
if(array_element(execute("cscript.exe",concatenate("//NoLogo C:\dudescr\BatteryStatus.vbs ",User_Pass()),"C:\WINDOWS\system32\"),1)<>-1, array_element(execute("cscript.exe",concatenate("//NoLogo C:\dudescr\BatteryStatus.vbs ",User_Pass()),"C:\WINDOWS\system32\"),1), "False")
OR
If the logic is correct and you want to handle negative 1 you could add 1 to your result (another; it should work fine).
if(array_element(execute("cscript.exe",concatenate("//NoLogo C:\dudescr\BatteryStatus.vbs ",User_Pass()),"C:\WINDOWS\system32\"),1)<>+1, array_element(execute("cscript.exe",concatenate("//NoLogo C:\dudescr\BatteryStatus.vbs ",User_Pass()),"C:\WINDOWS\system32\"),1), "False")
Then your probe line could be
if(Battery_Status()<>"False",if(Battery_Status()>2, "", "Battery Power!!!"), "False battery status")
Note: In my own testing of functions the return values are not consistently easy to evaluate in the probe error line.
For example if(execute,2,0) works better than if(execute,2,"unknown") With the latter "unknown" would not give correct logic when used in a probe where "0" would BUT "False" works fine, YMMV.
ALSO 4.3 requires double backslash for execute c:\\test.exe
HTH
Lebowski
edit - typo, clarity...