ban2/png

tutor/gif
Home

cell/gif

Saving

cell/gif
1/gif Add a save dialogue box
resf/gif Add a SaveAs dialogue box to the drawfile application in Example 2.4.b and attach it to the window as its Show menu object.

popup/gif

I.e. when the menu button is pressed over the window a SaveAs dialogue box pops up.

saveas/gif

2/gif The “SaveAs” event-handler when the Toolbox handles everything
  1. Double-click the SaveAs object in the resfile display
    dbox/gif
  2. Select the Deliver event before showing option
  3. Add the event-handler
    DEF PROCDealWith_SaveAs(event,object,component)
    CASE event OF
      WHEN SaveAs_AboutToBeShown
           PROCSaveAs_SetDataAddress(object,drawfile,length)
    ENDCASE
    ENDPROC

    The PROCSaveAs_SetDataAddress method supplies the address and length of the drawfile to the SaveAs object which automatically takes care of all aspects of the save.
  4. Worked solution
3/gif The “SaveAs” event-handler when the client handles the save
  1. Double-click the SaveAs object in the resfile display
    dbox2/gif
  2. Select the Client participates option
  3. Add the event-handler
    DEF PROCDealWith_SaveAs(event,object,component)
    LOCAL filename$
    CASE event OF
      WHEN SaveAs_SaveToFile
           PROCSaveAs_GetFileName(object,filename$)
           PROCFile_Save(filename$,drawfile,length,&AFF)
           PROCSaveAs_FileSaveCompleted(object,filename$)
    ENDCASE
    ENDPROC

    DEF PROCFile_Save(filename$,buffer,length,filetype%)
    SYS "OS_File",10,filename$,filetype%,,buffer,buffer+length
    ENDPROC

    The SaveAs_SaveToFile event is reported when the save is to be made. The client retrieves the pathname of the file by calling the PROCSaveAs_GetFileName method and signals that the save is completed by calling PROCSaveAs_FileSaveCompleted. The client must provide the orutines which perform the save e.g. PROCFile_Save above.
  4. Worked solution