Sign in to follow this  
Followers 0
Aimjiel

FileReadLine returns Blank line

3 posts in this topic

Hey All,

I have been coding all day, so I am probably overlooking something simple.

I Write a file, it writes correctly, content is there. And then open it again for reading. It reads the correct number of lines, except, they are all blank.

Func parseFile($inf,$fileName,$pre)
    Local $output
    Local $currentLine
    Local $localLineNumber = 0
    ConsoleWrite("Parsing " & $fileName) 
    While True
        ;ConsoleWrite("Reading line..." & $localLineNumber)
        $currentLine = FileReadLine($inf)
        If @error = -1 Then ExitLoop
        $currentLineNumber += 1
        $localLineNumber += 1
        $output &= parseLine($currentLine,$fileName,$localLineNumber,$pre,0)
        If $localLineNumber > 2000 Then ExitLoop
    WEnd
    Return $output
EndFunc
For $i = 0 To UBound($files,1) - 1 Step 1
    Global $in = FileOpen($files[$i],0)
    Local $output
    $output = parseFile($in,$files[$i],'')
    $of = FileOpen("Build.ouput.au3",2)
    FileWrite($of,$output)
    FileClose($of)
    FileClose($in)  
Next
;The above works fine.
    $x = 0
    $headsMatched = False
    $DEBUG = True
Do
    $infile = FileOpen("Build.output.au3",0) ;opens the file, no @error problems
    $outfile = FileOpen("Build.pass.au3",2)
    $output = parseFile($infile, "","") ;This works, except all of the lines are blank, I counted the blank lines, it's the correct number, they are just blank.
    FileWrite($outfile,$output)
    FileClose($infile)
    FileClose($outfile)
    FileCopy("Build.pass.au3","Build.output.au3",1)
Until $headsMatched = False

So, the first pass works, second pass doesn't...Note I have been trying variations for about an hour and I am at my wits end.

Thanks in advance for any light you can shed on this...

/jason

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hey All,

I have been coding all day, so I am probably overlooking something simple.

I Write a file, it writes correctly, content is there. And then open it again for reading. It reads the correct number of lines, except, they are all blank.

Func parseFile($inf,$fileName,$pre)
    Local $output
    Local $currentLine
    Local $localLineNumber = 0
    ConsoleWrite("Parsing " & $fileName) 
    While True
        ;ConsoleWrite("Reading line..." & $localLineNumber)
        $currentLine = FileReadLine($inf)
        If @error = -1 Then ExitLoop
        $currentLineNumber += 1
        $localLineNumber += 1
        $output &= parseLine($currentLine,$fileName,$localLineNumber,$pre,0)
        If $localLineNumber > 2000 Then ExitLoop
    WEnd
    Return $output
EndFunc
For $i = 0 To UBound($files,1) - 1 Step 1
    Global $in = FileOpen($files[$i],0)
    Local $output
    $output = parseFile($in,$files[$i],'')
    $of = FileOpen("Build.ouput.au3",2)
    FileWrite($of,$output)
    FileClose($of)
    FileClose($in)  
Next
;The above works fine.
    $x = 0
    $headsMatched = False
    $DEBUG = True
Do
    $infile = FileOpen("Build.output.au3",0) ;opens the file, no @error problems
    $outfile = FileOpen("Build.pass.au3",2)
    $output = parseFile($infile, "","") ;This works, except all of the lines are blank, I counted the blank lines, it's the correct number, they are just blank.
    FileWrite($outfile,$output)
    FileClose($infile)
    FileClose($outfile)
    FileCopy("Build.pass.au3","Build.output.au3",1)
Until $headsMatched = False

So, the first pass works, second pass doesn't...Note I have been trying variations for about an hour and I am at my wits end.

Thanks in advance for any light you can shed on this...

/jason

Me thinks the typo "Build.ouput.au3" may have some bearing on your difficulties.

That filename is probably a good candidate for a CONST, since it is referenced more than once.

Edited by Spiff59

Share this post


Link to post
Share on other sites

Me thinks the typo "Build.ouput.au3" may have some bearing on your difficulties.

That filename is probably a good candidate for a CONST, since it is referenced more than once.

You rock, thank you so much. I was so bleary eyed I completely missed it.

/Jason

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