Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mix mode input of a binary open file Question!
#2
Easy Peasy two-minute exercise in creating a HybridInput routine for you.   Smile

Code: (Select All)
Open "Z:/test.txt" For Input As #1
Do
    Print HybridInput$(1)
    Sleep
Loop Until EOF(1)

Function HybridInput$ (file)
    Static As Long ReadWholeLine, Init
    StartPos = Seek(file)
    If ReadWholeLine Then
        Line Input #1, dta$
        If Left$(_Trim$(dta$), 1) = "#" Then HybridInput$ = dta$: Exit Function
        ReadWholeLine = 0 'we are no longer reading the whole line
        Seek file, StartPos
    End If
    Input #1, dta$
    If Left$(_Trim$(dta$), 1) = "#" Then ReadWholeLine = -1
    HybridInput$ = dta$
End Function

Note that if you want to do this with BINARY input mode, you'd basically do the same, but you'd have to change the INPUT section to simply parse that dta$ form StartPos, looking for the comma, and take that segment to be your input.  Then SEEK to the proper position (StartPos + length of the dta$ segment you called the answer +1 for the comma after), and you'd be primed to ust continue on with no problems whatsoever.

BINARY doesn't support INPUT (one of these days, I've always said I was going to expand it so it could...), so you'll just need to parse your dta$, get the proper input, and then move the file pointer back to the proper spot to pick up from on the next read for data.


Attached Files
.txt   test.txt (Size: 215 bytes / Downloads: 11)
Reply


Messages In This Thread
RE: Mix mode input of a binary open file Question! - by SMcNeill - 11-28-2024, 01:44 PM



Users browsing this thread: 1 Guest(s)