We have earlier learned how to handle the different ways the app can be started, and the most used events...
Now we're going to handle the most important events: namely the System events.
There's 3 events that must be handled:
Now for the how to:
- Create. Someone selected Create new file in the system screen while your app was in the background.
Handle it by closing the active file, and create a new file as specified. Don't forget to save any unsaved information first.
- Open. Someone doubletapped on another file in the system screen while your app was in the background.
Handle it by closing the active file, and opening the specified file. If necessary, save any unsaved information first...
- eXit. The system wants the app to close down.
Handle by saving any unsaved information, and closing down the app. DO NOT use any 'Do you really want to do this' dialog!
This is REALLY important! otherwise your app will crash the backup system in psiwin
We need a variable or two:
Place this in the IF tests in the loop:
----- Place this in the event loop
ELSEIF eventdata&(4)=&404 REM System event
IF LEFT$(syscommand$,1)="X" REM Exit situation. Must be done!
ELSEIF LEFT$(syscommand$,1)="C" REM Create new file
ELSEIF LEFT$(syscommand$,1)="O" REM Open existing file
Now for the explanation:
The GETCMD$ command returns a string containing the event(C/O/X) and the filename (if C/O)
The Closefile:, Createfile: and Openfile: are your responsibility! (I won't build your whole app :-)