[comp.sys.mac.programmer] Inconsistent SysEnvirons declaration in IM?

vallon@sblw.CS.SunySB.EDU (Justin Vallon) (12/07/89)

I have recently tried to use the SysEnvirons trap as described in
IM V, "Compatability".  I have two problems:

1) SysEnvirons' procedure declaration uses SysEnvRecPtr, while the
   discussion uses SysEnvPtr.  Which one is right?

2) I am using LS Pascal 2.0, and have no success in trying to
   compile any of the following:

var x: SysEnvRec;
var x: SysEnvPtr;
var x: SysEnvRecPtr;
... All give undefined symbol (or whatever the error is)
err := SysEnvirons(1, x);
... Gives Type Mismatch if I type in the decl of SysEnvRec/Ptr

Anybody use SysEnvirons from LSP 2.0?

-Justin
vallon@sbcs.sunysb.edu

6600pete@hub.UUCP (12/07/89)

From article <4184@sbcs.sunysb.edu>, by vallon@sblw.CS.SunySB.EDU (Justin Vallon):
> I have recently tried to use the SysEnvirons trap as described in
> IM V, "Compatability".  I have two problems:
> 1) SysEnvirons' procedure declaration uses SysEnvRecPtr, while the
>    discussion uses SysEnvPtr.  Which one is right?
> 2) I am using LS Pascal 2.0, and have no success in trying to
>    compile any of the following:
>    ...

Just use
	err := SysEnvirons ( 1, theWorld );
where theWorld is a SysEnvRec. Apparently LSP 2.0x takes care of the pointer
stuff in glue. Might be interesting to hear how MPW does it.
-------------------------------------------------------------------------------
Pete Gontier   : InterNet: 6600pete@ucsbuxa.ucsb.edu, BitNet: 6600pete@ucsbuxa
Editor, Macker : Online Macintosh Programming Journal; mail for subscription
Hire this kid  : Mac, DOS, C, Pascal, asm, excellent communication skills

siegel@endor.harvard.edu (Rich Siegel) (12/08/89)

In article <4184@sbcs.sunysb.edu> vallon@sblw.CS.SunySB.EDU (Justin Vallon) writes:
>I have recently tried to use the SysEnvirons trap as described in
>IM V, "Compatability".  I have two problems:
>
>1) SysEnvirons' procedure declaration uses SysEnvRecPtr, while the
>   discussion uses SysEnvPtr.  Which one is right?
>
>2) I am using LS Pascal 2.0, and have no success in trying to
>   compile any of the following:

	This sounds suspiciously like a phone call I got this afternoon. :-)

	Inside Mac V is wrong. The interface to SysEnvirons is

	FUNCTION SysEnvirons (version : Integer; VAR env : SysEnvRec) : OSErr;

There is no such type as "SysEnvRecPtr", unless you define it yourself,
and attempting to pass one as a VAR argument to SysEnvirons will result
in havoc.

This necessary function interface and data types are built into THINK Pascal.

R.



~~~~~~~~~~~~~~~
 Rich Siegel
 Staff Software Developer
 Symantec Corporation, Language Products Group
 Internet: siegel@endor.harvard.edu
 UUCP: ..harvard!endor!siegel

"There is no personal problem which cannot be solved by sufficient
application of high explosives."

~~~~~~~~~~~~~~~

jackiw@cs.swarthmore.edu (Nick Jackiw) (12/09/89)

vallon@sblw.CS.SunySB.EDU (Justin Vallon) writes:
> 1) SysEnvirons' procedure declaration uses SysEnvRecPtr, while the
>    discussion uses SysEnvPtr.  Which one is right?

I-M is partially in error. You want to pass a pointer to the data
structure. (A regular pointer, not a Ptr.)  In Pascal, this is done
by apparently passing the entire data structure. See below.

> 2) I am using LS Pascal 2.0, and have no success in trying to
>    compile any of the following:
> 	[Incorrect versions Deleted]
> ... All give undefined symbol (or whatever the error is)
> err := SysEnvirons(1, x);
> ... Gives Type Mismatch if I type in the decl of SysEnvRec/Ptr
> Anybody use SysEnvirons from LSP 2.0?

Yes, try

var theWorld:SysEnvRec;

begin
 if SysEnvirons(1,theWorld)=noErr then
	begin
	  HasCQD:=theWorld.hasColorQD;
	  etc. etc.
	end
end



-- 
     _  _|\____    Nick Jackiw | Visual Geometry Project | Math Department
   / /_/   O>  \   ------------+-------------------------+ Swarthmore College
   |       O>   |  215-328-8225| jackiw@cs.swarthmore.edu| Swarthmore PA 19081
    \_Guernica_/   ------------+-------------------------+                 USA