Re: opening a file as random and setting the argument "len" with a variable?
- If your file has different size records, it can not be random.
Therefore your file must be sequential.
To find the longest record size in a sequential file,
open the file for input and read in all records using line input
and use the len() function to find the longest length record.
--- In libertybasic@y..., JCseven@a... wrote:
> Is there a way to set the argument "len" with a varialbe? I tried
> doing this as shown below and I get a syntax error. I am trying to
> figure out a way to open the file, determine the longest line, and
> then set num to its length. As shown below, I set len to num, but
> this will not work. Is there a way to do this, or does the
> len have to be set with an actual whole number?
> num = 28
> open "c:\lb202w\first.txt" for random as #1 len = num
> field #1, 13 as comp$, 10 as rt$, 5 as conc$
> while eof(#1) <> -1
> gettrim #1, i
> comp$(i) = comp$
> rt(i) = val(rt$)
> conc(i) = val(conc$)
> close #1