Jump to content

StringInStr


gbr
 Share

Recommended Posts

Hi All:

I am trying to automate a flashing procedure in target. I am sending commands via a console and taking logs in a text file. I am reading the text file and once I get the success message of the first command, I send the second command.

But its not working :)

Below is the code snippet of the function that checks for the success message.

Func FlashCheck()

sleep(60000)

$vValue2 = "SUCCESS: flashing finished!"

Do

$chars2 = FileReadLine($file)

$Search2 = StringInStr ( $chars2, $vValue2)

If @error = -1 Then ExitLoop

Until $Search2 > 0

Send("{ENTER}")

EndFunc

I am calling this function Flashcheck after the first command as below in the main program:

Send("1st command")

Send("{ENTER}")

$Search2 = 0

FlashCheck()

Send("{ENTER}")

Send("2nd Command")

Could you please let me know where is it going wrong?

Link to comment
Share on other sites

Hi ,

If I use the Msg Box.. then I see that all the lines are read from the log.

Func FlashCheck()

sleep(60000)

$vValue2 = "SUCCESS: flashing finished!"

Do

$chars2 = FileReadLine($file)

MsgBox(0, "Check", $chars2)

$Search2 = StringInStr ( $chars2, $vValue2)

If @error = -1 Then ExitLoop

Until $Search2 > 0

Send("{ENTER}")

EndFunc

If I keep on Clicking OK..once it matches the string to be searched in the line.. it sends the next command...

Link to comment
Share on other sites

gbr,

But its not working

is not a description of the problem... One thing that I would check just looking at these two functions is the scope of $Search2. It appears that you are counting on it retaining it's value from function to function... For further help post all of the code or a representative reproducer. Good Luck, kylomas Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Actually, in lieu of the OP replying I'm going to take a guess at the possible problem.

I'm imagining the code has been copy and pasted from somewhere and the StringInStr

func just thrown in after.

So Move your @error check for -1 to immediately after the call to FileReadLine.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
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
 Share

  • Recently Browsing   0 members

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