Qbasic/Quickbasic & setting environment variables 
Author Message
 Qbasic/Quickbasic & setting environment variables

I have tried on numerous occasions to set a DOS environment variable using
environ$ ... every time I get a message something like "out of memory" ...
can anyone advise me as to how to get around this problem? ... in general,
all I want to do is SET STRING=HELLO, etc. ... easy to do in DOS, but not
within my programs


Tue, 11 Dec 2001 03:00:00 GMT  
 Qbasic/Quickbasic & setting environment variables


: I have tried on numerous occasions to set a DOS environment variable using
: environ$ ... every time I get a message something like "out of memory" ...
: can anyone advise me as to how to get around this problem? ... in general,
: all I want to do is SET STRING=HELLO, etc. ... easy to do in DOS, but not
: within my programs

Well, first the statement is ENVRON, not ENVRON$. ENVRON$ *gets* environment
variables.

Try this:

DIM myVar AS STRING

myVar$ = "QBis = better than BASICA"

ENVIRON myVar$

If that doesn't work, then I would assume that you've run out of environment
space in DOS, or you've been trying to use ENVIRON$.

--

Yours,

** leadGUITARIST for machineDEGENERATE **



Tue, 11 Dec 2001 03:00:00 GMT  
 Qbasic/Quickbasic & setting environment variables
You get "out of enviroinment space" if you try to increase the number of
characters in the environment.

Instead of *adding* an environment variable in your program, change one.

What you can do is assign an environment variable from dos or a batch file
before starting your program. For example .....

SET varname=01234567890123456789

.. will reserve twenty characters you can then change in you program using
ENVIRON$. You can make it smaller if you want, but attempts to make it
larger will result in an "out of environment space" condition.

NOTE: the change will *not* be retained after your program terminates.

--
Michael Mattias
Tal Systems
Racine WI USA

Quote:

>I have tried on numerous occasions to set a DOS environment variable using
>environ$ ... every time I get a message something like "out of memory" ...



Tue, 11 Dec 2001 03:00:00 GMT  
 Qbasic/Quickbasic & setting environment variables
Regarding: Re: Qbasic/Quickbasic & setting environment variables

Quote:
>: all I want to do is SET STRING=HELLO, etc. ... easy to do in DOS, but not
>: within my programs

>Well, first the statement is ENVRON, not ENVRON$. ENVRON$ *gets* environment
>variables.

>Try this:
>DIM myVar AS STRING

     Why?

Quote:
>myVar$ = "QBis = better than BASICA"
>ENVIRON myVar$
>If that doesn't work, then I would assume that you've run out of environment
>space in DOS, or you've been trying to use ENVIRON$.

     I've seen that happen even when I have plenty of environment space
available - eventually, I stopped even trying to use it.  Also, the original
poster should note that any environment variable set by a QB program - if you
can actually manage to set one - will be CLEARED when the program exits!
Apparently, they use local *copies* of the environment, and when the program
exits, that copy of the environment is also shut down.

     IMHO, the ENVIRON keyword is a good idea that just doesn't work.  I've
tried it in QB45 *and* PDS, and it doesn't work in either one.  I gave up on it
years ago.  [Footnote: I just tried your example code in PDS, and that didn't
work either.]



Fri, 14 Dec 2001 03:00:00 GMT  
 Qbasic/Quickbasic & setting environment variables
Re: Qbasic/Quickbasic & setting environment variables

Quote:
>: all I want to do is SET STRING=HELLO, etc. ... easy to do in DOS, but not
>: within my programs.

Remember that any program run in DOS gets a _copy_ of the environment.  Your
(compiled) program can read it with ENVIRON$, but   modifying this copy does no
good because this copy is destroyed when the program terminates.  It is
possible to find the master environment and POKE to it, but it's easy to crash
DOS this way.  I usually resort to a temporary file.

--------------------------------------------------------------------------
--------------
If it's spam, it's a scam.  Don't do business with Net abusers.



Sun, 16 Dec 2001 03:00:00 GMT  
 Qbasic/Quickbasic & setting environment variables
While blathering insanely on Fri, 25 Jun 1999 06:04:36 GMT, Bruce A.
Rhoades scrawled in comp.lang.basic.misc:

Quote:
>I have tried on numerous occasions to set a DOS environment variable using
>environ$ ... every time I get a message something like "out of memory" ...
>can anyone advise me as to how to get around this problem? ... in general,
>all I want to do is SET STRING=HELLO, etc. ... easy to do in DOS, but not
>within my programs

My method is to make a batch file (proggy.bat):

QBASIC /RUN PROGGY.BAS
TEMP

Then in QBASIC, I make the file (temp.bat):

OPEN "temp.bat" for output as #1
PRINT #1, "SET SOUND=P220 I5 D1"
PRINT #1, "PATH %path%;C:\QBASIC"
CLOSE #1

So the batch file is run on exit, and all is fixed. As you can see,
any DOS command can be stuck in there too.

"640K of RAM is all anybody could ever need" - Bill Gates
                                /------------------------
                                |   My  opinions are  not
David Buckley                   |necessarily   in   touch

ICQ: 24444579                   |of the universe, sorry.



Mon, 17 Dec 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Setting the System Path & Other Environment Variables

2. Quickbasic Environment Settings?

3. how to set an environment variable?

4. Is it just me...(Setting Environment Variables)

5. Set Environment Variable?

6. Setting environment variables

7. setting the path environment variable

8. Manually setting referrer environment variable in a webbrowser control

9. how to set an environment variable?

10. setting environment variable ?

11. setting environment variable

12. Set an environment variable in a VB program

 

 
Powered by phpBB® Forum Software