Path: utzoo!mnetor!uunet!husc6!cmcl2!nrl-cmf!ames!pasteur!agate!violet.berkeley.edu!edmoy From: edmoy@violet.berkeley.edu Newsgroups: comp.sys.mac.hypercard Subject: Re: the target Message-ID: <7580@agate.BERKELEY.EDU> Date: 10 Mar 88 19:48:15 GMT References: <1011@pur-phy> <24353@felix.UUCP> <24416@felix.UUCP> Sender: usenet@agate.BERKELEY.EDU Reply-To: edmoy@violet.berkeley.edu.UUCP () Organization: University of California, Berkeley Lines: 40 In article <24416@felix.UUCP> john@felix.UUCP (John Gilbert) writes: >Well, it basically works, except when the target file does not yet have >a resource fork. > >I am looking for this, and basically do the following: > > if ( (target = OpenResFile( targetFile )) == -1 ) > { CreateResFile( targetFile ); > if ( ResError() != noErr ) > { > return; > } > else if ( target = OpenResFile( targetFile ) == -1 ) > { > return; > } > } > If this is exactly the code you use, then the problem is in: else if ( target = OpenResFile( targetFile ) == -1 ) You forgot the extra pair of parenthesis, as in else if ((target = OpenResFile( targetFile )) == -1 ) What you were doing is calling OpenResFile() and testing if it was -1. If it was, target was set to 1 (true) and your routine started to do its thing on what every resource file 1 was (maybe the System file). Although I would have expected that OpenresFile() to return a positive number, which doesn't match -1, so target becomes 0 and your routine returns. Edward Moy Workstation Software Support Group University of California Berkeley, CA 94720 edmoy@violet.Berkeley.EDU ucbvax!violet!edmoy