Sign in to follow this  
Followers 0
opapotamus

if loop simple question

5 posts in this topic

Howdy everyone!

I have what should hopefully be a very simple question for anyone to answer that is not a total noob like me. What I am trying to do is compare two variables via an IF statement and have the script function from there. Here is my verrrrry sloppy code:

WinActivate("Microsoft Excel - test_copy.xlsx")
$ka = InputBox("Question", "Please enter maximum allowable value for ka:", "", "")
For $i = 1 to 3 
    sleep(500)
    Send("^c")
    sleep(500)
    $value = ClipGet()
    sleep(500)
    MsgBox(0, "value is:", $value)
    MsgBox(0, "ka is:", $ka)
    sleep(500)
        if $value < $ka then ;PRRRRRRRRRRRRRRRRRRRRRRRRROOOOOOOOOOOOOOOOOOOOBLEMMMMMMMMMMMMM
        Send("{RIGHT 1}")
        send("{SCROLLLOCK off}")
        sleep(500)
        Send("+{RIGHT 2}")
        send("{SCROLLLOCK off}")
        sleep(500)
        Send("{DEL}")
        send("{SCROLLLOCK off}")
        sleep(500)
        Send("{DOWN 1}")
        send("{SCROLLLOCK off}")
        sleep(500)
        Send("{LEFT 1}")
        send("{SCROLLLOCK off}")
        sleep(500)
    else
        Send("{DOWN 1}")
        send("{SCROLLLOCK off}")
    EndIf
Next

The problem is where it tries to compare the two variables. If I put a numerical value where $ka is in the IF statement then the script works fine though. Any help would be greatly appreciated! :)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Read up on string-type versus number-type compare.

and

ClipGet() -> returns its data as string-type.

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

Read up on string-type versus number-type compare.

and

ClipGet() -> returns its data as string-type.

InputBox does as well. So if you want to compare the whole number comparison you could just do something like.

If Int($value) < Int($ka) Then

Share this post


Link to post
Share on other sites

InputBox does as well. So if you want to compare the whole number comparison you could just do something like.

If Int($value) < Int($ka) Then

Beautiful! Exactly what I needed to do, thank you so much! :)

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  
Followers 0