Sign in to follow this  
Followers 0
Bi0haZarD

File Read - only getting part of the text file.

9 posts in this topic

#1 ·  Posted (edited)

ok, found an app that gets all the info about a ventrilo server. and i'm trying to read the text file that i make using a .cmd file...

so... in the .cmd file i have

ventstat.exe 192.168.0.102 > stat.txt

now in my code i have a function called _read()

Func _read()
    Local $stat
    If FileExists("stat.txt") Then
        $stat = FileRead("stat.txt", FileGetSize("stat.txt"))
        Return $stat
    Else
        SetError(1)
        Return -1
    EndIf
EndFunc

now for the really weird part...

I read the text file like normal however.. it only gets the first part of the text file.. if i open it in notepad then re save it, it gets all the info...

any idea of why its doing this and how to fix it?

hmm the file size changes after its been saved in notepad...

Original:

Size: 841

Size on Disk: 4,096

After saved in notepad:

Size: 1,052

Size on Disk: 4,096

Edited by Bi0haZarD

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

as a hobbyist, i can only guess that there is an EOF (End Of File) found when read by FileRead()

since re-saving creates a larger file (from your edit) maybe try this

ventstat.exe 192.168.0.102 > stat1.txt

FileCopy(Stat1.txt, Stat.txt)

then call your _read() function

just an idea

6)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

good idea, i didn't think about that. but didn't work unfortunantly ;)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

would help if you attached a copy of the file, but sounds like some line feed conversion

<{POST_SNAPBACK}>

here it is.

http://www.bio.pk-designs.com/ventstat.zip

i have commented out the part where it trys to run the "run.cmd".

but i'm guessing if you download it and run it then it should should do what its doing over here. it'll read like 15 lines or so then stop. if you open the "stat.txt" file with notepad then save it and hit read it'll read the full text file.

only thing i can really think to fix this is to use autoit to open the file in notepad then save it then open it.

Edited by Bi0haZarD

Share this post


Link to post
Share on other sites

Ok, the file has nul lines it quits reading at the 1st nul line.

<{POST_SNAPBACK}>

how could i get past that?

Share this post


Link to post
Share on other sites

$s_file = _read()
ConsoleWrite($s_file)

Func _read()
    Local $stat, $file, $line
    If FileExists(@ScriptDir & "\stat.txt") Then
        $file = FileOpen(@ScriptDir & "\stat.txt", 0)
        
        If $file = -1 Then
            MsgBox(0, "Error", "Unable to open file.")
            Exit
        EndIf
        While 1
            $line = FileReadLine($file)
            If @error = -1 Then ExitLoop
            $stat = $stat & $line & @LF
        WEnd
        
        FileClose($file)
        Return $stat
    Else
        SetError(1)
        Return -1
    EndIf
EndFunc  ;==>_read


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

ahh many thanks ;)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0