Path: utzoo!attcan!uunet!cs.utexas.edu!sun-barr!ames!hc!lanl!opus!ksitze From: ksitze@nmsu.edu (Kevin Sitze) Newsgroups: comp.sys.mac.programmer Subject: Re: HELP with _OpenResFile Message-ID: Date: 23 May 89 13:50:51 GMT References: <863@umecs.cs.umu.se> Sender: news@nmsu.edu Organization: NMSU Computer Science Lines: 64 In article: >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: First problem with the code I see right off is: @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 You have to 1) jump over the string, it's not code, it's data. 2) Set you lenght byte as 0x06 (don't have my machine (or memory) handy at the moment but I'm pretty sure that a zero is the first byte here and then comes a 0x06. e.g. memory dump: 0000: 00 06 ...) Second piece of coding: 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 If OpenResFile is incapable of actually opening the file wanted (for whatever reason) then an error code will be returned & placed in refNum. e.g. the code with > in column one is unnecessary. Finally, I expect that the problem lies in the @fileName field. You might check to make sure that there is only _one_ byte before the first letter ('M'). As this field lies directly after the restore-registers at @exit, this will definantly cause problems. (say, various system errors, etc.) Hope this helps (wish I had my mac up & running...) -Kelesi -- ------------------------------------+------------------------------- From the Macintosh of: Kevin Sitze | Disclamer: Who the heck needs | a disclamer? After all, Dan EMail: ksitze%NMSU.edu | Quayle doesn't. SMail: 601 S. Melendres +------------------------------- Las Cruces, NM 88005 | "We have the answers, the ------------------------------------+ trouble lies in finding the "The difference between intelligence| questions..." and stupidity is that intelligence | "The information is there, has a limit." - anonymous | finding it is another story." The dolt confuses you -- more -- | - Any consultant ------------------------------------+-------------------------------