home *** CD-ROM | disk | FTP | other *** search
- (*
- Timo Salmi UNiT ENV
- A Turbo Pascal unit of file environment handling routines
- All rights reserved 8-Feb-92, 13-Jun-92, 20-Aug-92
-
- This unit may be used and distributed freely for PRIVATE, NON-COMMERCIAL,
- NON-INSTITUTIONAL purposes, provided it is not changed in any way. For
- ANY other usage, such as use in a business enterprise or a university,
- contact the author for the terms of registration.
-
- The units are under development. Comments and contacts are solicited. If
- you have any questions, please do not hesitate to use electronic mail for
- communication.
- InterNet address: ts@uwasa.fi (preferred)
- Bitnet address: SALMI@FINFUN.BITNET
-
- The author shall not be liable to the user for any direct, indirect or
- consequential loss arising from the use of, or inability to use, any unit,
- program or file howsoever caused. No warranty is given that the units and
- programs will work under all circumstances.
-
- Timo Salmi
- Professor of Accounting and Business Finance
- Faculty of Accounting & Industrial Management; University of Vaasa
- P.O. BOX 297, SF-65101 Vaasa, Finland
-
- Added 13-Jun-92
- SETENVSH
- *)
-
- unit TSUNTENV;
-
- (* ======================================================================= *)
- interface
- (* ======================================================================= *)
-
- uses Dos;
-
- (* Get the size of the parent environment. Draws very heavily on the
- article in the PC Magazine Vol. 11, No. 1, pp. 425-427, but also
- includes some programming of my own *)
- function ENVSIZFN : word;
-
- (* Get the size of the parent environment that is already used up.
- This part of the environment code is primarily due to yours
- truly, and is based on the format of the environment table which
- is name=value1<nul>name=value2<nul>...name=valueN<nul><nul> *)
- function ENVUSEFN : word;
-
- (* Get the starting segment address of the parent environment. Draws very
- heavily on the article in the PC Magazine Vol. 11, No. 1, p. 425-427,
- but also includes some ideas of my own.
- Returns 0 if the address cannot be found *)
- function ENVADDFN : word;
-
- (* Set the value of an environment variable. Note that the name of
- the environment variable is CASE SENSITIVE. E.g. you can put
- both COMSPEC and comspec in your environment. (Don't.)
- Use upper case throughout to be on the safe side.
- This part of the environment code is solely my own (un)doing.
- Status values:
- 0 = No errors detected
- 1 = Syntax error (Correct syntax: VARIABLE=VALUE)
- 2 = Out of environment space
- 3 = Missed the variable or the environment
- Note that this takes effect only after the program has terminated!
- Also note that any trailing white spaces are included:
- 'VARIABLE=VALUE' and 'VARIABLE=VALUE ' are not the same thing.
- *)
- procedure SETENV (EnvVar : string; var status : byte);
-
- (* Write the parent environment table on stdout *)
- procedure SHOWENV;
-
- (* Set a temporary value for an environment variable.
- SETENVSH should take effect for the duration of shelling to dos.
- This was a complicated task with parts of code scraped from
- here and there so be a bit wary.
- Everything is made upper case.
- Note the slightly differing syntax from SETENV.
- *)
- procedure SETENVSH (envvar, envval : string);
-