n9mfk9 Posted April 12, 2007 Share Posted April 12, 2007 Hi Here is my code It works my questionis about $line = StringReplace($line,"0","Ø") i wet to look between <TD an /TD for 0 but i only wet to change the the zero $file = FileOpen("n9mfk.html", 0) ;Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $line = StringReplace($line,"0","Ø") MsgBox(0, "Line read:", $line) $file1 = FileOpen("test.html", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWriteLine($file1, $line) Wend FileClose($file) Here is what is in n9mfk.html <body background bgcolor="#FFFFFF" text="#003399" link="#3366FF" vlink="#9900FF" alink="#000066"> <!--mstheme--><font face="Century Gothic, Arial, Helvetica"> <p ALIGN=center><b><font face="Arial" size="5">n9mfk Logbook <b><font size="2"> Created on: 4/3/2007 </font><font face="Arial" size="3" S-Type="REGENERATED" S-Format="%m/%d/%Y %H:%M"<!--webbot bot="Timestamp" I-CheckSum="26219" endspan --> </font></b></p> <p><font face="Courier New" size="2">s <TABLE WIDTH="85%"ALIGN=center BORDER="1"> <TR> <TD ALIGN=center><FONT SIZE="2">TIME</font/></TD><TD ALIGN=center><FONT SIZE="2">CALL</font/></TD><TD ALIGN=center><FONT SIZE="2">PFX</font/></TD><TD ALIGN=center><FONT SIZE="2">FREQ</font/></TD><TD ALIGN=center><FONT SIZE="2">BAND</font/></TD><TD ALIGN=center><FONT SIZE="2">MODE</font/></TD><TD ALIGN=center><FONT SIZE="2">RCVD</font/></TD><TD ALIGN=center><FONT SIZE="2">SENT</font/></TD><TD ALIGN=center><FONT SIZE="2">QSL-R</font/></TD><TD ALIGN=center><FONT SIZE="2">QSL-S</font/></TD><TD ALIGN=center><FONT SIZE="2">IOTA</font/></TD></TR> <TR> <TD ALIGN=center><FONT SIZE="2">17:45</font/></TD><TD ALIGN=center><FONT SIZE="2">N8RZZ </font/></TD><TD ALIGN=center><FONT SIZE="2">N8 </font/></TD><TD ALIGN=center><FONT SIZE="2">28.4000</font/></TD><TD ALIGN=center><FONT SIZE="2">10M </font/></TD><TD ALIGN=center><FONT SIZE="2">SSB </font/></TD><TD ALIGN=center><FONT SIZE="2">59 </font/></TD><TD ALIGN=center><FONT SIZE="2">57 </font/></TD><TD ALIGN=center><FONT SIZE="2"> </font/></TD><TD ALIGN=center><FONT SIZE="2"> </font/></TD><TD ALIGN=center><FONT SIZE="2"> </font/></TD> </TR> <TR> <TD ALIGN=center><FONT SIZE="2">18:51</font/></TD><TD ALIGN=center><FONT SIZE="2">W1AW </font/></TD><TD ALIGN=center><FONT SIZE="2">W1 </font/></TD><TD ALIGN=center><FONT SIZE="2">21.3090</font/></TD><TD ALIGN=center><FONT SIZE="2">15M </font/></TD><TD ALIGN=center><FONT SIZE="2">SSB </font/></TD><TD ALIGN=center><FONT SIZE="2">59 </font/></TD><TD ALIGN=center><FONT SIZE="2">33 </font/></TD><TD ALIGN=center><FONT SIZE="2"> </font/></TD><TD ALIGN=center><FONT SIZE="2"> </font/></TD><TD ALIGN=center><FONT SIZE="2"> </font/></TD> </TR> <TR> <TD ALIGN=center><FONT SIZE="2">21:21</font/></TD><TD ALIGN=center><FONT SIZE="2">K9UXZ </font/></TD><TD ALIGN=center><FONT SIZE="2">K9 </font/></TD><TD ALIGN=center><FONT SIZE="2">14.2350</font/></TD><TD ALIGN=center><FONT SIZE="2">20M </font/></TD><TD ALIGN=center><FONT SIZE="2">SSB </font/></TD><TD ALIGN=center><FONT SIZE="2">52 </font/></TD><TD ALIGN=center><FONT SIZE="2">57 </font/></TD><TD ALIGN=center><FONT SIZE="2"> </font/></TD><TD ALIGN=center><FONT SIZE="2"> </font/></TD><TD ALIGN=center><FONT SIZE="2"> </font/></TD> </TR> thanks for all help Link to comment Share on other sites More sharing options...
Zedna Posted April 12, 2007 Share Posted April 12, 2007 If I understand you correct then look at _StringBetween() Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 12, 2007 Share Posted April 12, 2007 (edited) You don't have to treat the file line-by-line. $FileInData = FileRead($FileIn, FileGetSize($FileIn)) Read the whole file in as a single string and then parse that. P.S. A clever StringRegExpReplace() would probably get the change done in one line of code too, but I'm not much help with RegExp stuff... Edited April 12, 2007 by PsaltyDS 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 Link to comment Share on other sites More sharing options...
Zedna Posted April 12, 2007 Share Posted April 12, 2007 P.S. A clever StringRegExpReplace() would probably get the change done in one line of code too, but I'm not much help with RegExp stuff... Yes. My proposed _StringBetween() internally use StringRegExp Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
n9mfk9 Posted April 12, 2007 Author Share Posted April 12, 2007 If I understand you correct then look at _StringBetween()Zedna, if i use string between how wood i use stringreplace with an ArrayThanks Beau Link to comment Share on other sites More sharing options...
Zedna Posted April 12, 2007 Share Posted April 12, 2007 Zedna, if i use string between how wood i use stringreplace with an ArrayThanks BeauSorry.Take a source of _StringBetween() and make your new UDF _StringBetweenReplace() --> instead of StringRegExp() use StringRegExpReplace() Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 12, 2007 Share Posted April 12, 2007 I'm not smart enough for the fancy shmancy RegExp, just say'n it would work for those who were. Had to brute force it with what I understood: Saved the input file as TestIn.txt and ran this: $FileIn = @ScriptDir & "\TestIn.txt" $FileOut = @ScriptDir & "\TestOut.txt" $FileInData = FileRead($FileIn, FileGetSize($FileIn)) $avSplitData = StringSplit($FileInData, "<TD", 1) $FileOutData = $avSplitData[1] For $n = 2 To $avSplitData[0] $End = StringInStr($avSplitData[$n], "</TD>", 0, -1) $EndLen = StringLen($avSplitData[$n]) - $End + 1 $EndText = StringRight($avSplitData[$n], $EndLen) $avSplitData[$n] = StringTrimRight($avSplitData[$n], $EndLen) $FileOutData &= "<TD" & StringReplace($avSplitData[$n], "0", "Ø") & $EndText Next $hFileOut = FileOpen($FileOut, 2) FileWrite($hFileOut, $FileOutData) FileClose($hFileOut) Run('Notepad.exe "' & $FileOut & '"') 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 Link to comment Share on other sites More sharing options...
n9mfk9 Posted April 12, 2007 Author Share Posted April 12, 2007 PsaltyDS, thanks works great I'm not smart enough for the fancy shmancy RegExp, just say'n it would work for those who were. Had to brute force it with what I understood: Saved the input file as TestIn.txt and ran this: $FileIn = @ScriptDir & "\TestIn.txt" $FileOut = @ScriptDir & "\TestOut.txt" $FileInData = FileRead($FileIn, FileGetSize($FileIn)) $avSplitData = StringSplit($FileInData, "<TD", 1) $FileOutData = $avSplitData[1] For $n = 2 To $avSplitData[0] $End = StringInStr($avSplitData[$n], "</TD>", 0, -1) $EndLen = StringLen($avSplitData[$n]) - $End + 1 $EndText = StringRight($avSplitData[$n], $EndLen) $avSplitData[$n] = StringTrimRight($avSplitData[$n], $EndLen) $FileOutData &= "<TD" & StringReplace($avSplitData[$n], "0", "Ø") & $EndText Next $hFileOut = FileOpen($FileOut, 2) FileWrite($hFileOut, $FileOutData) FileClose($hFileOut) Run('Notepad.exe "' & $FileOut & '"') Link to comment Share on other sites More sharing options...
PsaltyDS Posted April 12, 2007 Share Posted April 12, 2007 PsaltyDS, thanks works greatYou're welcome. 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 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