Path: utzoo!attcan!uunet!mcvax!kth!draken!umecs!zeus.umu.se!dvlmfs From: dvlmfs@zeus.umu.se Newsgroups: comp.sys.mac.programmer Subject: HELP with _OpenResFile Message-ID: <863@umecs.cs.umu.se> Date: 23 May 89 07:16:24 GMT Sender: news@umecs.cs.umu.se Reply-To: dvlmfs@zeus.umu.se () Organization: Dep. of Inform.Proc.,University of Umea,Sweden Lines: 74 I've got a big problem with an INIT I'm writing so I thought that maybe someone out on the net could help me with this problem or explain why it doesn't work. All I'm trying to do is to open my files' resources from the patch code so I can use the resources that I've made, but this doesn't work and I dont know why! It's written in LSC 3.0 and looks like this: main() { asm { . ;from here I patch traps and move code - . ;into the "right" place . ;here comes the pure code @patchstart movem.l a0-a1/d0-d3,-(sp) ;save registers clr.w -(sp) ;clear for result pea @fileName ;push adress of fileName _OpenResFile ;trap call move.w (sp)+,d3 ;save result in d3 clr.w -(sp) ;clear for result _ResError ;trap call move.w (sp)+,d0 ;get result from _ResError tst.w d0 ;check if it's equal to noErr bne @error ;if error has occured - ErrorAlert . . . jmp @exit ;jmp over error @error move.w #0x000A,-(sp) ;push 0x000A for _SysBeep _SysBeep ;trap call @exit movem.l (sp)+,a0-a1/d0-d3 ;restore registers @fileName dc.b 0x0006 ;length byte of Str255 dc.b 'M','y','F','i','l','e' ;the file name @patchend } /* end asm */ } /* end main */ The error this program generates is ( according to _ResError ) an OSErr (tmfoErr) equal to -42 and it stands for 'too many files open' !!! It is _OpenResFile that generates this error and I don't know what I shall do with it. Could someone please point out the problem with this code ! If I do something similar in pure C it works! main() { int refNum; . . . refNum = OpenResFile("\pMyFile"); if (ResError()) DebugStr("\pOpenResFile"); . . . } This code doesn't generate an error so the ResError statement never occurs. I have compared theese two programs in TMON and they look the same BUT the first ( and most important ) program doesn't work. Please correct what I'm doing wrong and explain to me what I shall do. Thanks in advance. Michael Forzelius dvlmfs@cs.umu.se