CHAIN command not working - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: CHAIN command not working (/showthread.php?tid=746) Pages:
1
2
|
RE: CHAIN command not working - TempodiBasic - 08-12-2022 (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! ... 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 Code: (Select All) ' program 2 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 Code: (Select All) ' program 4 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 RE: CHAIN command not working - SpriggsySpriggs - 08-31-2022 Hi, there. Just thought I'd share my two cents. We discourage the use of CHAIN as it just uses a text file to read into the spawned program. However, using some sample code that I've written before, you can share memory between two programs in Linux and Windows. I will answer any questions someone might have about sharing variables between programs. RE: CHAIN command not working - SpriggsySpriggs - 08-31-2022 As a matter of fact, you can also just send and receive messages between two processes. Attached is some sample code. The "loremipsum.txt" is just used as data for the send and receive. RE: CHAIN command not working - TempodiBasic - 09-01-2022 (08-31-2022, 01:28 PM)Spriggsy Wrote: Hi, there. Just thought I'd share my two cents. We discourage the use of CHAIN as it just uses a text file to read into the spawned program. However, using some sample code that I've written before, you can share memory between two programs in Linux and Windows. I will answer any questions someone might have about sharing variables between programs. Hi Spriggsy, very fine to see you. 1. Yes I can confirm that the way of sharing data between 2 programs proposed by Spriggsy is very functional ( I tried successful it at the time of QB64.org) I find interesting that the method has been shipped also to Linux SO. 2. I haven't yet tried to send and receive messagges between 2 programs on fly. But I think to try this as soon as I have time to learn (time with mind rested) RE: CHAIN command not working - Udix - 11-01-2022 Hi, ok, you guys - ok,ok you convinced me - i might do it via a database, stuff it into a file and extract it from there. And besides - why not put it all in just ONE file? Yeah .... Thanks. Udix |