if statement ...what in the world could possibly be wrong

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

if statement ...what in the world could possibly be wrong

Post by SuitedAces » Fri Feb 22, 2008 6:51 pm

I have tried every conceivable way to get the WWC_RESULT to work in an if statement and all have failed.
This line ....WriteLn>C:\33.txt,result,%WWC_RESULT%
Write to the file.

As soon as I try this with an if statement it failed for either true or false.
What the hell ?

I tried
If>%WWC_RESULT% = true
If>WWC_RESULT = true
If>%WWC_RESULT% is true
If>WWC_RESULT is true
If>%WWC_RESULT% = false
If>WWC_RESULT = false
If>%WWC_RESULT% is false
If>WWC_RESULT is false
If>%WWC_RESULT% = true then
If>WWC_RESULT = true then
If>%WWC_RESULT% is true then
If>WWC_RESULT is true then
If>%WWC_RESULT% = false then
If>WWC_RESULT = false then
If>%WWC_RESULT% is false then
If>WWC_RESULT is false then

None of them worked

I tried this :
WriteLn>C:\33.txt,result,x
Instead of this:
WriteLn>C:\33.txt,result,%x%

No good, I can't get it to work

Code: Select all

Let>x=if wwcResult was true
Let>y=if wwcResult was false


WaitWindowChanged>10

WriteLn>C:\33.txt,result,%WWC_RESULT%
 
 If>%WWC_RESULT% = true then
 WriteLn>C:\33.txt,result,%x%
 Endif
 
 If>%WWC_RESULT% = false then
 WriteLn>C:\33.txt,result,%y%
 Endif
Last edited by SuitedAces on Fri Feb 22, 2008 7:29 pm, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Feb 22, 2008 7:08 pm

Unless you have the IGNORESPACES directive enabled, remove the spaces:

Code: Select all

Let>x=if wwcResult was true
Let>y=if wwcResult was false

WaitWindowChanged>10

WriteLn>C:\33.txt,result,%WWC_RESULT%
 
If>%WWC_RESULT%=TRUE
  WriteLn>C:\33.txt,result,%x%
Endif
 
If>%WWC_RESULT%=FALSE
  WriteLn>C:\33.txt,result,%y%
Endif
Also remove "then". Look at the help file topic for "If".

If you WANT spaces (perhaps you're used to real programming languages) then set IGNORESPACES to 1 and read the help file topic "Ignoring Spaces" under "Command Reference".

Also, WWC_RESULT returns FALSE or TRUE (Uppercase).
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Feb 22, 2008 7:13 pm

Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

SuitedAces
Pro Scripter
Posts: 50
Joined: Thu Feb 21, 2008 9:11 pm

Post by SuitedAces » Fri Feb 22, 2008 7:36 pm

Holy **** it was the upper case .
This is a different animal.

Most of the software I have worked with ignores case or corrects the case.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Feb 22, 2008 8:06 pm

Most of the software I have worked with ignores case or corrects the case.
In this case you're making a comparison. Personally, I don't want AAA to be equal to aaa. For a fairly comprehensive (but probably incomplete) look at case sensitivity in Macro Scheduler, look here.

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Fri Feb 22, 2008 11:16 pm

SuitedAces wrote:Most of the software I have worked with ignores case or corrects the case.
Just curious, what software corrects the case of variables?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sat Feb 23, 2008 9:34 am

SuitedAces wrote:Holy **** it was the upper case .
This is a different animal.

Most of the software I have worked with ignores case or corrects the case.
It was also the syntax. Here's the syntax for the If statement, taken from the docs:

Code: Select all

If>expression[,true_label_name[,false_label_name]]
       statements    
[ [Else
       else statements]
Endif ]
Examples:

Code: Select all

Let>a=5
//simple expression only
IF>a=5
   //do something
ELSE
   //do something else
ENDIF

//complex expression:
IF>{(%a% = 5) AND (%VarA% = "allen")}
  //do something
ELSE
  //do something else
ENDIF
Regarding case. Macro Scheduler is by design not a typed language, doesn't care about delimiters by default and strings and numbers can be interchanged. So TRUE and FALSE are actually strings. The help file for WaitWindowChanged says that WWC_RESULT returns TRUE or FALSE only.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Thu Nov 29, 2012 5:45 pm

I want to add to this channel even though it has been idle for a while...

I needed to verify that at least 1 checkbox was checked.
(I didn't use Radio Group for reasons I won't go into here.)

I spent way to much time figuring this out and want to share the knowledge of how to check mutiple True/False conditions in 1 If statement.

UpperCase/LowerCase is the issue because getting the state of the Checkboxes returns True/False, but the logic in the If statement requires TRUE/FALSE

Code: Select all

SRT>RotarySpecifyDirection
  GDP>Form1,cbNegativeDirection,Checked,IsNegChecked
  UpperCase>IsNegChecked,IsNegChecked

  GDP>Form1,cbPositiveDirection,Checked,IsPosChecked
  UpperCase>IsPosChecked,IsPosChecked

  GDP>Form1,cbShortestDirection,Checked,IsShortChecked
  UpperCase>IsShortChecked,IsShortChecked
  
  If>{(%IsNegChecked%=FALSE)and(%IsPosChecked%=FALSE)and(%IsShortChecked%=FALSE)}
    MDL>At least one of these 3 must be checked: Negative, Positive, Shortest
  Endif
END>RotarySpecifyDirection
Thanks,
Jerry

[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts