Jump to content
Sign in to follow this  
sirkerry

If Else statements - what am I doing wrong?

Recommended Posts

sirkerry

What am I doing wrong with the following If Else statment? My intent is for it to check to see if $NoRecs string exists in $sText and if it doesn't then do stuff, but the script just doesn't.

$sText = String(_IEBodyReadText ($oIE))
$NoRecs = StringInStr($sText, "No records found for this account.")
If $NoRecs <> 0 Then
     "do stuff"
Else
EndIf

Share this post


Link to post
Share on other sites
Pantera975

What am I doing wrong with the following If Else statment? My intent is for it to check to see if $NoRecs string exists in $sText and if it doesn't then do stuff, but the script just doesn't.

$sText = String(_IEBodyReadText ($oIE))
$NoRecs = StringInStr($sText, "No records found for this account.")
If $NoRecs <> 0 Then
     "do stuff"
Else
EndIf

I assume there is more code above this that you have defined $oIE. If that is true then try the following below. Sometimes the source that autoit gets is kinda funky.

Try this and see if its what you expect.

$sText = String(_IEBodyReadText ($oIE))
$NoRecs = StringInStr($sText, "No records found for this account.")
msgbox(-1,"",$sText)
msgbox(-1,"",$NoRecs)
If $NoRecs <> 0 Then
     "do stuff"
Else
EndIf

Share this post


Link to post
Share on other sites
TurionAltec

$sText = String(_IEBodyReadText ($oIE))
$NoRecs = StringInStr($sText, "No records found for this account.")
Msgbox(0,"NoRecs",$NoRecs)
If $NoRecs <> 0 Then
     "do stuff"
Else
EndIf

Share this post


Link to post
Share on other sites
sirkerry

I assume there is more code above this that you have defined $oIE. If that is true then try the following below. Sometimes the source that autoit gets is kinda funky.

Try this and see if its what you expect.

There is. I just didn't see the point of posting the 40 lines of code above the If Else statement since they're working fine. The MsgBox is returning what I'm expecting. The If statement just doesn't seem act on the <> 0 bit.

Edited by sirkerry

Share this post


Link to post
Share on other sites
sirkerry

Msgbox(0,"NoRecs",$NoRecs)

What does the Msgbox tell you?

It tells me 0.

Share this post


Link to post
Share on other sites
sirkerry

Thanks guys, but never mind. I figured out what I was doing. I had my logic reversed.

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.