Passing Variable (Information) Between Programs

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
MattC
Posts: 114
Joined: Mon 16 Apr 2018, 06:17

Passing Variable (Information) Between Programs

Post by MattC »

Hi,

What's the best way to pass information between one program and another? For instance, if one program collects information and the user, through the first program, opens a second program (not a second instance), what's the best/easiest way to transfer any relevant information through to the second one?

Matt
DDRM

Re: Passing Variable (Information) Between Programs

Post by DDRM »

Hi Matt,

Have a look at CHAIN in the manual.

The obvious and simple answer is to write the data to a temporary file, and then read it in again.

CHAIN doesn't clear the static variables, so you could pass ~26 values that way....

Otherwise you could lower HIMEM and use the space above it as a data block, into which you can write data, and subsequently read it, using indirection operators. Not for beginners, but you aren't a beginner! ;-)

Re-reading your post, it sounds as though the programs might be running at significantly different times. In that case, I'd have thought writing a data file to disk is the obvious answer.

D
MattC
Posts: 114
Joined: Mon 16 Apr 2018, 06:17

Re: Passing Variable (Information) Between Programs

Post by MattC »

Thanks D.
DDRM wrote: Sun 13 Mar 2022, 09:51 The obvious and simple answer is to write the data to a temporary file, and then read it in again.
This is the normal method I've used in the past, usually to save information both between and within programs, rather than using memory to store information. I've pretty much always stored records in files automatically whenever they are changed - hence one of my other threads regarding renaming a temp file. However, I was hoping for something more 'appropriate'.
DDRM wrote: Sun 13 Mar 2022, 09:51 you could lower HIMEM and use the space above it as a data block
I'll have to look into this as it's something I've never played with.
DDRM wrote: Sun 13 Mar 2022, 09:51 Not for beginners, but you aren't a beginner!
You seem to have more faith in my programming that I have ;)
DDRM wrote: Sun 13 Mar 2022, 09:51 it sounds as though the programs might be running at significantly different times
Possibly, but not necessarily. One of the program sets I was playing with (and I use the word 'playing' deliberately) was one that uses programs that sit in the approx 32kB limit that the old BBC MICRO B used to have. However, this would necessarily require splitting the program up into smaller programs that 'chained' from one to another, but would require common but changeable data sets. The main things that need immediately transferring from one to the next are the settings, so either a settings file or the HIMEM usage seems reasonable options. As I say, this is more of an experiment than anything else.

Matt