Home Gadgetman Forum Book Reviews Links Contact me X-UFO
Gadgets Processors Programming School Old news
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:
We need a variable or two:
GLOBAL syscommand$(255)
Place this in the IF tests in the loop:
----- Place this in the event loop
   ELSEIF eventdata&(4)=&404 REM System event
      handlesystem:
-----

PROC handlesystem:
   syscommand$=GETCMD$
   IF LEFT$(syscommand$,1)="X" REM Exit situation. Must be done! 
      closefile:
      setquitloopvar:
   ELSEIF LEFT$(syscommand$,1)="C" REM Create new file
      closefile:
      createfile:(MID$(syscommand$,2,LEN(syscommand$))
   ELSEIF LEFT$(syscommand$,1)="O" REM Open existing file
      closefile:
      openfile:(MID$(syscommand$,2,LEN(syscommand$))
   ENDIF
ENDP
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 :-)
<<8. The [Ctrl] Key>>
<<How to build an application>>
<< >>