Jump to content

_StringBetween if text consists symbol then do another thing


Recommended Posts

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
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.

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
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.

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

    No registered users viewing this page.

×
×
  • Create New...