• Please review our updated Terms and Rules here

DOS Environment Variables: Use for other purposes?

mmruzek

Experienced Member
Joined
Sep 28, 2011
Messages
213
Location
Michigan, USA
Hi, I am doing some coding in GW-Basic for an XT compatible running DOS 3.3. I have a program that parses latitude and longitude from a GPS module connected to the COM port. I would like store the location information in the DOS system enviroment such that the location is available to other GW-Basic programs when they are run. So basically I would like to have global variables in DOS.

My first thought was to either try to define new environment variables in DOS, or re-purpose exising environment variables for my own purposes. (Hopefully that the system would not notice I am using!) Unfortunately I see the list of standard environment variables is pretty darn short. Any ideas for this path?

Another thing I could do is reserve some memory with a short TSR that 'protects' some area of memory that I access with PEEKs and POKEs. In that case I would need to reliably know where the TSR is loading in memory.

I'm guessing there are some other ways to do this. I would appreciate your thoughts and ideas! Thanks. Michael
 

Robbbert

Experienced Member
Joined
Jan 10, 2019
Messages
355
Just make up as many as you need.

SET MYVAR=PARAM1
SET ANOTHERVAR=PARAM2

There's a limit to the amount of space allocated to variables, which can be adjusted in your config.sys file. (I forgot the exact setup of that)
 

Eudimorphodon

Veteran Member
Joined
May 9, 2011
Messages
5,433
Location
Upper Triassic
There's a limit to the amount of space allocated to variables, which can be adjusted in your config.sys file. (I forgot the exact setup of that)

I think you need to do it with the "SHELL" command definition, IE:

SHELL=C:/COMMAND.COM /E: (number of bytes to reserve)
 

GeoffB17

Experienced Member
Joined
Jun 8, 2016
Messages
496
Location
Guisborough, England
Yes, that is correct. The number overrides the normal default. The new number can be anything. The manual for MSDOS 5 suggests /E:512, but I've used /E:1024 on occasions. Windows machines have MUCH bigger needs, i.e. numerous long paths.

As already stated, you can create as many Env Vars as you need.

If you CREATE an Env Var within your program, then it will work fine while you're IN the prog, and in any prog that your prog calls, but when you exit the prog that created the Env Var then the Env Var may vanish. Therefore, create your special Env Vars within a .BAT file which then calls your prog, or create them globally in say AUTOEXEC.BAT and they will be permanent. And visible to everything.

Geoff
 

mmruzek

Experienced Member
Joined
Sep 28, 2011
Messages
213
Location
Michigan, USA
Thank You! Makes total sense... define the environment variables in DOS using a batch file, and then I can update them from inside the GW-Basic program using the ENVIRON statement. Thanks! Michael
 
Last edited:

GeoffB17

Experienced Member
Joined
Jun 8, 2016
Messages
496
Location
Guisborough, England
Hm, I'm wrong!

When your prog starts, it inherits a COPY of the Env Vars. Your prog then changes the details in the COPY. When your prog finishes, the copy is discarded.

But I think I've done something like you want to do.

Can you create the initial BASIC prog so that it calls all the subsequent progs, then the Env settings remain constant. In QB this uses the SHELL command. Not sure if CHAIN is similar, but if you CHAIN you can pass any BASIC vars using COMMON.

Maybe less complicated if your original prog creates a little .TXT file, and LOADS/SAVES the data, just like Env Vars, and each subsid prog does the same. This may have an extra advantage that the data is retained between sessions, and while the computer is off

Geoff
 

Plasma

Veteran Member
Joined
Nov 7, 2005
Messages
1,558
Another option is an unused portion of the BIOS Data Area. There are at least 16 bytes available at 0000:04F0 ("Intra-Applications Communications Area"). On most XTs you can probably use 0000:04B0 to 04FF.
 
Top