FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DISK I/O

Use NewAlias


NewAlias is not included in the text file of supported toolbox calls just posted, but it auto capitalizes in a program, so I assume it is actually built in?

When I try to use it I get the error about assigning a value to this variable doesn't make sense.

err = FN NEWALIAS(relativeSpec,targetSpec,aliasHandle&)

The first variable gets flagged. I tried passing "0", because i don't want a relative spec. I tried a couple of other things that didn't work, either.

What is the correct way to call this, if it is indeed built in?

Larry


I can't see your dimension statments, so I have no way of knowing which thing went wrong in your code, but I would suspect that your FSSpecs were dimensioned as records. You would therefore need to use...

err = FN NEWALIAS(relativeSpec.nil%,targetSpec.nil%,aliasHandle&)

STAZ ~)~


Here is the whole thing, so you can see the fileSpec being set up and manipulated.

CLEAR LOCAL
  DIM fSpec;0,fVRefNum,fParID&,63 fName$
LOCAL FN makeAlias(fName$,fVRefNum,resID)
'---------------------------------------
' Make and save an alias.
'---------------------------------------
  DIM makeAlias,fromFile,aHndl&
  fromFile = 0
  fParID& = FN getParID(fName$,fVRefNum)
  LONG IF FN NEWALIAS(fromFile,fSpec,aHndl&)
    makeAlias = _fnfErr
  XELSE
    FN pGreplaceRes(aHndl&,_"alis",resID,fName$)
    makeAlias = _noErr
  END IF
END FN = makeAlias

Note that FN NEWALIAS must return 0 to be healthy.

This one:

fParID& = FN getParID(fName$,fVRefNum)

prepares the file spec for you.

CLEAR LOCAL MODE
LOCAL FN getParID(fName$,fVRefNum)
'---------------------------------------
' Return a folder's parent ID.
'---------------------------------------
  DIM pBlk&,paramBlock$,OSErr

  pBlk& = @paramBlock$
  & pBlk& + _ioNamePtr ,@fName$
  % pBlk& + _ioVRefNum ,fVRefNum
  % pBlk& + _ioFDirIndex,0
  OSErr = FN GETCATINFO(pBlk&)
END FN = [pBlk& + _ioFLParID]

I hope this is a better explanation. I am waking up now.

George


I dug the following out of one of my programs. I wrote it a long time ago, so I don't exactly remember the details of the problems that are alluded to in the comments. But at any rate, this works.

'-----------------------------------------------
LOCAL FN MyNewAlias(fromAddr&, targetAddr&, aliasHandleAddr&)
'Call as follows:
' OSErr = fn MyNewAlias(@fromSpec, @targetSpec, @aliasHandle&)
'or:
' OSErr = FN MyNewAlias(_nil, @targetSpec, @aliasHandle&)
'where fromSpec and targetSpec are fsSpec records (length 70)
'NOTE: FB has a NewAlias hook, but the parameter declarations
'are so unintelligible as to make it unworkable (i.e., I couldn't
'figure it out!)
  ` CLR.W -(SP)
  ` MOVE.L ^fromAddr&,-(SP)
  ` MOVE.L ^targetAddr&,-(SP)
  ` MOVE.L ^aliasHandleAddr&,-(SP)
  ` MOVEQ #2,D0
  ` DC.W $A823
  ` MOVE.W (SP)+,^OSErr
END FN = OSErr
'----------------------------------------------

Rick