Dementia Clock

The Dementia Clock is a Windows application designed to help people living with dementia by simply displaying the time of day as morning, afternoon, evening or night.


Follow this link to DOWNLOAD the Dementia Clock (including source code).

BBC BASIC for Windows source code follows.  Please modify and share freely.

     REM A clock for dementia sufferers
     REM T Street
     REM 2013-11-21
     REM this is a very simple program for displaying a simple clock
     REM the functionality is limited to only displaying the current
     REM day of the week
     REM and whether it is morning, afternoon, evening, or night
     REM with the intention of being an aid for people with memory problems

     REM requires BBC BASIC for Windows
     REM select Options -> lowercase keywords

     
(_Version_Info_)
     GAME_NAME$ = "Dementia Clock"
     VERSION$ = "1.01"

     (_Initialising_)
     REM error handling (displays message and quits)
     
ON ERROR SYS "MessageBox", @hwnd%, REPORT$ + " at line " + STR$ERL, "Error", 48:QUIT
     
REM event handler for quit button
     
ON CLOSE PROC_quit : RETURN
     
REM set size of window
     
VDU 23,22,880;186;32,32,2,0
     REM set window text
     
SYS "SetWindowText", @hwnd%, GAME_NAME$+" version "+VERSION$+" tinyurl.com/superdecade"
     PROC_preventResize
     OFF  : REM turn text cursor
     
*esc off
     COLOUR 1, 255, 255, 0   : REM yellow
     
COLOUR 2, 0, 0, 0       : REM black
     
*font Times New Roman, 48b
     VDU 5 :REM allow text to be printed at graphics cursor


     REM =========== MAIN LOOP =============
     
REPEAT
       PROC
_display(" It is "+FN_getDay( TIME$ )+" "+FN_getTimeFrame( FN_getHours( TIME$ ) )+".")
       SYS "Sleep", 1000 : REM sleep for 1 second
     
UNTIL FALSE
     
REM ===================================


     
DEFPROC_quit
     REM quit handler
     REM user gets 4 seconds to press ENTER key or program continues
     
LOCAL g%
     PROC_display("Now press Enter to quit.")
     g% = INKEY(400)
     IF g% = 13 THEN
       QUIT
     ENDIF
     ENDPROC


     
DEFPROC_display( t$ )
     REM displays text at approx half way along screen
     REM no time to code a proper centering routine
     
COLOUR 1+128 : CLS  : REM clear background to yellow
     
GCOL 2     : REM set graphics colour to red (text counts as graphics after vdu 5)
     
MOVE 190,290
     PRINT t$
     ENDPROC


     
DEFFN_getHours( t$ )
     REM returns the number of hours from the string passed
     REM assuming t$ is a string obtained from time$
     
= VAL( MID$(t$, 17, 2) )


     DEFFN_getTimeFrame( n% )
     REM returns a time such as "morning" etc depending on the string passed
     REM midnight - 6am = night
     REM 6am - noon     = morning
     REM noon - 6pm     = afternoon
     REM gpm - midnight = evening
     
LOCAL a$
     CASE TRUE OF
       WHEN
n% >= 0 AND n% < 6 a$ = "night"
       WHEN n% >= 6 AND n% < 12 a$ = "morning"
       WHEN n% >= 12 AND n% <18 a$ = "afternoon"
       WHEN n% >= 18 AND n% <= 23 a$ = "evening"
       OTHERWISE a$ = "undefined"
     ENDCASE
     
= a$


     DEFFN_getDay( t$ )
     REM returns a string representing the current day
     REM assuming t$ is a string obtained from time$
     
LOCAL part$
     part$ = LEFT$( t$, 3)
     CASE part$ OF
       WHEN
"Mon" a$ = "Monday"
       WHEN "Tue" a$ = "Tuesday"
       WHEN "Wed" a$ = "Wednesday"
       WHEN "Thu" a$ = "Thursday"
       WHEN "Fri" a$ = "Friday"
       WHEN "Sat" a$ = "Saturday"
       WHEN "Sun" a$ = "Sunday"
     ENDCASE
     
= a$


     DEF PROC_preventResize
     REM prevent user resizing window
     
PRIVATE ws%
     SYS "GetWindowLong", @hwnd%, -16 TO ws%
     REM prevent user maximising window
     
SYS "SetWindowLong", @hwnd%, -16, ws% AND NOT &50000
     ENDPROC