tal Posted April 23, 2007 Posted April 23, 2007 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??? please help me it's very impotent for me. tal
November Posted April 23, 2007 Posted April 23, 2007 Hi Read what and where? 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]
tal Posted April 23, 2007 Author Posted April 23, 2007 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
SpookMeister Posted April 23, 2007 Posted April 23, 2007 Clarify what is in your text file a bit.Is it always like this?blah blah blah blahblah blah <this is what I want> blah blahblah blah blah blahOr is it sometimes like this?blah blah blah blahblah blah <this is what I want> blah blahblah 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]
tal Posted April 23, 2007 Author Posted April 23, 2007 the first one blah blah blah blah blah blah <this is what I want> blah blah blah blah blah blah yes thanks
SpookMeister Posted April 23, 2007 Posted April 23, 2007 (edited) 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 April 23, 2007 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]
tal Posted April 23, 2007 Author Posted April 23, 2007 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
SpookMeister Posted April 23, 2007 Posted April 23, 2007 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]
SpookMeister Posted April 23, 2007 Posted April 23, 2007 (edited) How about this: ; Adjust this to point to your file $fullpath1 = @ScriptDir & "\text.txt" ; Open your file for reading $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) ; Close your file 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 April 23, 2007 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]
lod3n Posted April 23, 2007 Posted April 23, 2007 (edited) Or this:#include <String.au3> #include <array.au3> $aMatches = _StringBetween( FileRead(@ScriptDir & "\text.txt") '<', '>') _ArrayDisplay($aMatches, 'All strings between < and >') Edited April 23, 2007 by lod3n [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
tal Posted April 23, 2007 Author Posted April 23, 2007 SpookMeister you are the master thank you very much it works perfectly tal
tal Posted April 25, 2007 Author Posted April 25, 2007 hey alli have one more problemnow i want the same one but the start point should be a word and not a characterfor example:Hello to all this is my first script > bla bla bla bla bla blabla bla Hello abcdefg > bla bla blala bla bla hello la bla bla> la bla blala bla blala bla blathe 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 boxthankstal
PsaltyDS Posted April 25, 2007 Posted April 25, 2007 Re-read the answer from lod3n back at post #10... 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
tal Posted April 25, 2007 Author Posted April 25, 2007 ye i read this but i don't know what are those commands : _StringBetween , _ArrayDisplay i didn't found those in the help file
PsaltyDS Posted April 25, 2007 Posted April 25, 2007 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
jvanegmond Posted April 25, 2007 Posted April 25, 2007 this is my version3.2.2.0The beta version of AutoIt usually is a lot better then the release. It's the beta version that everyone on the forums is using. github.com/jvanegmond
tal Posted April 25, 2007 Author Posted April 25, 2007 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.ok i will download the beat ver
tal Posted April 25, 2007 Author Posted April 25, 2007 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?
PsaltyDS Posted April 25, 2007 Posted April 25, 2007 How about (missing comma): $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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now