Jump to content
Sign in to follow this  
Jzullo

If Clause Issue

Recommended Posts

Jzullo

Hello all, once again I come to request the great help of the individuals in this forum. :P

I'm trying to write a script that will copy the contents of a cell in Excel and store the contents in a variable. I will then use the contents of this variable to compare to a constant. The problem I'm having is that even when the statement is true, it goes to the else part of the If clause. What I have so far is below:

$iShpCnd = ClipGet()
MsgBox(0,$iShpCnd, $iShpCnd)
                If $iShpCnd = "02" then
        MsgBox(0,"First IF", $iShpCnd)
        WinActivate("XXXXXX")
        WinWaitActive("XXXXXX")
        MouseClick("left", 117, 337, 1)
        Send("02")
        Send("{Enter}")
    Else
        MsgBox(0,"Else", $iShpCnd)
        WinActivate("XXXXXX")
        WinWaitActive("XXXXXX")
        MouseClick("left", 117, 337, 1)
        Send("LD")
        Send("{Enter}")
    EndIf

The "02" is stored as text in Excel, that's why I put it between "" in AutoIT. I tried putting switching the comparison, but it still goes to Else nonetheless.

I really appreciate if anyone can shed a light on this.

Share this post


Link to post
Share on other sites
big_daddy

Even though you say it's stored as text in Excel your variable naming scheme $iShpCnd represents as integer. That doesn't affect the actual variable content, but it is confusing.

Try changing this...

If $iShpCnd = "02" then

Share this post


Link to post
Share on other sites
PsaltyDS

Even though you say it's stored as text in Excel your variable naming scheme $iShpCnd represents as integer. That doesn't affect the actual variable content, but it is confusing.

Try changing this...

If $iShpCnd = "02" thenoÝ÷ Ûú®¢×¢}ý·
+­Ø^æx3zº,jëh×6$iShpCnd = 02
If String($iShpCnd) = "02"  Then
    ConsoleWrite('Debug: $iShpCnd = "02"' & @LF)
Else
    ConsoleWrite('Debug: $iShpCnd <> "02"' & @LF)
EndIfoÝ÷ ÚéåzË2¢ä­®)àæjÛh«Ü©àz+m¡«­¢+Ù%MÑÉ¥¹ ÀÌØí¥M¡Á
¹¤ôÅÕ½ÐìÈÅÕ½ÐìÑ¡

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.