
rem (c) 1993 Les Hall
rem CIS Address 71053,1676

rem remove or rem out the next four lines if you do
rem not want this to be made into a an OPA type file

APP Worldclk	rem set up for icon
TYPE 1	rem set file type
ICON "M:\PIC\CLOCK.pic"	rem put the clock.pic(icon) in a directory called PIC on M:
ENDA


PROC Worldclk:
local g%				rem get keystrokes
local off1&,off2&,off3&		rem time offsets
local pl1$(11),pl2$(11),pl3$(11)	rem place name var's
local win%(4)			rem we will have 4 windows
if not exist ("M:\OPD\WORLDCLK.DAT")	rem check for file or create one change M: to A:,B: everywhere is is found
	create "M:\OPD\WORLDCLK.DAT",A,place1$,place2$,place3$,diff1&,diff2&,diff3&
	A.place1$="LOS ANGELES"		rem install initial names
	A.place2$="DALLAS"
	A.place3$="CONCORD, MA"
	A.diff1&=-120			rem install initial time differences
	A.diff2&=0
	A.diff3&=54	rem for a joke we put Psion six minutes behind everywhere else....
	append				rem write a record to file WORLDCLK.DAT
	beep 3,500
	dinit				rem set up first time dialogue
	dtext "","Welcome to World Clock!",$302
	dtext "","Press [Enter] at main screen to",2
	dtext "","set up cities & time differences.",2
	dtext "","Enter time differences in minutes.",2
	dtext "","A city two hours behind = -120",2
	dtext "","A city four hours ahead = 240",2
	dtext "","Press [Enter] now.",2
	dialog	rem this dialog only seen on first running or when file Worldclk.Dat does not exist
else
	open   "M:\OPD\WORLDCLK.DAT",A,place1$,place2$,place3$,diff1&,diff2&,diff3&
endif

win%(1)=gcreate(0,20,80,60,1)		rem open four windows when needed
win%(2)=gcreate(80,20,80,60,1)
win%(3)=gcreate(160,20,80,60,1)
win%(4)=gcreate(0,0,240,14,1)

last				rem go to our record in file WORLDCLK.DAT & get settings

do				rem enter loop
	guse win%(4)
	gat 0,0
	gfill 240,14,2			rem our clock titles
	gtmode 0				rem are being set up here
	gstyle 5
	gat 0,10
	gprintb A.place1$,80,3,20,20		rem print city 1 name
	gat 80,10
	gprintb A.place2$,80,3,20,20		rem print city 2
	gat 160,10
	gprintb A.place3$,80,3,20,20		rem print city 3

	guse win%(1)
	gat 7,0 Rem position the clocks.
	gclock on,$25,A.diff1&		rem our first clock with time difference
	guse win%(2)
	gat 7,0
	gclock on,$25,A.diff2&		rem our second clock
	guse win%(3)
	gat 7,0
	gclock on,$25,A.diff3&		rem our third clock
g%=get

	guse win%(1)			rem turn off clocks when we do dialog
	gclock off
	guse win%(2)
	gclock off
	guse win%(3)
	gclock off

if g%=291	rem Help key
	help:
endif

if g%=13				rem Enter key?
	dinit"Enter Cities & Time Differences In Minutes"
	pl1$=A.place1$			rem our dialog accepts names & time
	dedit pl1$,"City 1: (Max 11 Letters)"	rem differences and saves to file with
	off1&=A.diff1& 			rem an update command
	dlong off1&,"Time Difference 1:",-1440,1440
	pl2$=A.place2$
	dedit pl2$,"City 2: (Max 11 Letters)"
	off2&=A.diff2&
	dlong off2&,"Time Difference 2:",-1440,1440
	pl3$=A.place3$
	dedit pl3$,"City 3: (Max 11 Letters)"
	off3&=A.diff3&
	dlong off3&,"Time Difference 3:",-1440,1440
	dialog				rem show the dialog

	A.place1$=upper$(pl1$)		rem assign var's to file
	A.place2$=upper$(pl2$)
	A.place3$=upper$(pl3$)
	A.diff1&=off1&
	A.diff2&=off2&
	A.diff3&=off3&
	update				rem update the file
endif
until g%=27  			rem keep going till [Esc] key
	busy "No time to lose!",3 rem quiting program dialog
	pause -20 rem let user read the above, or continue by hitting any key
Endp

proc help:
local g%
top::
dinit
dtext "","Help: Worldclock",$300
dtext "","úUsing Worldclock",$500
dtext "","úSetting Worldclock",$500
dtext "","úAbout Wordclock",$500
dtext "","úKudos, Thanks",$500
g%=dialog
if g%=0		rem any key other than enter on a line
return		rem get outta here
elseif g%=291	rem help key?
return		rem get outta here
elseif g%=2	rem second line selected?
dinit
dtext "","Help: Using Worldclock",$300
dtext "","Worldclock allows you to set up three",0
dtext "","clocks showing the time & name of cities",0
dtext "","in different time zones. You could use",0
dtext "","city names or zone names like 'Hope,AR'",0
dtext "","or 'Pacific' etc. your settings are saved",0
dtext "","to a small file called Worldclk.DAT on M:.",0
dialog
goto top::
elseif g%=3
dinit
dtext "","Help: Setting Worldclock",$300
dtext "","Press [Enter], you are shown the time",0
dtext "","difference & city naming dialog. Enter",0
dtext "","the titles for each clock and its time",0
dtext "","difference from your home. A city 2 hours",0
dtext "","behind would be entered as -120. A city",0
dtext "","3 hours ahead would be entered as 180.",0
dialog
goto top::
elseif g%=4
dinit
dtext "","Wordclock vers 1.01",$102
dtext "","¸1993 Les Hall",$102
dtext "","CIS 71053,1676",$102
dtext "",chr$(34)+"levitas tempus"+chr$(34),2
dialog
goto top::
elseif g%=5
dinit
dtext "","Help: Kudos, Thanks",$300
dtext "","Again, thanks to Pison PLC & Psion Inc",0
dtext "","for making great palmtop computers.",0
dtext "","Special thanks to Mark Esposito for all",0
dtext "","the pointers & code sharing. And very",0
dtext "","grateful thanks to Jim Hoyt for just",0
dtext "","being a real gent. Love all. Les Hall.",0
dialog
goto top::
endif
endp rem It's all over....
