Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mix mode input of a binary open file Question!
#4
(11-28-2024, 01:44 PM)SMcNeill Wrote: 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.
This could work for me and anybody else.  I will just convert string to number when needed.  Side bonus:  Didn't know "\" and "/" interchangeable with a pathname.
Thanks for the "+" answer.
Reply


Messages In This Thread
RE: Mix mode input of a binary open file Question! - by doppler - 11-28-2024, 02:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  a question about OpenGL in QB64pe: TempodiBasic 11 1,861 11-22-2025, 05:47 PM
Last Post: TempodiBasic
  How do you boot Win 11 in Safe Mode? Pete 8 5,954 10-30-2025, 06:03 AM
Last Post: SMcNeill
  Download the file from the internet and extract the .zip file quickbasic 6 684 10-25-2025, 01:39 AM
Last Post: madscijr
  Question about load pictures Jim_001 4 554 10-22-2025, 06:19 AM
Last Post: Unseen Machine
  Test to post a new Thread + question 32 or 64 bit Rudy M 2 556 09-09-2025, 04:10 PM
Last Post: Rudy M

Forum Jump:


Users browsing this thread: 1 Guest(s)