Jump to content
Macro Express Forums
ksk051182

Comparing 3 integers

Recommended Posts

I'm trying to compare 3 integers and pick the highest number.

The result is 20 instead of 29 when I run the script below.

What am I doing wrong?

 

Variable Set Integer %N1% to 20

Variable Set Integer %N2% to 29

Variable Set Integer %N3% to 15

 

If variable %N1% <= variable %N2%

Switch (N2)

End Switch

Variable Modify Integer : Copy %N2% to %N10%

End IF

 

If variable %N2% <= variable %N3%

Switch (N3)

End Switch

Variable Modify Integer : Copy %N3% to %N10%

End IF

 

If variable %N3% <= variable %N1%

Switch (N1)

End Switch

Variable Modify Integer : Copy %N1% to %N10%

End IF

 

Text Box Display: end

Share this post


Link to post
Share on other sites

Your last IF block gets executed every time, and since 15 is always less than 20 you will always end up with 20 in %N10%.


How about this:

Variable Modify Integer : Copy %N1% to %N10%

If variable %N2% > variable %N10%
Variable Modify Integer : Copy %N2% to %N10%
End IF

If variable %N3% > variable %N10%
Variable Modify Integer : Copy %N3% to %N10%
End IF


I'm not familiar with using SWITCH without CASE, so I don't know what you have in mind with the SWITCH statements.

Share this post


Link to post
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...