Jump to content
Macro Express Forums

simple loop with "OR" doesn't work


Recommended Posts

Hello guys. I wrote a loop with OR but the condition is not true. Why ?

 

Variable Set String %T[1]% to "2013"
If Variable %T[1]% Does not Equal "2013"
OR
If Variable %T[1]% Does not Equal "2014"
MessageBox: Info
Else
MessageBox: Info
End If

Source code:

<VARIABLE SET STRING Option="\x00" Destination="%T[1]%" Value="2013" NoEmbeddedVars="FALSE"/>
<IF VARIABLE Variable="%T[1]%" Condition="\x01" Value="2013" IgnoreCase="FALSE"/>
<OR/>
<IF VARIABLE Variable="%T[1]%" Condition="\x01" Value="2014" IgnoreCase="FALSE"/>
<MESSAGEBOX Caption="Info" Message="Date is NOT 2013 or 2014" Icon="0"/>
<ELSE/>
<MESSAGEBOX Caption="Info" Message="Date is correct. Have a nice day." Icon="0"/>
<END IF/>

My hairs getting grey.

 

Look_Up

Link to comment
Share on other sites

Stan Jones from Macro Express Team answered me. It only works correct when i change "Does not Equal" to "Equal". Looks like it is a bug.

 

BUT....

I came to the solution, when I finished my macro.

"VARIABLE SET STRING" >> 2013 and 2014 are normally NOT string variable rather integer.

 

Macro Express can only make a correct comparison when the correct variable type is given.

 

Look_Up

Edited by Look_Up
Link to comment
Share on other sites

  • 2 weeks later...

Just saw this thread today. You had no need to look beyond Bob's answer of 19th November! Didn't you try it?

 

It's a common mistake. Your logic was flawed. ONE of those two conditions you specified was met: T1 was 2013, so it did not equal 2014. So you got the 'correct' message. It was just wrongly worded. :)

 

Nothing to do with variable type.

 

Also, are you sure you reported Stan's suggestion correctly? That obviously doesn't work either.

 

--
Terry, East Grinstead, UK

Link to comment
Share on other sites

  • 2 weeks later...

Change the OR to AND. You will be not unhappy. ;)

 

[...] I came to the solution, when I finished my macro.

"VARIABLE SET STRING" >> 2013 and 2014 are normally NOT string variable rather integer.

 

Macro Express can only make a correct comparison when the correct variable type is given. [...]

 

Hey Terry,

 

i want answer you. Yes, I have a problem to getting thru with Boolean logic. rberg giving the correct answer AND 2013/2014 aren't string variable. So i change my macro and everything went right.

 

Here is the answer from Stan:

 

 

 

Hi,

Variable Set String %T[1]% to "2013"

If Variable %T[1]% Does not Equal "2013"

OR

If Variable %T[1]% Does not Equal "2014"

MessageBox: Info

 

The way this is written only one of the two If Variables needs to be true in order for the first message box to display. Since T1 does not equal 2014, the first message appears.

I would suggest rewriting the macro to something similar to what is shown below. Also make sure to swap the message boxes.

Variable Set String %T[1]% to "2013"

If Variable %T[1]% Equals "2013"

OR

If Variable %T[1]% Equals "2014"

MessageBox: Info (Date is correct. Have a nice day.)

Else

MessageBox: Info (Date is NOT 2013 or 2014)

End If

The above should work the way you want. Please let me know if you have any questions.

Thanks,

Stan Jones

Insight Software Solutions, Inc.

 

 

 

Thanks to all the people who helped me !

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...