#171795 - 2006-12-20 02:35 PM
Readline problem in .htm file
|
Muesli
Fresh Scripter
Registered: 2006-07-17
Posts: 26
|
Hi, Im making a script to read an .htm file that is writen by a server. It then picks up certain lines of "importance", which are then written to a different file (For ease i i have posted it here to go to a messagebox).
The problem is that instead of reading the lines and then storing them in a string its reading every single "character"/"letter". By doing this it is impossible to get important sentences written by the server.
This is what the script looks like:
Open(1,$Location+"Full Backup_"+$BDate+$BMonth+".htm",2)
$readline = ReadLine(1)
?$readline
$Count = val($Count) + 1
WHILE @error = 0
$readline = ReadLine(1)
?$readline
$Count = val($Count) + 1
? $Count
If $Count = 175 ; Count untill important line
$Myarray = Split($readline, "<BR>") ;Spilt Line
For Each $Element In $MyArray ;Check Line
?$readline
? $Element
If $ElementCount = 3
$JobStat = $Element ;Store Jobstatus
EndIf
$ElementCount = val($ElementCount) + 1
Next
EndIf
LOOP
Close(1)
Messagebox($JobStat,"Message Box Title",48,0)
Thanks in advance
Edited by Muesli (2006-12-20 02:37 PM)
|
|
Top
|
|
|
|
#171799 - 2006-12-20 02:54 PM
Re: Readline problem in .htm file
[Re: Lonkero]
|
Muesli
Fresh Scripter
Registered: 2006-07-17
Posts: 26
|
it's a unicode file, not ansi text. need to translate it to ansi/ascii or use UDF that translates it for you.
Do you know if such a UDF exists? I just looked at the UDF library and could only find "IsUnicode() - Determines if a file is unicode ".
is it true then, that each line contains at least one <'br'>?
The line that i want is filled with <BR>'s which sepperate the the parts i want.
perhaps you could do a instr for <'br'>'s and from that point work your way through it?
Im not sure what you mean whith this?
Grtz.
Edited by Muesli (2006-12-20 03:01 PM)
|
|
Top
|
|
|
|
#171803 - 2006-12-20 03:27 PM
Re: Readline problem in .htm file
[Re: Lonkero]
|
Muesli
Fresh Scripter
Registered: 2006-07-17
Posts: 26
|
hmm... couldn't find one in the UDF lib either. odd. anyways, here is one:
function UnicodeToAscii($inputFile, $outputFile)
Shell '%compsec% /C type "' + $inputFile + '" > "' + $outputFile + '"'
endfunction
Ok i tried it like this:
$BDate = "15"
$BMonth = "May"
$Location = ""
UnicodeToAscii($Location+"Full Backup_"+$BDate+$BMonth+".htm", $Location+"Full Backup_"+$BDate+$BMonth+".txt")
function UnicodeToAscii($inputFile, $outputFile)
Shell '%compsec% /C type "' + $inputFile + '" > "' + $outputFile + '"'
?"Done!"
Sleep 2
endfunction
But I dont get the .txt file back ?
|
|
Top
|
|
|
|
#171805 - 2006-12-20 03:32 PM
Re: Readline problem in .htm file
[Re: Les]
|
Muesli
Fresh Scripter
Registered: 2006-07-17
Posts: 26
|
$Location = ""
What is the point of that?
Nothing now but in the future it will open its file from a different location. So i put it in the script now so i dont have to do it later.
|
|
Top
|
|
|
|
#171810 - 2006-12-20 03:47 PM
Re: Readline problem in .htm file
[Re: Les]
|
Muesli
Fresh Scripter
Registered: 2006-07-17
Posts: 26
|
In the same directory as where the .kix is placed at the moment.
|
|
Top
|
|
|
|
#177284 - 2007-06-27 10:49 AM
Re: Readline problem in .htm file
[Re: Muesli]
|
Tobi
Fresh Scripter
Registered: 2006-03-31
Posts: 11
|
Hi,
I don't have an English OS but I think there is a small typing failure in the function that disables it's functionality:
function UnicodeToAscii($inputFile, $outputFile) Shell '%compsec% /C type "' + $inputFile + '" > "' + $outputFile + '"' endfunction
should be: function UnicodeToAscii($inputFile, $outputFile) Shell '%comspec% /C type "' + $inputFile + '" > "' + $outputFile + '"' endfunction
=> the environment variable compsec doesn't exist on my system, it is comspec
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 837 anonymous users online.
|
|
|