ching@amd.UUCP (Mike Ching) (05/31/86)
I'm having trouble with the following code in Lightspeed C. It
bombs with ID = 2 when run. Can anybody shed some light on what I'm
doing wrong?
#include "Lightspeed:stdio.h"
#include "Lightspeed:MacTypes.h"
#include "Lightspeed:StdFilePkg.h"
main()
{ Point apoint;
SFReply reply;
SFTypeList typelist;
apoint.v = 80;
apoint.h = 80;
typelist[0] = 'TEXT';
typelist[1] = 'WORD';
SFGetFile(apoint, "\p ", (ProcPtr) 0, 2, typelist, (ProcPtr) 0, &reply);
...
}
Mike Ching
{decwrl,ucbvax}!amdcad!amd!ching
gjs@k.cs.cmu.edu (Gregory Stein) (06/03/86)
Keywords: > I'm having trouble with the following code in Lightspeed C. It > bombs with ID = 2 when run. Can anybody shed some light on what I'm > doing wrong? > > #include "Lightspeed:stdio.h" > #include "Lightspeed:MacTypes.h" > #include "Lightspeed:StdFilePkg.h" > main() > { Point apoint; > SFReply reply; > SFTypeList typelist; > > apoint.v = 80; > apoint.h = 80; > typelist[0] = 'TEXT'; > typelist[1] = 'WORD'; > SFGetFile(apoint, "\p ", (ProcPtr) 0, 2, typelist, (ProcPtr) 0, &reply); > ... > } > > Mike Ching > {decwrl,ucbvax}!amdcad!amd!ching > I'm not familiar with Lightspeed C, but it could be that it is passing the entire structure of 'apoint' to SFGetFile. So, the correct call would be: SFGetFile(&apoint, "\p ", (ProcPtr) 0, 2, typelist, (ProcPtr) 0, &reply); In Megamax C, I have to pass all Point's as &pt. This is strange because somewhere in Inside Mac it says points are passed as long values instead of addresses. Who knows? Give the & a try. Greg Stein ARPA: gjs@k.cs.cmu.edu
shebanow@ernie.Berkeley.EDU (Mike Shebanow) (06/04/86)
The only problem with your code is that you are not initializing the necessary Macintosh managers. When you are not using the LightSpeed standard libraries you have to init all of these yourself. The proper calls are: InitGraf(&thePort); InitFonts(); InitWindows(); InitMenus(); TEInit(); InitDialogs(0); InitCursor(); /* this is optional, but nice */ Also, you should avoid including "stdio.h" when you are not using the UNIX style libraries. Just to make sure, I added these lines to your program, and it ran fine. Have fun... Andrew G. Shebanow