Search code examples
basic

Understanding of BASIC code


I need to read some basic code. I never worked with BASIC and ask you help me. There is such code

filedialog "Open","*.txt",file$
 if file$="" then end
open file$  for input as #f
'open "g:\data\funcfirstques.txt" for input as #f

while not(eof(#f))
  line input #f, a$
  i=i+1
wend
close #f
nrows=i

open "g:\data\junk.txt" for output as #1
print#1, a$
close #1

open "g:\data\junk.txt" for input as #1
while not(eof(#1))
input #1, b$
k=k+1
wend
close #1

As I understood, here is opening file file$, then in first loop, counting lines in this file and adding they to array a$. Then opening file junk.txt and writing array a$ to this file. But what is doing in second loop? What is the k?

Input is usual .csv file.

Thanks.

P.S Sorry for my awful English :)


Solution

  • Its reading the file

    As you know from this

    open "g:\data\junk.txt" for output as #1
    print#1, a$
    close #1
    

    like open for OUTPUT and PRINT #

    similarly this...

    open "g:\data\junk.txt" for input as #1
    while not(eof(#1))
    input #1, b$
    k=k+1
    wend
    

    is reading the file back IN byte by byte.