Random file not working with sub
Sept 5, 2008 19:18:50 GMT -5
Post by Psycho on Sept 5, 2008 19:18:50 GMT -5
I have another problem that I'm not sure if it is a bug or not (but seems like it to me).
I have a program using a random access file for storing of data. I initially used a gosub routine to open the file but eventually programmed some subroutines that couldn't access it. I switched it to a sub for opening and a sub for closing and it would not work. I ended up leaving the gosub routine for opening it and writing a redundant sub that could be accessed by other subs. Another problem I had is some of the other subs won't properly access the random access file unless the gosub routine has been run sometime in the program first.
The following simple example should show the problem I'm having. This program works fine in Liberty Basic but gives the following error in RB:
Runtime Error in program 'untitled': put #subtest, x
Invalid handle: #subtest
Thanks for any help.
Psycho
I have a program using a random access file for storing of data. I initially used a gosub routine to open the file but eventually programmed some subroutines that couldn't access it. I switched it to a sub for opening and a sub for closing and it would not work. I ended up leaving the gosub routine for opening it and writing a redundant sub that could be accessed by other subs. Another problem I had is some of the other subs won't properly access the random access file unless the gosub routine has been run sometime in the program first.
The following simple example should show the problem I'm having. This program works fine in Liberty Basic but gives the following error in RB:
Runtime Error in program 'untitled': put #subtest, x
Invalid handle: #subtest
[start]
filepath$="" 'for testing locally
call openfile
for x = 1 to 3
input "First Name ";name$
input "Last Name ";name2$
put #subtest, x
next x
call closefile
call openfile
for x = 1 to 3
gettrim #subtest, x
print name$;", ";name2$
next x
call closefile
[end]
print
print "Thanks, the program is complete."
end
sub openfile
' Open database
open filepath$+"subtest.dat" for random as #subtest len = 20
field #subtest, 10 as name,ドル 10 as name2$
end sub
sub closefile
close #subtest
end subThanks for any help.
Psycho