Page 1 of 1 1
Topic Options
#171795 - 2006-12-20 02:35 PM Readline problem in .htm file
Muesli Offline
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:
Code:
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
#171796 - 2006-12-20 02:45 PM Re: Readline problem in .htm file [Re: Muesli]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
is it true then, that each line contains at least one <'br'>?
perhaps you could do a instr for <'br'>'s and from that point work your way through it?


Edited by Björn (2006-12-20 02:45 PM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#171797 - 2006-12-20 02:48 PM Re: Readline problem in .htm file [Re: Björn]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
it's a unicode file, not ansi text.
need to translate it to ansi/ascii or use UDF that translates it for you.
_________________________
!

download KiXnet

Top
#171799 - 2006-12-20 02:54 PM Re: Readline problem in .htm file [Re: Lonkero]
Muesli Offline
Fresh Scripter

Registered: 2006-07-17
Posts: 26
Originally Posted By: Jooel
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 ".

Originally Posted By: Björn
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.

Quote:
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
#171800 - 2006-12-20 03:00 PM Re: Readline problem in .htm file [Re: Muesli]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
couldn't find one in the UDF lib either. odd.

anyways, here is one:
Code:
function UnicodeToAscii($inputFile, $outputFile)
 Shell '%compsec% /C type "' + $inputFile + '" > "' + $outputFile + '"'
endfunction
_________________________
!

download KiXnet

Top
#171801 - 2006-12-20 03:06 PM Re: Readline problem in .htm file [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
btw, I think you could also use FSO to read unicode files...

here is a link for the udf if you wish to give it a try:
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Number=164088


Edited by Jooel (2006-12-20 03:08 PM)
_________________________
!

download KiXnet

Top
#171802 - 2006-12-20 03:14 PM Re: Readline problem in .htm file [Re: Lonkero]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Originally Posted By: Jooel
hmm...
couldn't find one in the UDF lib either. odd.

anyways, here is one:
Code:
function UnicodeToAscii($inputFile, $outputFile)
 Shell '%compsec% /C type "' + $inputFile + '" > "' + $outputFile + '"'
endfunction


Care to post this with a header in udf forum?

I know it is much more work for you but ...

btw. If you are at it anyway, how about silencing the error stream just in case


Edited by Jochen (2006-12-20 03:15 PM)
_________________________



Top
#171803 - 2006-12-20 03:27 PM Re: Readline problem in .htm file [Re: Lonkero]
Muesli Offline
Fresh Scripter

Registered: 2006-07-17
Posts: 26
Originally Posted By: Jooel
hmm...
couldn't find one in the UDF lib either. odd.

anyways, here is one:
Code:
function UnicodeToAscii($inputFile, $outputFile)
 Shell '%compsec% /C type "' + $inputFile + '" > "' + $outputFile + '"'
endfunction


Ok i tried it like this:

Code:
 
$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
#171804 - 2006-12-20 03:30 PM Re: Readline problem in .htm file [Re: Muesli]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
$Location = ""

What is the point of that?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#171805 - 2006-12-20 03:32 PM Re: Readline problem in .htm file [Re: Les]
Muesli Offline
Fresh Scripter

Registered: 2006-07-17
Posts: 26
Originally Posted By: Les
$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
#171808 - 2006-12-20 03:41 PM Re: Readline problem in .htm file [Re: Muesli]
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Then what location is it supposed to find the files now? You should never rely on chance.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#171810 - 2006-12-20 03:47 PM Re: Readline problem in .htm file [Re: Les]
Muesli Offline
Fresh Scripter

Registered: 2006-07-17
Posts: 26
In the same directory as where the .kix is placed at the moment.
Top
#171812 - 2006-12-20 04:10 PM Re: Readline problem in .htm file [Re: Muesli]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well...
comspec opens in different folder.
either in system32 or in your home dir.

just set the full path to the file and it shall work.
_________________________
!

download KiXnet

Top
#171855 - 2006-12-21 04:52 AM Re: Readline problem in .htm file [Re: Lonkero]
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
You might also want to correct the typo in
Code:
'%compsec%
\:\)
_________________________
There are two types of vessels, submarines and targets.

Top
#177284 - 2007-06-27 10:49 AM Re: Readline problem in .htm file [Re: Muesli]
Tobi Offline
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
#177285 - 2007-06-27 11:03 AM Re: Readline problem in .htm file [Re: Tobi]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
It's not the language of the OS that has a different spelling for %comspec%. It depends on the user. If he or she types to fast letters get mixed up ;\)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 657 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.076 seconds in which 0.032 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org