Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!apple!hercules!sparkyfs!ads.com!potomac!jtn From: jtn@potomac.ads.com (John T. Nelson) Newsgroups: comp.sys.mac.programmer Subject: Can't seem to get SFGetFile to work....! Message-ID: <9183@potomac.ads.com> Date: 22 Sep 90 17:52:34 GMT Organization: Advanced Decision Systems, Arlington VA Lines: 81 This is going to sound ike a truly naive' question but I've been over and over the problem and I can't seem to find where I'm going wrong. Maybe it's someplace I'm not looking. Here's the problem. The very first thing I do in a program is call a function I call "selectFile" which is basically a shell wrapped around SFGetFile.... #include #include #include #define FILE_NAME_SIZE 30 #define DEFAULT_DIALOG_X_POS 100 #define DEFAULT_DIALOG_Y_POS 100 FILE *fi, *fo; char buffer[128]; char fileName[FILE_NAME_SIZE + 1]; main() { char sourceFile[FILE_NAME_SIZE + 1]; selectFile(sourceFile); . . . } Well the call to selectFile causes a Bus Error right on the SFGetFile and I can't figure out why. I've checked with other Macintosh books ("Using the Macintosh ToolBox with C", "Macintosh Revealed" and even "Inside Macintosh") and the call looks kosher. Problem is that even the above three references vary on what they say should go into SFGetFile. By the way I'm using Lightspeed C with MacHeaders turned on and the ANSI/unix/MacTraps libraries and it all compiles and links perfectly. selectFile looks like this.... selectFile(char *name) { char fName[FILE_NAME_SIZE + 1]; Point position; int numTypes; OSType tList; /* Was SFTypeList */ SFReply reply; int workingVrefNum; Str255 prompt; numTypes = -1; SetPt(&position,DEFAULT_DIALOG_X_POS,DEFAULT_DIALOG_Y_POS); tList = '????'; SFGetFile(position, "\p", 0L, numTypes, &tList, 0L, &reply); workingVrefNum = reply.vRefNum; SetVol(0L,reply.vRefNum); if ( reply.good ) { strcpy(fName, (char *) reply.fName); PtoCstr(fName); strcpy(name, fName); } } Help! -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ORGANIZATION: Advanced Decision Systems GEOGRAPHIC: Arlington, VA UUCP: kzin!speaker@mimsy.umd.edu INTERNET: jtn@potomac.ads.com SPOKEN: Yo... John! PHONE: (703) 243-1611 PROJECT: The Conrail Locomotive/Harpsichord Fusion Program =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=