Board index » delphi » Dos Set variable

Dos Set variable

  Is there a way to read the variable set with the set command in a bat
file.  Like for example reading the following path
set sfpath=c:\misc\sf
--

*************************************************************************

 

Re:Dos Set variable


In article <52e888$...@alpha.delta.edu>,
Jeremy Jon Kettelhohn <jjket...@alpha.delta.edu> wrote:
:  Is there a way to read the variable set with the set command in a bat
:file.  Like for example reading the following path
:set sfpath=c:\misc\sf

For getting an environment variable see the keyword GetEnv in your
manual. For setting one please see below.

-From: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip Frequently Asked TP Questions
-Subject: Assigning environment variable values

30. *****
 Q: How can I assign a value to an environment variable in TP?

 A: For assigning a value to (a parent process's) environment value
you have to access and manipulate the Program Segment Prefix and
Memory Control Blocks. This is a rather complicated undertaking. A
source code with an accompanying article by Trudy Neuhaus can be
found in PC Magazine Volume 11 Number 1 pages 425-427.
   The budding TP programmers should note that the elementary trick
of Exec (GetEnv('comspec'), '/c set key=whatever') will achieve only
a transient result for the duration of the exec shell. When you exit
the shell after this endeavor, the environment will be as it was.
   Here is about the why. When the above command is executed, MS-DOS
makes a copy of the environment, and uses the copy. When the above
shelling terminates, the copy of the environment is deleted, and the
original is restored. Hence the above trick cannot be used to change
the parent environment.
   If you don't want to try to go through this rather complicated
task yourself, the routines
 "SETEVN   Set a parent environment variable (variable=value)"
 "SETENVSH Set an environment variable for the duration of shelling"
can be found in my TP TPU collection ftp://garbo.uwasa.fi/pc/ts/
tspa35*.zip (* = 40,50,55,60,70). No source code is included, nor
available for tspa35. However, there is a TPENV section within
ftp://garbo.uwasa.fi/pc/turbopas/bonus507.zip. From z...@tcscs.com
Gregory Young{*word*76}: For a source code see /pc/source/setenv.zoo at
Garbo.
   One further detail. Users sometimes ask how one can change the
prompt or the path from within a Turbo Pascal program. This is in no
way different from changing the value of any other environment
variable. Both PATH and PROMPT are environment variables that can be
set with the MS-DOS SET command in the fashion described in the
above. This is not changed in any way by the fact that you can apply
PROMPT and PATH also in an alternative format not requiring the SET
command.
--------------------------------------------------------------------

   All the best, Timo

....................................................................
Prof. Timo Salmi   Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa
mailto:t...@uwasa.fi  <URL:http://uwasa.fi/~ts>  ; FIN-65101,  Finland

Re:Dos Set variable


jjket...@alpha.delta.edu (Jeremy Jon Kettelhohn) wrote:

Quote
>  Is there a way to read the variable set with the set command in a bat
>file.  Like for example reading the following path
>set sfpath=c:\misc\sf
>--
>*************************************************************************

Check your reference manual for the "EnvStr" function and the
associated functions.
---
Roger Gariepy                            Be :-) even if you feel :-(
email: rgari...@rocler.qc.ca
Je parle Francais.

Other Threads