Discussion:
Chaining
(too old to reply)
Paul
2003-09-23 16:13:25 UTC
Permalink
I need some help or maybe some example code on how to chain from one exe to
another exe with arrays. I need the arrays public to all the routines and
units within each exe but also need the array to be chained between them. I
just cant seem to be able to get it right as far as DIM or Public or Common
goes as always at the pbc stage i get comile errors.

Any help or an example would be very much appreciated.

Thanks
Lance Edmonds
2003-10-02 14:07:54 UTC
Permalink
Try these example files, Paul...:

The 3 files work like this:
* A.BAS compiles to A.EXE (main executable)
* B.BAS compiles to B.PBU (precompiled unit file)
* C.BAS compiles to C.PBC (chain file)
* Both A.EXE and C.PBC utilize B.PBU.
* The 2 dimension array A() is common COMMON between the CHAIN files
and PUBLIC between the main code and unit code of A.EXE and C.PBC.

I hope it helps!

' A.BAS
$compile exe "a.exe"
$dim all
declare sub x()
$link "b.PBU"
dim a(1:10, 1:2) as string
common a(2)
public a()
print "A=" a(1,2) : a(1,2) = "1"
print "A=" a(10,2) : a(10,2) = "10"
call x
chain "c.pbc"

' B.BAS
$compile unit "b.pbu"
$dim all
dim a(min,2) as string
external a()
sub x() public
print "B=" a(1,2) : a(1,2) = "1"
print "B=" a(10,2) : a(10,2) = "10"
end sub

' C.BAS
$compile chain "c.pbc"
$dim all
declare sub x()
$link "b.PBU"
dim a(min,2) as string
common a(2)
public a()
print "C=" a(1,2) : a(1,2) = "1"
print "C=" a(10,2) : a(10,2) = "10"
call x

I hope this helps. If you have any further questions, please do not
hesitate to ask!

Thanks!
Post by Paul
I need some help or maybe some example code on how to chain from one exe to
another exe with arrays. I need the arrays public to all the routines and
units within each exe but also need the array to be chained between them. I
just cant seem to be able to get it right as far as DIM or Public or Common
goes as always at the pbc stage i get comile errors.
Any help or an example would be very much appreciated.
Thanks
Lance
PowerBASIC Support

-------------------------------------------------------------------------
PowerBASIC, Inc. | 800-780-7707 Sales | "We put the Power in Basic!"
316 Mid Valley Center | 831-659-8000 Voice | http://www.powerbasic.com
Carmel, CA 93923 | 831-659-8008 Fax | mailto:***@powerbasic.com
Loading...