CHAIN command not working
#11
(08-09-2022, 06:09 AM)Pete Wrote: Back in the good ol' QJurassic Period, I put 14 programs together using a database file (what Steve was getting at) to transfer the data to each new program that was run from the main program. I never used CHAIN. I thought it was sucky and if I remember right, it had some limitations with stand-alone exes. So basically, you could say I yanked my CHAIN. I know Steve would happily put it that way!

Pete

...
using CHAIN to transfer the data from a program to another.... I miss the point, friend
CHAIN , like RUN, invokes a program and quit the invoking program.
The main difference and so the main advantage is to be able to transfer data from the invoking program to the invoked program... but it can be used just to run a program quitting the invoking program.

I think that the original reason to implement a CHAIN is just avoid the overflow (out of memory) error that it brings to crashing the program and loosing the data into it.
So in Qbasic using a memory stack pointed by the COMMON SHARED section in both the program files, the data present in the first program pass to the second program.
If Qbasic had had pointers (like C) the work would be done by them.

However
CHAIN needs 2 files .BAS or 2 files .EXE
please load into QB64 IDE these 2 files and pres f11 for each one, then go to the folder of QB64 (or where you have saved the 2 file .EXE) and click on PR1.EXE
Code: (Select All)
' program 1

Print "Hi, I'm the first to running"
Chain "Pr2.bas"

Code: (Select All)
' program 2

Print "Hi, I'm the second to running"
Print "Before me it runs Pr1.bas"

it seems to me that CHAIN have worked well.

Going deeper  we can add the COMMON area of data
we add a COMMON area of data to the two previous programs with output instructions to show the passed data.

Code: (Select All)
' program 3
Common a As Integer, b As Single, c As String
a = -11: b = 1.55: c = "QB64"
Print "Hi, I'm the first to running"
Print " I pass these values to Pr4.bas"
Print a, b, c
Print "Goodbye"
Chain "Pr4.bas"

Code: (Select All)
' program 4
Common integ As Integer, singl As Single, stri As String

Print "Hi, I'm the third to running"
Print "I get from Pr3.bas these values"
Print integ, singl, stri

as for the previous experiment, load code into data, save Program 3 as Pr3.bas, Program 4 as Pr4.bas
load each program into QB64 IDE and press F11.  At the end you go at folder of .EXE and run (doubleclick?) on Pr3.exe

Looking at results I must say that also in this case It works doing its job.

The only 2 rules that we must apply are:
1.-        .BAS with .BAS    or .EXE with .EXE  naturally both files must be in the same folder
2.-        if you use COMMON/ COMMON SHARED data the kind of data must be the same number in the same order in all file that use that COMMON area of data.

These my two cents
Reply


Messages In This Thread
CHAIN command not working - by TerryRitchie - 08-08-2022, 04:02 AM
RE: CHAIN command not working - by bplus - 08-08-2022, 03:00 PM
RE: CHAIN command not working - by mdijkens - 08-08-2022, 03:28 PM
RE: CHAIN command not working - by mnrvovrfc - 08-08-2022, 10:47 PM
RE: CHAIN command not working - by Kernelpanic - 08-08-2022, 04:04 PM
RE: CHAIN command not working - by TerryRitchie - 08-08-2022, 08:07 PM
RE: CHAIN command not working - by Kernelpanic - 08-08-2022, 08:56 PM
RE: CHAIN command not working - by TerryRitchie - 08-08-2022, 09:25 PM
RE: CHAIN command not working - by SMcNeill - 08-08-2022, 11:34 PM
RE: CHAIN command not working - by Pete - 08-09-2022, 06:09 AM
RE: CHAIN command not working - by TempodiBasic - 08-12-2022, 05:35 PM
RE: CHAIN command not working - by TempodiBasic - 09-01-2022, 12:13 AM
RE: CHAIN command not working - by Udix - 11-01-2022, 01:31 PM



Users browsing this thread: 4 Guest(s)