Author Topic: LookAhead function  (Read 681 times)

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2229
    • View Profile
LookAhead function
« on: October 17, 2023, 09:49:57 AM »
The FTELL function was recently added to the BCX.  Besides the example in the BCX Help file,
the following might sometimes be useful when reading lines of text from sequential files.  It allows
us to selectively grab the next line of text without changing the current line pointer.  In other words,
in a loop like this, we get a peek at the next line.

WHILE NOT EOF(FP1)
    LINE INPUT FP1, Txt$
    IF LookAhead$(FP1) = Txt$ THEN PRINT "The Next Line is the same as Txt$"
WEND

LookAhead$() gets its super-power from the FTELL and SEEK commands.

UPDATED 8/8/2024 -- This function has been enhanced and built into 8.1.2
« Last Edit: August 08, 2024, 09:49:55 AM by MrBcx »