business-basicbbj

How to read a txt file in BBx4


I have a >30 year old program in BBx what need to read something outside it's own database. Actually it must be something very simple like

txt$ = read (message.txt) print txt$

However there isn't any documentation available. So my question is: How can i read a plain txt file in to BBx4


Solution

  • simple open the file and read it with READ RECORD

    open (1,err=linenr) "message.txt"    
    read record (1,siz=1,end=linenr) txt$
    

    opens on channel 1, linenr=line to go when there is an error *siz=1 reads 1 character siz=100 reads 100 etc. end where to go when end of file is detected.