Hi gang,
Below find my code for creating a new file with a resource in it.
It works if the folder chosen for the file is the same as the
applications but creates two files when a different folder is chosen.
The data fork portion is created in the folder requested but the
resource portion is created in the application folder. Both have the
same names. Can anyone suggest a solution.
Thanks
Craig
LOCAL FN SaveAs
DIM rHndl&
gFileName$ = FILES$(_fSave,"Save Level as:","Untitled",gVolRefNum%)
LONG IF LEN(gFileName$) > 0
DEF OPEN "DoD3JBEd"
OPEN "R",#1,gFileName$,,gVolRefNum%
CALL CREATERESFILE(gFileName$)
rHndl& = FN NEWHANDLE(520454)
LONG IF rHndl&
BLOCKMOVE @gMainArray(0,0,0), [rHndl&], 520454
R%=USR OPENRFPERM(gFileName$,gVolRefNum%,_fsWrPerm)
C=FN COUNT1RESOURCES(_"levl"):gLev=C+1
CALL ADDRESOURCE(rHndl& ,CVI("levl"),gLev ,"Custom")
CALL CHANGEDRESOURCE(rHndl&)
CALL WRITERESOURCE(rHndl&)
CALL RELEASERESOURCE(rHndl&)
END IF
CALL CLOSERESFILE(R%)
CLOSE #1
END IF
END FN
=========================================================================
Craig Hoyt
==========================================================================