The code for save-file is as follows:
define method save-file
(gadget :: <gadget>) => ()
let frame = sheet-frame(gadget);
let task-list = frame-task-list(frame);
save-as-file(gadget, filename: task-list.task-list-filename)
end method save-file;
Add this code to frame.dylan.
This method is very simple, in that it just calls the method save-as-file, passing it a filename as an argument. The save-as-file method then does the real work of updating the GUI and calling the relevant code to save information to disk.
Just like the open-file method, save-file takes the gadget used to invoke it as an argument and returns no values. In the case of the task list manager the gadget is either open-menu-button (in the File menu of the application) or open-button (on the tool bar). The save-file method sets the following two local variables:
frameThe frame of which the gadget argument is a part, so that the main application frame can be identified.
task-list This contains the value of the frame-task-list slot for frame. This identifies the instance of <task-list> that needs to be saved to disk.
Note that similar local variables are used in the definition of open-file.
The save-file method then calls save-as-file, passing it the following two arguments:
save-file.
<task-list> that needs to be saved to disk.
Notice that the second of these arguments may be #f, if the task list has not previously been saved to disk.