Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!orca!javelin.es.com!bgeer From: bgeer@javelin.es.com (Bob Geer) Newsgroups: comp.lang.pascal Subject: Re: Change ENV. Message-ID: <1991Jan14.143941.10541@javelin.es.com> Date: 14 Jan 91 14:39:41 GMT References: <25474@adm.brl.mil> Reply-To: bgeer%javelin@dsd.es.com Organization: Evans & Sutherland Computer Corp., Salt Lake City, Utah Lines: 62 ZCCBJSB%EB0UB011.BITNET@cunyvm.cuny.edu ( Info-Pascal list) writes: >Has anyone some code/idea to modify PERMANENTLY a DOS environtment >variable from a TP program (any TP version)? Each program run gets a new copy of the environment of the current program. For example, any changes to the environment of, say, a batch program doesn't make its way to the previous copy so is lost when the batch program terminates. Those changes only propogate to programs run from the batch file, or programs they subsequently run. Dr. Dobb's Journal #122 (December 1986) contained an article about MS-DOS' undocumented interrupt 2Eh which will change the `master' copy of the environment but not any copies already propogated from it. Below I've included a procedure fragment that I use to edit the path string. The string handed to 2Eh must be formatted in the DOS style: length byte, string, , . The environment must be sufficiently large to accept the string; I found I had to limit my path string to 127 bytes (with standard size environment space) to prevent hanging DOS. This has worked for me from DOS 2.0 thru DOS 4.01, but MS doesn't guarantee undocumented interrupts. I didn't want to soak up bandwidth by including the whole program, & I'm unsure of my ability to send or receive e-mail. --------------------------------------- { new_path is type PATH, defined as follows: } PATH = RECORD CASE BOOLEAN OF TRUE : (str : STRING[255]) ; FALSE : (bytes : ARRAY [0..255] OF BYTE) ; END ; { path } { MY_SP, MY_SS, TMPDS, TMPSI are integers } new_path.str := CONCAT('SET ', path_str.str) ; new_path.bytes[1+LENGTH(new_path.str)] := CARRIAGE_RETURN ; new_path.bytes[2+LENGTH(new_path.str)] := NULL ; WRITELN ('Setting path to:') ; WRITELN (new_path.str) ; TMPDS := SEG(new_path) ; { path command segment for dos } TMPSI := OFS(new_path) ; { path command offset for dos } INLINE ($1E/ { push ds ; save environment } $55/ { push bp ; " } $2E/$8E/$1E/TMPDS/ { mov ds,cs:TMPDS ; prepare for fn } $2E/$8B/$36/TMPSI/ { mov si,cs:TMPSI } $2E/$8C/$16/MY_SS/ { mov cs:MY_SS,ss ; save stack seg } $2E/$89/$26/MY_SP/ { mov cs:MY_SP,sp ; & stack ptr } $CD/$2E/ { int 2e ; call msdos } $2E/$8E/$16/MY_SS/ { mov ss,cs:MY_SS } $2E/$8B/$26/MY_SP/ { mov sp,cs:MY_SP } $5D/ { pop bp } $1F) ; { pop ds } { continue pascal code here } ---------------------------------------- -- <> Bob `Bear' Geer <> bgeer@javelin.sim.es.com <> <> Alta-holic <> speaking only for myself, one of my many tricks <> <> Salt Lake City, <> "We must strive to be more than we are, Lal." <> <> Ootah <> -- Cmdr. Data, learning schmaltz <>