[futurebasic] Resource pain

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 1998 : Group Archive : Group : All Groups

From: Paul Bruneau <paul_bruneau@...>
Date: Tue, 14 Jul 1998 16:44:59 -0400
I seem to be able to get resources OK, but this is my first shot at
saving/creating them. Here is some code that I hope some kind soul can laugh
about to me:

 
DEF PAGE                                'put up the page setup dialog
LONG IF PRCANCEL = _false               'only perform if the user didn't cancel
  curResRefNum = FN CURRESFILE          'save the refNum of current resource file
  CALL USERESFILE(gPrefFile%)           'set the current resource file to the
preferences file
  printHandle& = FN GETRESOURCE(_"SPRC",128)'get the print record resource
  LONG IF printHandle&                  'was it there?
    BLOCKMOVE [PRHANDLE],[printHandle&],_iPrintSize'copy the print record to
the handle
    CALL CHANGEDRESOURCE(printHandle&)  'I changed the resource!
  XELSE                                 'there is no print record resource yet
    printHandle& = PRHANDLE             'get the print handle
    CALL ADDRESOURCE (printHandle&,_"SPRC",128,"Print Record")make the PRINT
RECORD resource
  END IF
            
  CALL UPDATERESFILE(gPrefFile%)
  CALL RELEASERESOURCE(printHandle%)
            
  CALL USERESFILE(curResRefNum)         'restore original resource file
END IF

This thing crashes occasionally, and never does the actual changing of the resource.

TIA,
Paul