Iyonix Select Acorn RISCOS 4 Home About Toolbox Examples Maillist Downloads
AppBasic

Toolbar


bar/gif
General
Hello world 1
Hello world 2
Min app
Bin
Window
Slot machine
Drawing
Colour menu
Drawing
Clock

Clock

clock/gif
A simple desktop clock displaying the current time by responding to “Null” events

You can download the application from here.
  1. Create a new window application
    • Do NOT set the ‘Auto-show’ and ‘Auto-create’ flags
  2. Edit the template
    • Resize the window
    • Add a ‘Display’ gadget
    • Remove some of the window ‘furniture’
    At this stage the window should look like the image above
  3. Insert the null event handler
    DEF PROCDealWith_NullEvent
    PROCDisplayField_SetValue(window,0,FNCurrentTime)
    PROCUtils_IncrementPollIdleTime(100):REM Return in 1 second
    ENDPROC
    • When this procedure is called the current time is placed in the display-field gadget. (The function CurrentTime returns the current time as a string; see the finished application for details)
    • The procedure Utils_IncrementPollIdleTime specifies a time - in centiseconds - before which the null event-handler is not to be called again
  4. Insert the Initial event-handler
    DEF PROCDealWith_InitialEvent
    PROCCreateAndShowWindow
    PROCUtils_PollIdleOn
    ENDPROC

    DEF PROCCreateAndShowWindow
    window=FNToolbox_CreateObject("Window")
    PROCToolbox_ShowObject(window,3)
    ENDPROC
    • The procedure CreateAndShowWindow creates and shows the window on the desktop, storing its object id in the variable window
    • The utility Utils_PollIdleOn switches polling to “Poll idle” form. (Effectively the application can "sleep", not being woken up until a specified time has passed or until it has some action to perform).