GEOSoft Posted December 25, 2009 Share Posted December 25, 2009 Will do sir. Don't down yourself sir. If we don't mess up from time to time, how will we ever learn codemaster sir? BTW....I tried to send you a zip file of the files but AutoIT would'nt let me,sir.Send me a PM with a valid Email address and I'll send you one where you can send me the files. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
styles3000 Posted December 25, 2009 Author Share Posted December 25, 2009 Send me a PM with a valid Email address and I'll send you one where you can send me the files. Codemaster GeoSoft, I've tried to merge these two script, although it cleared the compiler with no errors, the strings in title.txt aren't getting extracted and sent to D:\New Text Document (2).txt file. expandcollapse popup#include<file.au3> $sText = "" $sPath = "D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\" $aFiles = _FileListToArray($sPath, "*", 1) If NOT @Error Then For $i = 1 To Ubound($aFiles) -1 $sHold = FileRead($sPath & $aFiles[$i]) $aTitle = StringRegExp($sHold, "(?i)<title>(.+)</title>", 1) If NOT @Error Then $sText &= $aTitle[0] & @CRLF EndIf Next EndIf If $sText Then $sFile = @TempDir & "\titles.txt" $hFile = FileOpen($sFile, 2) FileWrite($hFile, StringStripWS($sText, 2)) FileClose($hFile) ShellExecute($sFile) EndIf Func _CreateTaggedKeywords() Dim $aRecords $PthFile = 'D:\Documents and Settings\Taevon Jones\Desktop\titles.txt' ;Full path and filename to read $outputFileName = 'D:\New Text Document (2).txt' If Not _FileReadToArray($PthFile,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $file = FileOpen($outputFileName, 2) For $x = 1 to $aRecords[0] FileWriteLine($file,'<a href="'&$aRecords[$x]&'.htm">'&$aRecords[$x]&'</a><BR>'&@CRLF) Next FileClose($file) EndFunc I tried this but it didn't work..... expandcollapse popup#include<file.au3> $sText = "" $sPath = "D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\" $aFiles = _FileListToArray($sPath, "*", 1) If NOT @Error Then For $i = 1 To Ubound($aFiles) -1 $sHold = FileRead($sPath & $aFiles[$i]) $aTitle = StringRegExp($sHold, "(?i)<title>(.+)</title>", 1) If NOT @Error Then $sText &= $aTitle[0] & @CRLF EndIf Next EndIf If $sText Then $sFile = @TempDir & "\titles.txt" $hFile = FileOpen($sFile, 2) FileWrite($hFile, StringStripWS($sText, 2)) FileClose($hFile) ShellExecute($sFile) EndIf Func _CreateTaggedKeywords() Dim $aRecords $PthFile = @TempDir & 'titles.txt' ;Full path and filename to read $outputFileName = 'D:\New Text Document (2).txt' If Not _FileReadToArray($PthFile,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $file = FileOpen($outputFileName, 2) For $x = 1 to $aRecords[0] FileWriteLine($file,'<a href="'&$aRecords[$x]&'.htm">'&$aRecords[$x]&'</a><BR>'&@CRLF) Next FileClose($file) EndFunc What could I be doing wrong? Link to comment Share on other sites More sharing options...
GEOSoft Posted December 25, 2009 Share Posted December 25, 2009 One of your problems is probably related to the path structure. Is "D:\Documents and Settings\Taevon Jones\Desktop" actually your Desktop folder? If it is then change $sPath = "D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\" To $sPath = @DeskTopDir & "\Extracted Keywords\" Try to make use of Macros (in the help file) whenever possible. Also you may want to review some of the file names and perhaps use FileGetShortName() on them. Now, it's Christmas eve and replies from me could be sporadic at best for the rest of the night and probably non-existant tomorrow. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
styles3000 Posted December 25, 2009 Author Share Posted December 25, 2009 One of your problems is probably related to the path structure.Is "D:\Documents and Settings\Taevon Jones\Desktop" actually your Desktop folder?If it is then change$sPath = "D:\Documents and Settings\Taevon Jones\Desktop\Extracted Keywords\"To$sPath = @DeskTopDir & "\Extracted Keywords\"Try to make use of Macros (in the help file) whenever possible. Also you may want to review some of the file names and perhaps use FileGetShortName() on them.Now, it's Christmas eve and replies from me could be sporadic at best for the rest of the night and probably non-existant tomorrow.CodeMaster GEOSoft, Yes, "D:\Documents and Settings\Taevon Jones\Desktop" is my Desktop folder. What are some of the benefits of Macros? Link to comment Share on other sites More sharing options...
styles3000 Posted December 26, 2009 Author Share Posted December 26, 2009 Codemaster GeoSoft, I found out what the problem was in mereging the two script. I was neglecting to place this _CreateTaggedKeywords()... before the second function as you can see below. expandcollapse popup#include<file.au3> $sText = "" $sPath = @DeskTopDir & "\Extracted Keywords\" $aFiles = _FileListToArray($sPath, "*", 1) If NOT @Error Then For $i = 1 To Ubound($aFiles) -1 $sHold = FileRead($sPath & $aFiles[$i]) $aTitle = StringRegExp($sHold, "(?i)<title>(.+)</title>", 1) If NOT @Error Then $sText &= $aTitle[0] & @CRLF EndIf Next EndIf If $sText Then $sFile = 'D:\Documents and Settings\Taevon Jones\Desktop\titles.txt' $hFile = FileOpen($sFile, 2) FileWrite($hFile, StringStripWS($sText, 2)) FileClose($hFile) ShellExecute($sFile) EndIf _CreateTaggedKeywords() Func _CreateTaggedKeywords() Dim $aRecords $PthFile = 'D:\Documents and Settings\Taevon Jones\Desktop\titles.txt' ;Full path and filename to read $outputFileName = 'D:\Documents and Settings\Taevon Jones\Desktop\OutputofFreshkeywords.txt' If Not _FileReadToArray($PthFile,$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf $file = FileOpen($outputFileName, 2) For $x = 1 to $aRecords[0] FileWriteLine($file,'<a href="'&$aRecords[$x]&'.htm">'&$aRecords[$x]&'</a><BR>'&@CRLF) Next FileClose($file) EndFunc Link to comment Share on other sites More sharing options...
GEOSoft Posted December 26, 2009 Share Posted December 26, 2009 So all is well now? George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
styles3000 Posted December 26, 2009 Author Share Posted December 26, 2009 (edited) <br />So all is well now?<br /><br /><br />Not exactly sir, their's still a final step thats been given me problems .  I believe, all I need is a StringReplace function(),  where I get confused is how to write the code to were the output of this script below..........<br /><br />expandcollapse popup<br /> <br /> #include<file.au3><br /> $sText = ""<br /> $sPath = @DeskTopDir & "\Extracted Keywords\"<br /> $aFiles = _FileListToArray($sPath, "*", 1)<br /> If NOT @Error Then<br /> For $i = 1 To Ubound($aFiles) -1<br /> $sHold = FileRead($sPath & $aFiles[$i])<br /> $aTitle = StringRegExp($sHold, "(?i)<title>(.+)</title>", 1)<br /> If NOT @Error Then<br /> $sText &= $aTitle[0] & @CRLF<br /> EndIf<br /> Next<br /> EndIf<br /> If $sText Then<br /> $sFile = 'D:\Documents and Settings\Taevon Jones\Desktop\titles.txt'<br /> $hFile = FileOpen($sFile, 2)<br /> FileWrite($hFile, StringStripWS($sText, 2))<br /> FileClose($hFile)<br /> ShellExecute($sFile)<br /> <br /> EndIf<br /> _CreateTaggedKeywords()<br /> Func _CreateTaggedKeywords()<br /> Dim $aRecords<br /> $PthFile = 'D:\Documents and Settings\Taevon Jones\Desktop\titles.txt' ;Full path and filename to read<br /> $outputFileName = 'D:\Documents and Settings\Taevon Jones\Desktop\OutputofFreshkeywords.txt'<br /> <br /> If Not _FileReadToArray($PthFile,$aRecords) Then<br /> MsgBox(4096,"Error", " Error reading log to Array error:" & @error)<br /> Exit<br /> EndIf<br /> <br /> $file = FileOpen($outputFileName, 2)<br /> For $x = 1 to $aRecords[0]<br /> FileWriteLine($file,'<a href="'&$aRecords[$x]&'.htm">'&$aRecords[$x]&'</a><BR>'&@CRLF)<br /> <br /> Next<br /> <br /> <br /> FileClose($file)<br /> EndFunc<br /> <br /> <br /><br /><br />........which is 'D:\Documents and Settings\Taevon Jones\Desktop\OutputofFreshkeywords.txt'<br />,gets opened;extracted and placed at a certain place within each html file. Below is script that I've been fiddling with  that I hope does the trick........How can I change things to make $hFile = FileOpen("D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\christmas greetings\index.htm",0)  not only go into index.htm but index1.htm,index2.htm etc,etc.<br /><br /><br />expandcollapse popup<br /> <br /> #include <file.au3><br /> Global $hFile<br /> Global $SomeTxt<br /> Global $StartPos, $EndPos<br /> Global $Find_This, $Find_This_Too<br /> Global $MyResult<br /> <br /> $Find_This = "<GROUPLINKS>"<br /> $Find_This_Too = "</GROUPLINKS>"<br /> $hFile = FileOpen("D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\christmas greetings\index.htm",0) ;Open file in read mode<br /> <br /> If @error Then<br /> MsgBox(0,"Warning", "Unable to open file")<br /> Exit<br /> EndIf<br /> <br /> $SomeTxt = FileRead($hFile) ;reads the complete file<br /> FileClose($hFile)<br /> $StartPos = StringInStr($SomeTxt,$Find_This) + StringLen($Find_This) ;finds the first string and puts the pos direct behind the found string<br /> <br /> If $StartPos = 0 Then ;means $Find_This not found, no need to continue<br /> MsgBox(0,"Warning", "Unable to find: " & $StartPos)<br /> Exit<br /> Else<br /> ConsoleWrite("$StartPos= " & $StartPos & @CRLF) ;not needed just added to check if code works<br /> EndIf<br /> <br /> $EndPos = StringInStr($SomeTxt,$Find_This_Too,0,1,$StartPos) ;finds the first occurence of $Find_This_Too after $Start_pos<br /> <br /> If $EndPos = 0 Then ;means $Find_This_Too was not found, no need to continue<br /> MsgBox(0,"Warning", "Unable to find: " & $EndPos)<br /> Exit<br /> Else<br /> ConsoleWrite("$EndPos= " & $EndPos & @CRLF) ;not needed just added to check if code works<br /> EndIf<br /> <br /> $MyResult = (StringMid($SomeTxt,$StartPos,$EndPos-$StartPos))<br /> $MyResult = StringStripWS($MyResult,3)<br /> <br /> <br /> If StringLen($MyResult) <> 0 Then<br /> MsgBox(0,"Finished", "You were looking for: " & $MyResult )<br /> $text_from_clip = ClipGet() ;Takes the result off the clipboard<br /> $result = StringReplace($SomeTxt, $MyResult, $text_from_clip)<br /> Clipput($Result) ;Put the result on the clipboard<br /> Else<br /> MsgBox(0,"Warning", "Unable to find the wanted string")<br /> EndIf<br /> <br /><br /><br />.... since I last emailed you the htm files, I've added an additional tag within all of them. Called the "<GROUPLINKS> "</GROUPLINKS>"  tags.  I'm trying to extract  send all in 'D:\Documents and Settings\Taevon Jones\Desktop\OutputofFreshkeywords.txt'<br />to each htm file and insert the string betweet the  <GROUPLINKS> </GROUPLINKS>tags. Edited December 26, 2009 by styles3000 Link to comment Share on other sites More sharing options...
styles3000 Posted December 26, 2009 Author Share Posted December 26, 2009 <br /><br /><br />Not exactly sir, their's still a final step thats been given me problems .  I believe, all I need is a StringReplace function(),  where I get confused is how to write the code to were the output of this script below..........<br /><br />expandcollapse popup<br /> <br /> <br /> <br /> #include&lt;file.au3&gt;<br /> <br /> $sText = &quot;&quot;<br /> <br /> $sPath = @DeskTopDir &amp; &quot;\Extracted Keywords\&quot;<br /> <br /> $aFiles = _FileListToArray($sPath, &quot;*&quot;, 1)<br /> <br /> If NOT @Error Then<br /> <br /> &nbsp;&nbsp;&nbsp; For $i = 1 To Ubound($aFiles) -1<br /> <br /> &nbsp;&nbsp;&nbsp; $sHold = FileRead($sPath &amp; $aFiles[$i])<br /> <br /> &nbsp;&nbsp;&nbsp; $aTitle = StringRegExp($sHold, &quot;(?i)&lt;title&gt;(.+)&lt;/title&gt;&quot;, 1)<br /> <br /> &nbsp;&nbsp;&nbsp; If NOT @Error Then<br /> <br /> &nbsp;&nbsp;&nbsp; $sText &amp;= $aTitle[0] &amp; @CRLF<br /> <br /> &nbsp;&nbsp;&nbsp; EndIf<br /> <br /> &nbsp;&nbsp;&nbsp; Next<br /> <br /> EndIf<br /> <br /> If $sText Then<br /> <br /> &nbsp;&nbsp;&nbsp; $sFile = 'D:\Documents and Settings\Taevon Jones\Desktop\titles.txt'<br /> <br /> &nbsp;&nbsp;&nbsp; $hFile = FileOpen($sFile, 2)<br /> <br /> &nbsp;&nbsp;&nbsp; FileWrite($hFile, StringStripWS($sText, 2))<br /> <br /> &nbsp;&nbsp;&nbsp; FileClose($hFile)<br /> <br /> &nbsp;&nbsp;&nbsp; ShellExecute($sFile)<br /> <br /> <br /> <br /> EndIf<br /> <br /> _CreateTaggedKeywords()<br /> <br /> Func _CreateTaggedKeywords()<br /> <br /> &nbsp;&nbsp;&nbsp; Dim $aRecords<br /> <br /> &nbsp;&nbsp;&nbsp; $PthFile = 'D:\Documents and Settings\Taevon Jones\Desktop\titles.txt' ;Full path and filename to read<br /> <br /> &nbsp;&nbsp;&nbsp; $outputFileName = 'D:\Documents and Settings\Taevon Jones\Desktop\OutputofFreshkeywords.txt'<br /> <br /> <br /> <br /> &nbsp;&nbsp;&nbsp; If Not _FileReadToArray($PthFile,$aRecords) Then<br /> <br /> &nbsp;&nbsp;&nbsp; MsgBox(4096,&quot;Error&quot;, &quot; Error reading log to Array &nbsp;&nbsp;&nbsp; error:&quot; &amp; @error)<br /> <br /> &nbsp;&nbsp;&nbsp; Exit<br /> <br /> &nbsp;&nbsp;&nbsp; EndIf<br /> <br /> <br /> <br /> &nbsp;&nbsp;&nbsp; $file = FileOpen($outputFileName, 2)<br /> <br /> &nbsp;&nbsp;&nbsp; For $x = 1 to $aRecords[0]<br /> <br /> &nbsp;&nbsp;&nbsp; FileWriteLine($file,'&lt;a href=&quot;'&amp;$aRecords[$x]&amp;'.htm&quot;&gt;'&amp;$aRecords[$x]&amp;'&lt;/a&gt;&lt;BR&gt;'&amp;@CRLF)<br /> <br /> <br /> <br /> Next<br /> <br /> <br /> <br /> <br /> <br /> &nbsp;&nbsp;&nbsp; FileClose($file)<br /> <br /> EndFunc<br /> <br /> <br /> <br /> <br /> <br /><br /><br /><br /><br /><br />expandcollapse popup<br /> <br /> <br /> <br /> #include &lt;file.au3&gt;<br /> <br /> Global $hFile<br /> <br /> Global $SomeTxt<br /> <br /> Global $StartPos, $EndPos<br /> <br /> Global $Find_This, $Find_This_Too<br /> <br /> Global $MyResult<br /> <br /> <br /> <br /> $Find_This = &quot;&lt;GROUPLINKS&gt;&quot;<br /> <br /> $Find_This_Too = &quot;&lt;/GROUPLINKS&gt;&quot;<br /> <br /> $hFile = FileOpen(&quot;D:\Documents and Settings\Taevon Jones\My Documents\One a be HyperVRE Webpages\christmas greetings\index.htm&quot;,0)&nbsp;&nbsp;&nbsp; ;Open file in read mode<br /> <br /> <br /> <br /> If @error Then<br /> <br /> &nbsp;&nbsp;&nbsp; MsgBox(0,&quot;Warning&quot;, &quot;Unable to open file&quot;)<br /> <br /> &nbsp;&nbsp;&nbsp; Exit<br /> <br /> EndIf<br /> <br /> <br /> <br /> $SomeTxt = FileRead($hFile)&nbsp;&nbsp;&nbsp; ;reads the complete file<br /> <br /> FileClose($hFile)<br /> <br /> $StartPos = StringInStr($SomeTxt,$Find_This) + StringLen($Find_This) ;finds the first string and puts the pos direct behind the found string<br /> <br /> <br /> <br /> If $StartPos = 0 Then &nbsp;&nbsp;&nbsp; ;means $Find_This not found, no need to continue<br /> <br /> &nbsp;&nbsp;&nbsp; MsgBox(0,&quot;Warning&quot;, &quot;Unable to find: &quot; &amp; $StartPos)<br /> <br /> &nbsp;&nbsp;&nbsp; Exit<br /> <br /> Else<br /> <br /> &nbsp;&nbsp;&nbsp; ConsoleWrite(&quot;$StartPos= &quot; &amp; $StartPos &amp; @CRLF) &nbsp;&nbsp;&nbsp; ;not needed just added to check if code works<br /> <br /> EndIf<br /> <br /> <br /> <br /> $EndPos = StringInStr($SomeTxt,$Find_This_Too,0,1,$StartPos) ;finds the first occurence of $Find_This_Too after $Start_pos<br /> <br /> <br /> <br /> If $EndPos = 0 Then &nbsp;&nbsp;&nbsp; ;means $Find_This_Too was not found, no need to continue<br /> <br /> &nbsp;&nbsp;&nbsp; MsgBox(0,&quot;Warning&quot;, &quot;Unable to find: &quot; &amp; $EndPos)<br /> <br /> &nbsp;&nbsp;&nbsp; Exit<br /> <br /> Else<br /> <br /> &nbsp;&nbsp;&nbsp; ConsoleWrite(&quot;$EndPos= &quot; &amp; $EndPos &amp; @CRLF) &nbsp;&nbsp;&nbsp; ;not needed just added to check if code works<br /> <br /> EndIf<br /> <br /> <br /> <br /> $MyResult = (StringMid($SomeTxt,$StartPos,$EndPos-$StartPos))<br /> <br /> $MyResult = StringStripWS($MyResult,3)<br /> <br /> <br /> <br /> <br /> <br /> If StringLen($MyResult) &lt;&gt; 0 Then<br /> <br /> &nbsp;&nbsp;&nbsp; MsgBox(0,&quot;Finished&quot;, &quot;You were looking for: &quot; &amp; $MyResult&nbsp;&nbsp;&nbsp; )<br /> <br /> &nbsp;&nbsp;&nbsp; $text_from_clip = ClipGet()&nbsp;&nbsp;&nbsp; ;Takes the result off the clipboard<br /> <br /> &nbsp;&nbsp;&nbsp; $result = StringReplace($SomeTxt, $MyResult, $text_from_clip)<br /> <br /> &nbsp;&nbsp;&nbsp; Clipput($Result)&nbsp;&nbsp;&nbsp; ;Put the result on the clipboard<br /> <br /> Else<br /> <br /> &nbsp;&nbsp;&nbsp; MsgBox(0,&quot;Warning&quot;, &quot;Unable to find the wanted string&quot;)<br /> <br /> EndIf<br /> <br /> <br /> <br /><br /><br />.... since I last emailed you the htm files, I've added an additional tag within all of them. Called the &quot;&lt;GROUPLINKS&gt; &quot;&lt;/GROUPLINKS&gt;&quot;  tags.  I'm trying to extract  send all in 'D:\Documents and Settings\Taevon Jones\Desktop\OutputofFreshkeywords.txt'<br />to each htm file and insert the string betweet the  &lt;GROUPLINKS&gt; &lt;/GROUPLINKS&gt;tags.<br /><br /><br /><br /> I don't know what just happened to my post, could anybody tell me why it has all the funny characters in it? Link to comment Share on other sites More sharing options...
styles3000 Posted December 27, 2009 Author Share Posted December 27, 2009 (edited) Send me a PM with a valid Email address and I'll send you one where you can send me the files.Codemaster GEOSoft', All is well, I pulled some code together that suited my needs. Thank you again as well as everyone elses support. Edited December 27, 2009 by styles3000 Link to comment Share on other sites More sharing options...
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