[comp.lang.pascal] Enviroment variables

marcos@caus-dp.UUCP (Marcos R. Della) (12/31/87)

I had a routine that scanned the current enviroment getting its location
buffer from [CSEG:$002C] (I think that was the location. No code in front
of me, just memory) and it no longer works as my program is over 64K and
I have no idea what the CSEG will be at the time of program execution nor
can I name any of the files that are at the first CSEG. Does anyone have
a clue as to how to get this information so that I can again read the 
enviroment variables under TP4.0?

Marcos R. Della

-- 
...!csustan ->!polyslo!caus-dp!marcos               | Whatever I said doesn't
...!sdsu ---/   Lt. Marcos R. Della                 | mean diddly as I forgot
...!csun --/    Smail:PO Box 8104 SLO,CA 93403-8104 | it even before finishing
...!dmsd -/     Tele: (805) 544-4900                | typing it all out!!! :-)

toma@killer.UUCP (Tom Armistead) (01/06/88)

In article <340@caus-dp.UUCP>, marcos@caus-dp.UUCP (Marcos R. Della) writes:
> ...
> buffer from [CSEG:$002C] (I think that was the location. No code in front
> of me, just memory) and it no longer works as my program is over 64K and
> I have no idea what the CSEG will be at the time of program execution nor
> can I name any of the files that are at the first CSEG. Does anyone have
> a clue as to how to get this information so that I can again read the 
> enviroment variables under TP4.0?
> 
> Marcos R. Della

What you really need to point to the Environment is PSP:$002C, it just so 
happened that in a COM file PSP and CSEG are the same, this is not the case 
in an EXE file. TP 4.0 has a variable call PrefixSeg which holds the segment
of the PSP, so something like this would work now:
var
  EnvPtr : pointer absolute PrefixSeg:$002c;

should do it for you, look at page 295 in your Turbo Pascal 4.0 manual...

Tom

-- 
-------------
Tom Armistead
UUCP:  ...!ihnp4!killer!toma