Examples

Opening the Application Automatically

When you are going through the edit/build/download/test cycle, anything that speeds up the process helps. One way to speed up the process is to remove the step of opening the application on the Newton. That is, have the application you are working with automatically open itself. A QuickTime movie of this example is available, as is the completed project for different platforms (Mac OS, Windows 3.1 or Windows 95/NT).

To do this, we'll write an InstallScript which does the opening. Take an existing project and create a text file named "Auto-Open InstallScript". Add the text file to the project and then add the following InstallScript to the file:

InstallScript := func(partFrame)
begin
   AddDeferredCall(
      func()       
      begin
         GetRoot().(kAppSymbol):Open();
      end, 
      nil);
end;
It would be nice if the InstallScript could just open the application with:

GetRoot().(kAppSymbol):Open();
That won't work, however, because the application hasn't yet been successfully installed. We need to postpone the opening until the application has successfully been installed. We do that with AddDeferredCall, which, the next time the main event loop is executed, runs the function you pass it (see Newton Programmer's Guide: System). We call AddDeferredCall in the InstallScript, passing a function which will do the opening. By the time the function executes, the application will have been completely installed, and the Open can be done.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996