Dynamic linking in QBasic?

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
angros47
Veteran
Posts: 79
Joined: Mon Sep 08, 2008 12:52 pm
Contact:

Dynamic linking in QBasic?

Post by angros47 »

Is there a way to dynamically link a library in QBasic, like it has been done in Seal?

The idea is:

main program:

Code: Select all

call LibEntryPoint
Library 1:

Code: Select all

SUB LibEntryPoint
PRINT "this is library 1"
Library 2:

Code: Select all

SUB LibEntryPoint
PRINT "this is library 2"
And, at runtime, I wish to be able to unload library 1 and load library 2.

Can it be done (maybe using overlays)?
Thanks
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

I've never heard of unloading a Library. Why would you need to?
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
angros47
Veteran
Posts: 79
Joined: Mon Sep 08, 2008 12:52 pm
Contact:

Post by angros47 »

I was thinking about a sort of cooperative multitasking in qb (in a way similar to Seal, but made in QB). To load multitasking programs, I'd need dynamic linking, and also pointers and callbacks.

Has anyone ever tried something similar? I know about Gimi, and others multitasking systems in QB using scripts, but could be done using real machine code instead of an interpreted script?
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

No...there is no way to do this with traditional QB. QB PDS has something sort of what you're looking for, but it's not exactly the same.
angros47
Veteran
Posts: 79
Joined: Mon Sep 08, 2008 12:52 pm
Contact:

Post by angros47 »

Can be done in QB PDS? How? Can you tell me more?

Thanks
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

The only way that I can think of is to use 2 separate modules. Each runs one Library using RUN or CHAIN.

CLEAR clears all variables and closes all open files.

Whether RUN or CHAIN can close one is questionable. I'll ask if it is possible and can be proven somewhere else.

I still don't see the big deal however.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
angros47
Veteran
Posts: 79
Joined: Mon Sep 08, 2008 12:52 pm
Contact:

Post by angros47 »

I was thinking...

Maybe it could be done using TSR with some "tweaks"...

I.E. every application is a TSR, the "kernel" manages the GUI and calls interrupts to activate single apps, and a segment of ram is used as "interface" (if an application has to open a window, it leave a message in the common area, and the kernel read it and open the window).
In that way, I will also be able to mix programs written in QB and in other languages.

Do you think that it could work?

I've downloaded tsrv21.zip, but there is no doc. Of course I'm not going to buy external libraries. Does anybody know how to make a TSR that is not enabled by hitting a key, but by using (for example) a POKE in a qb program?

Thanks
Post Reply