LB Booster
« handle variable with files »

Welcome Guest. Please Login or Register.
May 23rd, 2017, 03:09am


Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
LB Umbrella forum
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: handle variable with files  (Read 59 times)
wscbill
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx handle variable with files
« Thread started on: May 17th, 2017, 5:32pm »

Getting the "handle used for incompatible devices" error in LBB when using a handle variable for files. Works successfully in LB.

The situation involves opening an unknown number of files, some of which may need to be open concurrently.

The troubleshooting write-up indicates this error occurs when the same handle is used for file and window, etc. Only files used here.

Some example code that generates the error.

Code:
    fn = fn+1
    hvar$ = "#B" + str$(fn)
    print hvar$
    open "errors1.txt" for input as #hvar$
    line input #hvar$, s$ 
    print s$
    close #hvar$

    fn = fn+1
    hvar$ = "#B" + str$(fn)
    print hvar$
    open "errors2.txt" for input as #hvar$
    line input #hvar$, s$ 
    print s$
    close #hvar$

    end

 
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1167
xx Re: handle variable with files
« Reply #1 on: May 17th, 2017, 6:58pm »

on May 17th, 2017, 5:32pm, wscbill wrote:
Getting the "handle used for incompatible devices" error in LBB when using a handle variable for files. Works successfully in LB.

If it works successfully in LB4 I think that's an anomaly, since my understanding is that handle variables can't be used in an OPEN statement. The correct method is surely to use MAPHANDLE as follows:

Code:
    fn = fn+1
    hvar$ = "#B" + str$(fn)
    print hvar$
    open "\temp\errors.txt" for input as #hvar
    maphandle #hvar, hvar$
    line input #hvar$, s$ 
    print s$
    close #hvar$ 

Richard.
« Last Edit: May 17th, 2017, 7:15pm by Richard Russell » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1167
xx Re: handle variable with files
« Reply #2 on: May 19th, 2017, 3:45pm »

on May 17th, 2017, 6:58pm, Richard Russell wrote:
If it works successfully in LB4 I think that's an anomaly, since my understanding is that handle variables can't be used in an OPEN statement.

Just to confirm that I've checked the LB4 documentation and nowhere is there any suggestion that a handle variable can be used in an OPEN statement: none of the examples show that and the description of the statement only mentions the use of a regular handle.

If the OP's report is correct and you can, at least in some circumstances, use a handle variable this is another example of LB working differently from what the documentation states. I would not consider the usage to be safe, and it does not work in LBB.

The correct, documented, method is to use MAPHANDLE as I showed in my example, which works in both LB 4 and LBB.

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls