Environment Variables

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Bulwark
Newbie
Posts: 2
Joined: Fri May 05, 2006 3:32 am

Environment Variables

Post by Bulwark »

Win XP Home SP.2 QBasic 4.5

After running the following code why does filenam not appear in the list of Environment Variables please - the path\file do exist.

Code: Select all


cls
shell "if exist c:\windows\system32\eula.txt set filenam=yes"

I = 1
do while environ$(I) > ""
   print environ$(I) 
   I = I + 1
loop

Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

Because shell creates a new local copy of the shell environment, and sets thefilenam variable there.
Then the shell is closed, and the environment for that shell is lost.

To do what you want you have to set the filenam in the same shell as the program is executed in. A batfile to start it works.
I have left this dump.
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations »

Thats what DOS emulation does for you. (because Windows NT based-OSes are not based on DOS, but the NT kernel.)
User avatar
Zim
Veteran
Posts: 98
Joined: Mon Dec 05, 2005 4:31 pm
Location: Wisconsin, USA
Contact:

Post by Zim »

It's done the same thing since DOS version 2.1. I speak from experience.
--- Zim ---
--- Time flies like an arrow, but fruit flies like a banana ---
Bulwark
Newbie
Posts: 2
Joined: Fri May 05, 2006 3:32 am

Thanks to all

Post by Bulwark »

And sorry for the delay in getting back to you.

I couldn't figger out a workaround so now echo to a file to pass the info to the program.

B...
Antoni
Veteran
Posts: 132
Joined: Wed Jun 15, 2005 3:01 pm
Contact:

Post by Antoni »

Just do a batch file that runs the program that changes the environment, then the program that requires the new environment in the same DOS window.
If you close the window the changes will be lost, and they won't affect to a different DOS window.
Post Reply