[futurebasic] Re: [FB] saving file locations-make alias?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 2001 : Group Archive : Group : All Groups

From: George Beckman <gbeckman@...>
Date: Fri, 31 Aug 2001 17:05:30 -0700
on 8/30/01 7:57 PM, Peter Dempsey at theviron@... wrote:

> I know that it saves the correct name and refnum (by text checking.. which I
> actually wrote a tiny program to do, and in game checking).  However, later
> when trying to open the scenario (at the begining), the file can't** be
> found (which I know from FN IsFileThere***).  I have a reload function later
> in the program, which re-opens the last file (which would have been opened
> while still in the program) just fine.

This is because the refnum is only good while the file is open.  Alias will
get it.

This is an old routine.  I do believe I ported something much like this to
FB^3


This is a PG project, so I am using STAZ PG global file stuff:
CLEAR LOCAL
DIM osErr
DIM useAlias
DIM RECORD fsSpec
  DIM fsVrefNum%
  DIM fsParID&
  DIM 63 fsName$
DIM END RECORD .fsSpec

DIM myFSSpec.fsSpec
DIM test,OSErr
LOCAL FN SeeAboutAQuickOpen
  
  osErr=FN useAlias(1003,myFSSpec)
  LONG IF osErr=0
    PARENTID=myFSSpec.fsParID&
    CLS
    gFileVol=FN GetWDRefNum(myFSSpec.fsVrefNum%,myFSSpec.fsParID&,@OSErr)
    
    
    gFileName$=myFSSpec.fsName$
    gSaveName$ = gFileName$
    gSaveVol=gFileVol
    
    FN MyOpen
    
    
    % _SFSaveDisk,-myFSSpec.fsVrefNum%
    & _CurDirStore, myFSSpec.fsParID&
    
  XELSE
    
    FN pGbuild(_ItsNotThereWnd)
  END IF
END FN

Here is GetWDrefnum


'--------------------------- Functions ----------------------------------
'----------- START: Font, Size menu routines ----------
_myProcID = _"FWtx"
'-------------------------------------------------
CLEAR LOCAL
DIM iopb.52
DIM OSErr
LOCAL FN GetWDRefNum(volumeID, dirID&,OSErrAddr&)
  'Call as follows:
  '  wdRefNum = FN GetWDRefNum(volumeID, dirID&, @OSErr)
  'Returns a Working Directory Reference Number, given a
  '_true_ volume reference number (volumeID) and a directory
  'ID (dirID&).  The wdRefNum should be used in most places
  'where FB documentation talks about a "volume reference number".
  iopb.ioCompletion& = 0
  iopb.ioNamePtr& = 0
  iopb.ioVRefNum% = volumeID
  iopb.ioWDDirID& = dirID&
  iopb.ioWDProcID& = _myProcID
  OSErr = FN OPENWD(@iopb)
  POKE WORD OSErrAddr&, OSErr
END FN = iopb.ioVRefNum%


And this attempts to set the directory so the next open is in the working
directory...this is the real tricky part and fails if Last File Used By App
is checked in general prefs.  (Not needed if checked as the finder forces
the directory you would have saved in the alias.

CLEAR LOCAL MODE
DIM pBlock.128
LOCAL FN SetFilesFolder(Vref%)
  pBlock.ioVRefNum% = Vref%
  LONG IF FN GETCATINFO(@pBlock) = _NoErr
    & _CurDirStore , pBlock.ioDirID&
    pBlock.ioWDProcID&  = 0
    pBlock.ioWDVRefNum% = 0
    LONG IF FN GETWDINFO(@pBlock) = _NoErr
      % _SFSaveDisk , -pBlock.ioWDVRefNum%
    END IF
  END IF
END FN

I make the alias here.  (I save it in preferences.)

    
    makeAlias=FN makeAlias(gSaveName$,gSaveVol,1003)
    IF makeAlias=_fnfErr THEN BEEP
    FN SetFilesFolder(gSaveVol)

fn makeAlias is a PG fn found in HSF stuff, I think.


-- 
Best Wishes,

George
mailto: gbeckman@...
http://www.pggp.com