Jump to content

Recommended Posts

Posted (edited)

Trying to get a value, and see if it equals another value

$Life = StringSplit(_IEBodyReadText($oIE), @CR)
$Life2 = StringSplit($Life[3], ":")
$Life3 = StringSplit($Life2[2], "/")

$CheckLife = StringRegExp($Life3[1], $Life3[2], 0)
    
If $CheckLife = 1 Then
    MsgBox(0, "", "Good ! " & $Life3[1] & "/" & $Life3[2])
Else
    MsgBox(0, "", "Bad ! " & $Life3[1] & "/" & $Life3[2])
EndIf

Tried this too:

If StringRegExp($Life3[1], $Life3[2], 0) = 0 Then
    $Wait = 1
Else
    $Wait = 0
EndIf

Neither worked, always turns up as 0, I even made a message box to show the values, so I could confirm. Searched the help files and forums, any and all methods I came across didnt work :) Also saw that StringInStr doesn't work :P

Maybe it's because they are numbers, and need to be stored as text? I think I awnsered my own question :P

$Life4 = String($Life3[1])
    $Life5 = String($Life3[2])
    $result = StringCompare($Life4, $Life4)

    If $result = 0 Then
        MsgBox(0, "", "Woot")
    ElseIf $result < 0 Then
        MsgBox(0, "", "Boo!")
    Else
        MsgBox(0, "", "Huh?")
    EndIf

Tried converting the values I want to compare to strings, and then using StringCompare, but it always turns up with 'Huh?', so I don't think they are even getting compared :(

Help appreciated ;)

Edited by Shonnie
  • Moderators
Posted

If you don't know how to use regular expressions, you'll need to take a week or two and study them (plenty of tutorials on the net).

What you have is nothing more than a StringInStr() option with the RegExp functions you are using.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted (edited)

Is there a mighty simple way to compare 2 numbers?

I also tried == operands instead of = but to no avail ;)

Btw, I read the article on Wikipedia about regular expressions, but this is all working with strings, right?

The only reason I resorted to this was because I could not find any way to compare 2 numbers, or none that worked

Perhaps they just dont equal each other? I output to a messagebox, with periods infront and before the number, to make sure theres no trailing spaces or anything, and there isn't :P

Edited by Shonnie
  • Moderators
Posted (edited)

Is there a mighty simple way to compare 2 numbers?

I also tried == operands instead of = but to no avail :P

If Number($var) = Number($var2) Then Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...