science@oasys.dt.navy.mil (Zimmermann) (06/17/91)
Help! I need to open a named file from within a HyperCard XFCN (written by me in Think C, running under System 7.0 in HyperCard 2.1), WITHOUT going through a Standard Files Dialog ... can somebody show me an example of a Think C code fragment to do so? Maybe this is trivial (I hope so!), but I can't get it to work without calling SFGetFile() first to get a vRefNum and file name (unless the named file is in the same directory as HyperCard itself -- see below). What am I doing wrong? Specifically, I seem to be having trouble with getting the vRefNum to work right ... I had thought (naively?) that I could use 0 for a vRefNum and provide a file name, and the file would be opened if it was in the same directory as the current HC stack (which I assumed would be the default volume) ... that clearly doesn't work. I tried calling GetVol() with NULL for volName, and that gives me back a vRefNum which seems to correspond to the directory in which HyperCard itself lives (which makes sense, since HC is running the stack which my XFCN is executing from). So, I can open my named file with FSOpen() when it is in the same directory as HyperCard, not a good solution. My attempts to provide a colon-delimited path as part of the fileName given to FSOpen() also have failed. So, any advice? My ultimate goal is to simply find out the vRefNum for the directory in which my stack is stored, and to open a named file in that very directory. Would it work to ask HyperCard to provide me with "the long name of this stack" and then to edit that into shape? But what about the vRefNum that I need to provide FSOpen()?? Tnx for any advice or pointers to relevant info or sample code! ... ^z (Mark Zimmermann, "science@oasys.dt.navy.mil", "zimmermann" on AppleLink) P.S. I am still looking for examples/advice re interapplication communication between HC2.1 stacks and UNIX-like Think C programs ... has anybody actually *done* this yet? tnx -- ^z^z
John_Miller@mindlink.bc.ca (John Miller) (06/19/91)
In article <8474@oasys.dt.navy.mil>, Mark Zimmermann writes > My attempts to provide a colon-delimited path as part of > the fileName given to FSOpen() also have failed. > > So, any advice? My ultimate goal is to simply find out > the vRefNum for the directory in which my stack is stored, > and to open a named file in that very directory. Would > it work to ask HyperCard to provide me with "the long name of > this stack" and then to edit that into shape? But what about > the vRefNum that I need to provide FSOpen()?? If it was a full pathname -- that is, a complete specification including the volume name -- it should work. You don't have to worry about the vRefNum. If it is a full pathname, it is overrides the volume reference number (which is actually a working directory in most cases under HFS). A catch is that you full pathname must fit within 255 characters, a limit that Apple's Tech Notes and DTS group condemn, but not too many paths are longer. Besides, it is a limitation you can share with HyperCard: HyperCard does not like pathnames greater than 255 characters. If you want to remove the 255 character limit, you have to parse the name yourself using routines such as PBGetCatInfo(). You might also consider whether the new callback GetFilePath is appropriate for your needs. It uses HyperCard's search paths, which is useful in some cases. _________________________________________________________________ John Miller (604) 433-1795 Symplex Systems usenet: john_miller@mindlink.uucp Macintosh Consulting and Software Development _________________________________________________________________