Sign in to follow this  
Followers 0
socap

_StringBetween if text consists symbol then do another thing

9 posts in this topic




#3 ·  Posted (edited)

If $Text[$i] <> ">" Then

Send("any word")

EndIf

Thank you very much. I mean, if text is like "word word >word word" it shouldn't send "any word".

I can't even test it to know if it works that way.

#include <String.au3>
$Text = FileRead("test2.txt")
$Text = _StringBetween($Text, "NEXT", "NEXT")
For $i = 0 To UBound($Text) -1
Sleep(2000)
If $Text[$i] <> ">" Then
Send("any word")
EndIf
ClipPut($Text[$i])
Send("+{INSERT}")
Sleep (3000)
Next

Do you know what's wrong?

Edited by socap

Share this post


Link to post
Share on other sites

Hello socap,

first of all: read the helpfile. It helps me a lot :)

second: you can use StringInStr() function to see if a ">" string is in the text.


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hello socap,

first of all: read the helpfile. It helps me a lot :)

second: you can use StringInStr() function to see if a ">" string is in the text.

Thank you very much, I don't understand how exactly make "If Then" line. Can you help?

#include <String.au3>
$Text = FileRead("test2.txt")
$Text = _StringBetween($Text, "NEXT", "NEXT")
For $i = 0 To UBound($Text) -1
Sleep(2000)
If Stringinstr($Text[$i], ">") <> ">" Then
Send("any word")
EndIf
ClipPut($Text[$i])
Send("+{INSERT}")
Sleep (3000)
Next

Now it sends "any word" only if ">" is alone in text. Can you help that it send "any word" if ">" is anywhere in text?

Found the answer to this

If Stringinstr($Text[$i], ">") = @Error  Then

How can I exit the script if $Text[$i] doesn't contain anything please?

Edited by socap

Share this post


Link to post
Share on other sites

Hello socap,

The syntax of the IF statement is:

If ... Then

Else

EndIf

To exit the script just use the "Exit" statement.

And again: Please read the helpfile and/or the tutorials, you can find here in the forum (You may want to look for AutoIT 1-2-3)


Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]

Share this post


Link to post
Share on other sites

#include <String.au3>
$Text = FileRead("test2.txt")
$Text = _StringBetween($Text, "NEXT", "NEXT")
For $i = 0 To UBound($Text) -1
Sleep(2000)
If Stringinstr($Text[$i], ">") = @Error  Then
Send("any word")
EndIf

If Stringinstr($Text[$i], "") = "" Then Exit;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

ClipPut($Text[$i])
Send("+{INSERT}")
Sleep (3000)
Next

This was supposed to Exit if $Text[$i] doesn't contain anything. But it exits no matter what's inside. Help please.

Share this post


Link to post
Share on other sites

socap,

Can't test without your input file so this is just spitballing...

IF you want to test for blank array entries use

if stringlen($Text[$i]) = 0 then exit

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

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