## Recommended Posts

hey

i try to make a script thats read from one point to another and put the text in other window

like:

<hello>

i want that all the text from the character < to the character > will display"hello"

or

<hellobye> will display "hellobye"

any idea???

tal

##### Share on other sites

Hi

A file? A web Page?

Be more specific.

Cheers

Old Scriptology

Visual Ping 1.8 - Mass Ping Program with export to txt delimited.

Desktop 2 RGB and YMCK - Pick a color in the desktop and get the RGB and YMCK code.

Desktop 2 RGB - Pick a color in the desktop and get the RGB code.

ShootIT 1.0 - Screen Capture full and partial screen

[font="'Arial Black';"]Remember Remember The Fifth of November.[/font]

##### Share on other sites

I want it to do so

read a text file exp: untitled.txt

find the start point , a character that I decide foe example this one - "<"

and to copy all the text after this point , until he gets the End character ">"

Take all the text he read and copy them to other text file

##### Share on other sites

Clarify what is in your text file a bit.

Is it always like this?

blah blah blah blah

blah blah <this is what I want> blah blah

blah blah blah blah

Or is it sometimes like this?

blah blah blah blah

blah blah <this is

what I want> blah blah

blah blah blah blah

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

##### Share on other sites

the first one

blah blah blah blah

blah blah <this is what I want> blah blah

blah blah blah blah

yes

thanks

##### Share on other sites

In making this little example, I found that it would work for either case.

This example assumes that you only care about the first time you see < and > in the file... and that < precedes >

$fullpath1 = @ScriptDir & "\text.txt"$file1 = FileOpen($fullpath1, 0) ; Check if file opened for reading OK If$file1 = -1 Then
MsgBox(0, "Error", "Unable to open file1.")
Exit
EndIf

$filetext = FileRead($file1)
$startpoint = StringInStr($filetext, "<")
$endpoint = StringInStr($filetext, ">")
$count =$endpoint - $startpoint$text = StringMid($filetext,$startpoint + 1, $count - 1) MsgBox(4096, "",$text)

FileClose($file1) Edited by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] #### Share this post ##### Link to post ##### Share on other sites hey thanks it realy works but one more thing if it will be like this blah blah blah blah blah blah [<this is what I want> blah blah <this is what I want> blah blah blah blah blah blah <this is what I want>blah blah blah blah so i need it to take all the text between "<" ">" from all my text #### Share this post ##### Link to post ##### Share on other sites That would take a different approach.... let me see.... [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] #### Share this post ##### Link to post ##### Share on other sites How about this: ; Adjust this to point to your file$fullpath1 = @ScriptDir & "\text.txt"

$file1 = FileOpen($fullpath1, 0)

; Check if file opened for reading OK
If $file1 = -1 Then MsgBox(0, "Error", "Unable to open " &$fullpath1)
Exit
EndIf
; Make a string out of your file
$filetext = FileRead($file1)

FileClose($file1) ; Assign some variables for later use$flag = 0 ; This will be tested to decide whether or not to save the info
$text = "" ; This ensures that you have a clean starting point for your output ; loop through the string you made out of your file For$x = 1 To StringLen($filetext) ; Assign a variable to hold the current character in your string$char = StringMid($filetext,$x, 1)
If $char = "<" Then$flag = 1
If $char = ">" Then$flag = 0
$text =$text & @CRLF
EndIf
If $flag = 1 And$char <> "<" Then $text =$text & $char Next ; Display results MsgBox(4096, "",$text)

It works well with data formatted like so:

blah blah blah blah

blah blah [<this is what I want> blah blah <this is also what I want>

blah blah blah blah

blah blah <this is another thing I want>blah blah blah blah

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

##### Share on other sites

Or this:

#include <String.au3>
#include <array.au3>
$aMatches = _StringBetween( FileRead(@ScriptDir & "\text.txt") '<', '>') _ArrayDisplay($aMatches, 'All strings between < and >')

Edited by lod3n

[font="Fixedsys"][list][/list][/font]

##### Share on other sites

SpookMeister you are the master

thank you very much

it works perfectly

tal

##### Share on other sites

hey all

i have one more problem

now i want the same one but the start point should be a word and not a character

for example:

Hello to all this is my first script > bla bla bla bla bla bla

bla bla Hello abcdefg > bla bla bla

la bla bla hello la bla bla> la bla bla

la bla blala bla bla

the start point will be the word "hello" and the end point will be ">"

and i want it to put all the text between in a mesege box

thanks

tal

##### Share on other sites

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

##### Share on other sites

ye

i read this but i don't know what are those commands : _StringBetween , _ArrayDisplay

i didn't found those in the help file

##### Share on other sites

ye

i read this but i don't know what are those commands : _StringBetween , _ArrayDisplay

i didn't found those in the help file

You don't?!

What version of AutoIt are you running?

Try this:

MsgBox(64, "AutoIt", "Version: " & @AutoItVersion)

The current production version is 3.2.2.0, and the Beta I have is 3.2.3.6.

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

##### Share on other sites

this is my version

3.2.2.0

##### Share on other sites

this is my version

3.2.2.0

The beta version of AutoIt usually is a lot better then the release. It's the beta version that everyone on the forums is using.

##### Share on other sites

The beta version of AutoIt usually is a lot better then the release. It's the beta version that everyone on the forums is using.

##### Share on other sites

Or this:

#include <String.au3>
#include <array.au3>
$aMatches = _StringBetween( FileRead(@ScriptDir & "\text.txt") '<', '>') _ArrayDisplay($aMatches, 'All strings between < and >')
well i try this script with my new beta version :

#include <String.au3>

#include <array.au3>

$aMatches = _StringBetween( FileRead(@ScriptDir & "\text.txt") '<', '>') _ArrayDisplay($aMatches, 'All strings between < and >')

and it didn't work for me

how can i display the results?

##### Share on other sites

\$aMatches = _StringBetween( FileRead(@ScriptDir & "\text.txt"),  '<', '>')

...and _StringBetween() works just as well in the Prod version as it does in Beta!

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...