Problem with IF and...
 
Notifications
Clear all

We had a major storm through here recently and we suffered damage to the house roof and ceilings. I just received the quote to repair. I’m hoping that a small fraction of the 80,000 odd people that download SDIO and/or Desktop Info every month won’t mind chipping in a few dollars to help out. Click on the big blue button at the bottom of the page to help us keep a roof over our heads, literally!

Guests have read-only access to our forums. If you wish to participate you will need to register. Be sure to activate your account from the email sent to you when you register.

Problem with IF and BUTTON

8 Posts
2 Users
3 Reactions
56 Views
(@renegade_pirate)
Active Member Registered
Joined: 1 week ago
Posts: 5
Topic starter  

Hi Glenn,

First of all, I love the new BEGIN-IF / END-IF option in v3.20 👍 

I've started reworking my INI file, and it's making my life so much easier already.

The one problem I do have though is the removal of CONTROL , and it's replacement with the BUTTON command. Going back many versions, I  always had a problem with BUTTON not working correctly with the IF statement, and got round it by using CONTROL instead.

I've tried using both IF and BEGIN-IF, but both have the same result. 

IF=value1:%RebootPendResult%,value2:True,comparator:eq
BUTTON=button-color:%Orange%,text:Warning:,display:Restart Pending,uri:control,args:/name Microsoft.WindowsUpdate
 
The button displays regardless of the IF result.

This is my BEGIN-IF :

BEGIN-IF=value1:%RebootPendResult%,value2:True,comparator:eq
     BUTTON=button-color:%Orange%,text:Warning:,display:Restart Pending,uri:control,args:/name Microsoft.WindowsUpdate
END-IF
 
I tested it by adding other TEXT and COMMENTs in the Begin-If block, and those worked as expected. If the value is not True, the TEXT does not display, though the Button does. For example:
 
BEGIN-IF=value1:%RebootPendResult%,value2:True,comparator:eq
     TEXT=color:%Orange%,text:Warning,display:Restart Pending
     BUTTON=button-color:%Orange%,text:Warning:,display:Restart Pending,uri:control,args:/name Microsoft.WindowsUpdate
END-IF
 
 
As I say, I had the same problem in earlier versions, but switched to the CONTROL command instead. Sadly for me, it seems CONTROL has now been removed.
 
As much as I'd love to move to v3.20 it's not usable for me if BUTTON doesn't respond to IF results.
 
I hope you can get this fixed soon, as I really want to make use of the BEGIN-IF command. It will really help me simplify my ini file.
 
Cheers,
Matt

   
Quote
Glenn
(@glenn)
Member Admin
Joined: 7 years ago
Posts: 1591
 

I tried the following:

SET RebootPendResult = True
IF=value1:%RebootPendResult%,value2:True,comparator:eq
BUTTON=button-color:%Orange%,text:Warning:,display:Restart Pending,uri:control,args:/name Microsoft.WindowsUpdate

Which worked fine. My suspicion is %RebootPendResult% does not have the value you think it does. Try enabling the display for the IF item and see what it's actually comparing after it's done replacing variable values:

SET RebootPendResult = True
IF=value1:%RebootPendResult%,value2:True,comparator:eq, hidden:0, display:%1 %2 %3 %4
BUTTON=button-color:%Orange%,text:Warning:,display:Restart Pending,uri:control,args:/name Microsoft.WindowsUpdate

%1 = result

%2 = value1

%3 = value2

%4 = comp


   
ReplyQuote
(@renegade_pirate)
Active Member Registered
Joined: 1 week ago
Posts: 5
Topic starter  

@glenn 

Yes, that code does work, but if I try setting the RebootPendResult to False, the button still appears.

If I try the following:

SET RebootPendResult = True
IF=value1:%RebootPendResult%,value2:True,comparator:eq, hidden:0, display:%1 %2 %3 %4
BUTTON=button-color:%Orange%,text:Warning:,display:Restart Pending,uri:control,args:/name Microsoft.WindowsUpdate

SET RebootPendResult = False
IF=value1:%RebootPendResult%,value2:True,comparator:eq, hidden:0, display:%1 %2 %3 %4
BUTTON=button-color:%Blue%,text:Warning:,display:Shouldnt be Restart Pending,uri:control,args:/name Microsoft.WindowsUpdate

I get one orange button, and one blue button.

The display %1 %2 %3 %4 for each results in 

True True True eq

False False True eq

I have a second page, and if I go to the second page and go back, both buttons disappear, and the results show as expected.

 

I've added screenshots to show the results with the two extra IF statements. The first is what happens as soon as DekstopInfo is launched, the second is what happens after I go to page two and back to page one, and is what I would expect it to look like. 

 


   
ReplyQuote
(@renegade_pirate)
Active Member Registered
Joined: 1 week ago
Posts: 5
Topic starter  

This is how it should look, and does look using an older version and the CONTROL command instead of the BUTTON command.


   
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 7 years ago
Posts: 1591
 

wrap it all in

BEGIN-ONLOAD=onload:2

...

END-ONLOAD


   
ReplyQuote
(@renegade_pirate)
Active Member Registered
Joined: 1 week ago
Posts: 5
Topic starter  

If I change the code slightly, to remove setting the RebootPendResult before the second IF, thi sshould result in the Blue button NOT displaying. Instead, I get the attached.

SET RebootPendResult = True

IF=value1:%RebootPendResult%,value2:True,comparator:eq, hidden:0, display:%1 %2 %3 %4
BUTTON=button-color:%Orange%,text:Warning:,display:Restart Pending,uri:control,args:/name Microsoft.WindowsUpdate

IF=value1:%RebootPendResult%,value2:False,comparator:eq, hidden:0, display:%1 %2 %3 %4
BUTTON=button-color:%Blue%,text:Warning:,display:Shouldnt be Restart Pending,uri:control,args:/name Microsoft.WindowsUpdate

 

 

 


   
ReplyQuote
(@renegade_pirate)
Active Member Registered
Joined: 1 week ago
Posts: 5
Topic starter  

Glenn my man ! You are a genius. Begin-onload/end-onload seems to have cured the problem.

Thank you !!


   
Glenn reacted
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 7 years ago
Posts: 1591

   
ReplyQuote
Glenn's Page