home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-01-04 | 24.7 KB | 1,129 lines |
- APP WorkTime
- TYPE $1003
- EXT "WTM"
- ICON "\OPD\Worktime.pic"
- ENDA
-
- PROC Start:
- global sad&,maxday&,d1970&,d2038&
- global off&,exists%,cur&
- global gcy%,gcmax%
- global setup&(10)
- global bmeet&,bleave&,bnormal&,bcomnt$(20)
- global fonttyp%,zoom%,lines%,h% Rem for zoomming
- global prolist$(255)
- Rem --- Constants ---
- sad& = 86400 REM Seconds a day (24*60*60)
- maxday& = 86399 REM 23:59:59
- d1970& = 25567 REM days(1,1,1970)
- d2038& = 50422 REM days(19,1,2038) Rem Not 100% correct, but closer than a Pentium ;-)
- defaultwin 1
- statuswin on,2
- gsetwin 0,0,415,160
- SysReq:(cmd$(3),cmd$(2)) rem open file
- Handler:
- ENDP
-
- PROC SysReq:(act$,file$) REM For system requests
- SaveFile:
- if act$="X" rem Close and Exit
- stop
- elseif act$="C" rem Create new file
- MkFile:(file$)
- elseif act$="O" rem Open file
- OpenFile:(file$)
- endif
- ENDP
-
- PROC SetFont:
- local i%(32),font%
- Rem
- Rem Recalculate all font size dependent values
- Rem
- font%=fonttyp%+zoom%
- setup&(10)=font%
- gfont font%
- font font%,0
- ginfo i%()
- h%=i%(3)
- Rem TODO: Extract screen width
- Rem TODO: and recalc column widths
- lines%=(gheight-8)/h%
- gcmax%=(lines%-1)*h%
- off&=Offset&:(cur&,1-lines%) :gcy%=gcmax%
- REM -- A repaint: is needed after this
- rem cursor 1,1,255,h%,2 REM To bad max width is 255, really
- ENDP
-
- PROC Handler:
- global a%(6)
- onerr Error
- while 1
- getevent a%()
- @("x"+hex$(a%(1))):
- continue
- Rem This part is only reached when no
- Rem corresponding event handler is found.
- Rem Keypresses fall back on either TextED: or RecED:
- Error::
- if err=-99 and a%(1)<256
- if a%(1)>64 rem Textchars
- TextED:
- else Rem Other
- RecED:
- endif
- else
- ShowErr:(hex$(a%(1)))
- endif
- endwh
- ENDP
-
- PROC MkFile:(reqfile$)
- local file$(128),o%(6)
- o%(1)=1 :o%(2)=6 :o%(3)=8 :o%(4)=8 :o%(5)=10 :o%(6)=0
- file$=parse$(reqfile$,"LOC::M:\*.WTM",o%())
- trap create file$,A,meet&,leave&,normal&,total&,comment$
- if err
- ShowErr:("Cannot create '"+file$+"'")
- else
- append rem Append empty entry
- setname file$
- setup&(1)=28800 REM 08:00:00 = 8*60*60 / Monday
- setup&(2)=28800 REM 08:00:00 = 8*60*60 / Tuesday
- setup&(3)=28800 REM 08:00:00 = 8*60*60 / Wedensday
- setup&(4)=28800 REM 08:00:00 = 8*60*60 / Thursday
- setup&(5)=18000 REM 05:00:00 = 5*60*60 / Friday
- setup&(6)=0 rem Saturday
- setup&(7)=0 rem Sunday
- setup&(8)=0 rem Morning slack
- setup&(9)=0 rem Evening slack
- setup&(10)=9 :fonttyp%=9 :zoom%=0
- cur&=Early&:(Now&:) :off&=cur&-lines%*sad& :gcy%=gcmax% :exists%=0
- SetFont:
- Repaint:
- endif
- ENDP
-
- PROC OpenFile:(file$)
- local n%,sp%,set$(255),v$(10),sep$(1)
- trap open file$,A,meet&,leave&,normal&,total&,comment$
- if err
- setname "-none-"
- ShowErr:("Cannot open '"+file$+"'")
- x26f: Rem As if user pressed Psion-O again to open file
- return
- endif
- setname file$
- Rem
- Rem Comment string from first entry holds
- Rem all the setup values.
- Rem Extract and save as setup&(1-10)
- Rem
- set$=a.comment$
- Rem Decide on what seperator was used
- Rem for packing the setup values.
- if loc(set$,chr$(13))
- sep$=chr$(13) Rem NEW setup
- else
- sep$=" " Rem OLD setup
- endif
- n%=1 :sp%=loc(set$,sep$)
- while sp%>0 and n%<=10
- setup&(n%)=val(left$(set$,sp%-1))
- if sp%>=len(set$) :break :endif
- set$=right$(set$,len(set$)-sp%)
- n%=n%+1 :sp%=loc(set$,sep$)
- endwh
- if sp% :prolist$=left$(set$,sp%-1) :endif
- Rem reset if bad font value (happens when readng old format)
- if setup&(10)<5 or setup&(10)>12
- setup&(10)=9
- SaveSet: Rem update change
- endif
- fonttyp%=int(setup&(10)/4)*4+1
- zoom% =setup&(10)-fonttyp%
- SetFont:
- first :cur&=0 :MovTo:(datetosecs(year,month,day,23,59,59),1)
- ENDP
-
- PROC ShowErr:(txt$)
- dinit
- dtext "",txt$,$400
- dtext "",err$(err),$600
- dtext ""," "
- dbuttons "Exit program",%x,"Continue",-13
- lock on
- if dialog=%x :stop :endif
- lock off
- ENDP
-
- PROC Repaint:
- ggrey 2 :gcls
- Paint:(off&,lines%)
- Cursor:
- ENDP
-
- PROC Cursor:
- gat 1,gcy%+4 :gfill 300,h%,2
- ENDP
-
- PROC Paint:(from&,l%)
- local y%,dy%,lin%
- local yr%,mo%,da%,ho%,m%,s%,yrd%,wd%
- local oldcur&,oldpos%,oldex%,oldcurd&
- oldpos%=pos :oldcur&=cur& :oldex%=exists%
- gborder $203
- MovTo:(off&,0)
- y%=MovCnt%:(from&,0)*h%
- dy% = h%*l%
- ggrey 1
- gat 90,y%+4 :glineby 0,dy%
- gat 190,y%+4 :glineby 0,dy%
- gat 240,y%+4 :glineby 0,dy%
- gat 300,y%+4 :glineby 0,dy%
- lin%=l%
- while (lin%>0)
- secstodate cur&,yr%,mo%,da%,ho%,m%,s%,yrd%
- wd% = dow(da%,mo%,yr%)
- ggrey 1 :gat 1,y%+4
- if wd%=6 or wd%=7
- gfill 300,h%,0
- else
- glineby 300,0
- endif
- ggrey 0
- gat 7,y%+3
- gmove 0,h% :gprintb dayname$(wd%),30
- gmove 30,0 :gprintb num$(da%,2),16,1
- gmove 20,0 :gprintb month$(mo%),30
- if exists%
- gmove 35,0 :gprintb Time$:(cur&,0,0),40,1
- gmove 40,0 :gprintb "-",10
- if a.leave&
- gmove 5,0 :gprintb Time$:(a.leave&,0,0),40,1
- gmove 50,0 :gprintb Time$:(a.leave&-cur&-a.normal&,1,0),45,1
- gmove 50,0 :gprintb Time$:(a.total&,1,0),55,1
- gmove 70,0
- else
- gmove 175,0
- endif
- gprintb a.comment$,99
- endif
- MovRel:(1,0)
- y% = y%+h% :lin%=lin%-1
- endwh
- ggrey 1 :gat 1,y%+4 :glineby 300,0 :ggrey 0
- position oldpos% :cur&=oldcur& :exists%=oldex%
- ENDP
-
-
- PROC Time$:(t&,sign%,secs%)
- local res$(30),yr%,mo%,da%,ho%,mi%,se%,yrd%
- secstodate abs(t&),yr%,mo%,da%,ho%,mi%,se%,yrd%
- if yr%=1970 :ho%=ho%+(da%-1)*24 :endif
- if ho%<10 :res$=res$+" " :endif
- if t&<0 :res$=res$+"-"
- elseif sign% :res$=res$+"+"
- endif
- res$=res$+num$(ho%,3)+":"
- if mi%<10 :res$=res$+"0" :endif
- res$=res$+num$(mi%,2)
- if secs%
- res$=res$+":"
- if se%<10 :res$=res$+"0" :endif
- res$=res$+num$(se%,2)
- endif
- return res$
- ENDP
-
- PROC RecED:
- local m&,l&,n&,c$(20),morn&,even&
- local yr%,mo%,dy%,hr%,mn%,sc%,yd%,wd%
- local ret%,new$(13)
- morn& = Early&:(cur&)
- secstodate cur&,yr%,mo%,dy%,hr%,mn%,sc%,yd%
- wd%=dow(dy%,mo%,yr%)
- Rem See if an entry already exists
- if exists%
- m&=cur&-morn&
- l&=a.leave&
- if l& :l&=l&-morn& :endif
- n&=a.normal&
- c$=a.comment$
- new$=""
- else
- Rem Fill in Defaults
- m&=8*60*60
- n&=setup&(wd%)
- l&=m&+n&
- new$=" (new entry)"
- endif
- Rem Display edit dialog
- dinit dayname$(wd%)+" "+num$(dy%,2)+" "+month$(mo%)+" "+num$(yr%,4)+new$
- dtime m&,"Meet",1,0,maxday&
- dtime l&,"Leave",1,0,maxday&
- dtext "Worktime",Time$:(l&-m&,0,1),0
- dtime n&,"Normal time",0,0,maxday&
- dtext "Todays diff",Time$:(l&-m&-n&,1,1),0
- dtext "Total diff",Time$:(a.total&,1,1),0
- dedit c$,"Comment",20
- lock on :ret% = dialog :lock off
- if ret%
- a.meet&=m&+morn&
- if l& :l&=l&+morn& :if m&>l& :l&=l&+sad& :endif :endif
- a.leave&=l&
- a.normal&=n&
- a.comment$=c$
- if exists% :update :else :append :endif
- Reorder:
- PaintCur:
- endif
- ENDP
-
- PROC TextED:
- local c$(20), ret%
- if exists%
- c$=a.comment$+chr$(a%(1))
- else
- a.meet&=cur&+28800 Rem current day at 08:00 => cur& + 8*60*60
- a.normal&=0
- a.leave&=0
- c$=chr$(a%(1))
- endif
- dinit "Comment"
- dedit c$,"",20
- REM - So how do I position the cursor
- REM to the end of the 'dedit' string ?
- REM If you have an idea please tell me...
- lock on :ret% = dialog :lock off
- if ret%
- a.comment$=c$
- if exists% :update :else :append :endif
- Reorder:
- PaintCur:
- endif
- ENDP
-
- PROC SaveFile:
- trap close
- if err<>0 and err<>-102
- ShowErr:("Error closing file")
- endif
- ENDP
-
- PROC PaintCur:
- Cursor:
- paint:(cur&,1)
- Cursor:
- ENDP
-
- Rem current entry is always the one
- Rem just less than or eual to cur&
- Rem exists% tells if tec really exists
-
- PROC MovCurs:(d%)
- local rd%
- if abs(d%)>lines%
- if d%>0
- off&=Offset&:(cur&,1-lines%) :gcy%=gcmax%
- else
- off&=cur& :gcy%=0
- endif
- Repaint:
- return
- endif
- Cursor:
- gcy%=gcy%+d%*h%
- if gcy%<0 rem Move UP (scrolls down)
- rd% = gcy%/h%
- off&=cur&
- ggrey 2 :gscroll 0,-rd%*h%,1,4,410,gcmax% :ggrey 0
- paint:(off&,-rd%)
- gcy% = 0
- elseif gcy%>gcmax% rem Move DOWN (scrolls up)
- rd% = (gcy%-gcmax%)/h%
- off& = Offset&:(off&,rd%)
- ggrey 2 :gscroll 0,-rd%*h%,1,4+h%,410,gcmax% :ggrey 0
- paint:(Offset&:(off&,lines%-rd%),rd%)
- gcy%=gcmax%
- endif
- Cursor:
- ENDP
-
- Rem Move to Entry specified as time&
- Rem cur& will point to
- Rem 1) Entry, if exists
- Rem 2) Prev entry same day, if any
- Rem 3) Following entry same day, if any
- Rem 4) Start of day (exists%=0)
-
- Proc MovTo:(time&,show%)
- local day&,lin%,d&
- d&=int(time&/sad&)-int(cur&/sad&)
- if abs(d&)<50 and show%
- lin%=d&
- while a.meet&<time& and not eof
- next
- if int(a.meet&/sad&)=int(cur&/sad&) :lin%=lin%+1 :endif
- cur&=a.meet&
- endwh
- if eof :back :endif
- while a.meet&>time& and not eof
- back
- if int(a.meet&/sad&)=int(cur&/sad&) :lin%=lin%-1 :endif
- cur&=a.meet&
- endwh
- else
- REM - Fast seek
- if time&>cur& :lin%=50 :else :lin%=-50 :endif
- while a.meet&<time& and not eof :next :endwh
- if eof :back :endif
- while a.meet&>time& and not eof :back :endwh
- endif
- day&=Early&:(time&)
- exists%=1 Rem Greatest probability
- if a.meet&=time&
- cur&=time&
- elseif a.meet&>=day& and a.meet&<day&+sad&
- cur&=a.meet&
- else
- next
- if not eof and a.meet&>=day& and a.meet&<day&+sad&
- cur&=a.meet&
- else
- back :cur&=day& :exists%=0
- endif
- endif
- if show% :MovCurs:(lin%) :endif
- ENDP
-
- PROC MovRel:(lin%,show%)
- local l%,day&
- l%=lin%
- while l%<0 Rem go back
- if exists% :back :endif
- day&=Early&:(cur&)-sad& Rem Yesterday
- if a.meet&<day&
- cur&=day& :exists%=0
- else
- cur&=a.meet& :exists%=1
- endif
- l%=l%+1
- endwh
- while l%>0
- next
- day&=Early&:(cur&)+sad& Rem Tomorrow
- if eof
- back
- cur&=day& :exists%=0
- elseif a.meet&>=day&+sad& Rem after the morning of the day after tomorrow
- back
- cur&=day& :exists%=0
- else
- cur&=a.meet& :exists%=1
- endif
- l%=l%-1
- endwh
- if show% :MovCurs:(lin%) :endif
- ENDP
-
- Proc MovCnt%:(time&,show%)
- local lin%
- while cur&<time& :MovRel:( 1,show%) :lin%=lin%+1 :endwh
- while cur&>time& :MovRel:(-1,show%) :lin%=lin%-1 :endwh
- if show% :MovCurs:(lin%) :endif
- return lin%
- ENDP
-
- PROC Reorder:
- local p%,meet&,total&,cnt%
- rem We know that only last rec
- rem can be out of order
- busy "Sorting"
- last :meet&=a.meet&
- if meet&
- back
- while meet&<a.meet& :cnt%=cnt%+1 :back :endwh
- total&=a.total& :next :p%=pos
- last
- if a.leave& :total&=total&+a.leave&-a.meet&-a.normal& :endif
- a.total&=total&
- update Rem stll remains at end
- else
- Rem Little shortcut for rewriting
- Rem setup record (meet&=0)
- total&=a.total& :p%=1 :cnt%=pos-1
- endif
- while cnt%
- position p%
- if a.leave& :total&=total&+a.leave&-a.meet&-a.normal& :endif
- a.total&=total&
- update Rem and move to end
- cnt%=cnt%-1
- endwh
- onerr off
- busy off
- MovTo:(cur&,0)
- ENDP
-
- PROC Offset&:(from&,lin%)
- local oldcur&,oldpos%,oldex%,oldcurd&
- local offs&
- oldpos%=pos :oldcur&=cur& :oldex%=exists%
- MovTo:(from&,0)
- MovRel:(lin%,0)
- offs&=cur&
- position oldpos% :cur&=oldcur& :exists%=oldex%
- return offs&
- ENDP
-
- PROC Now&:
- return datetosecs(year,month,day,hour,minute,second)
- ENDP
-
- PROC Early&:(tim&)
- return int(tim&/sad&)*sad&
- ENDP
-
- PROC Mark:
- local wd%,tim&,today&
- tim&=Now&:
- MovTo:(tim&,1)
- today&=Early&:(tim&)
- if a.meet&>=today& and a.meet&<today&+sad& and a.leave&=0
- a.leave&=Now&:+setup&(9)
- update :Reorder: :Repaint:
- else
- if cur&>tim& :MovCurs:(1) :endif
- a.meet&=tim&-setup&(8)
- a.leave&=0
- wd%=dow(day,month,year)
- a.normal&=setup&(wd%)
- a.comment$=""
- append
- Reorder:
- Repaint:
- MovTo:(tim&,1)
- endif
- ENDP
-
- PROC x8: rem Delete
- DelCur:
- ENDP
-
- PROC x7f: rem shift-delete (backspace)
- DelRang:
- ENDP
-
- PROC DelCur:
- local stat%,oldcur&
- if exists%
- oldcur&=cur&
- dinit
- dtext "","Remove"
- dbuttons "Yes",%y,"No",%n
- lock on : stat%=dialog :lock off
- if stat%=%y
- CopyBuf:
- ERASE
- cur&=0 :first :MovTo:(oldcur&,1)
- giprint "Removed"
- endif
- else
- giprint "Nothing to remove"
- endif
- ENDP
-
- PROC DelRang:
- local stat%,from&,to&,cnt%,oldcur&
- oldcur&=cur&
- from&=cur&/sad&+d1970&
- to&=cur&/sad&+1+d1970&
- dinit
- dtext "","Remove"
- ddate from&,"from",d1970&,d2038&
- ddate to&,"to (excl.)",d1970&,d2038&
- dbuttons "Yes",%y,"No",%n
- lock on : stat%=dialog :lock off
- if stat%=%y
- busy "Removing"
- from&=(from&-d1970&)*sad&
- to&=(to&-d1970&)*sad&
- first
- while a.meet&<from& :next :endwh
- while a.meet&<to& and not eof
- cnt%=cnt%+1
- REM This is silly, when removing a range
- REM only last entry is remembered
- REM But to remember all takes up way too much memory (does it, really ?)
- CopyBuf:
- ERASE
- endwh
- onerr off
- if cnt%
- cur&=0 :first :MovTo:(oldcur&,1)
- giprint num$(cnt%,5)+" entries removed"
- else
- giprint "No entries removed"
- endif
- busy off
- endif
- ENDP
-
- PROC CopyBuf:
- onerr Problem::
- rem Copy to paste buffer
- bmeet&=a.meet&
- bleave&=a.leave&
- bnormal&=a.normal&
- bcomnt$=a.comment$
- Problem::
- ENDP
-
- PROC x9: rem TAB
- JumpDate:
- ENDP
-
- PROC xd: rem ENTER
- RecED:
- ENDP
-
- PROC x1b: rem ESC
- call($198d,100,0) Rem background
- ENDP
-
- PROC x20: rem Space
- Mark:
- ENDP
-
- PROC x100: rem up
- if a%(2) and 2 rem Shift
- MovRel:(-3,1)
- elseif a%(2) and 4 rem Control
- MovTo:(cur&-30*sad&,1)
- else
- MovRel:(-1,1)
- endif
- ENDP
-
- PROC x101: rem down
- if a%(2) and 2 rem Shift
- MovRel:(3,1)
- elseif a%(2) and 4 rem Control
- MovTo:(cur&+30*sad&,1)
- rem MovRel:(30,1)
- else
- MovRel:(1,1)
- endif
- ENDP
-
- rem PROC x102: rem right
- rem ENDP
- rem PROC x103: rem left
- rem ENDP
-
- PROC x104: rem Page up
- MovRel:(-10,1)
- ENDP
-
- PROC x105: rem Page down
- MovRel:(10,1)
- ENDP
-
- rem PROC x106: rem Page right
- rem ENDP
- rem PROC x107: rem Page left
- rem ENDP
-
- PROC x122: rem Menu
- local menu%
- minit
- mcard "File","Open file",%o,"Make new file",%m,"Print",%p,"Who did this?",%w,"Exit",%x
- mcard "Edit","Insert",%i,"Copy",%c,"Delete",%D,"Delete range",%R,"Edit",%e
- mcard "Screen","Repaint",%r,"Sort/Recalc",%s,"Jump to date",%j,"Font type",%f,"Zoom in",%z,"Zoom out",%Z
- mcard "Project","Begin",%b,"Project Usage",%u,"Delete project",%d
- mcard "Settings","Normal worktime",%n,"Slack",%l
- lock on :menu% = MENU :lock off
- if menu%
- onerr Error::
- @("x"+hex$(menu%+$200)):
- endif
- return
- Error::
- ShowErr:(hex$(menu%+$200))
- ENDP
-
- PROC x123: rem Help
- local file$(20)
- file$="\opo\Workhelp.opo"
- trap loadm file$
- if err
- ShowErr:("'"+file$+"' - Help not installed")
- else
- WorkHelp:
- unloadm file$
- endif
- ENDP
-
- PROC x124: rem Star
- WhoInfo:
- ENDP
-
- PROC WhoInfo:
- dinit "Worktime"
- dtext "","Version 2.06",2
- dtext "","Created January 1995",2
- dtext "","by",2
- dtext "","Erik Johansen",$102
- dtext "","ej@id.dtu.dk",$102
- dtext "","(icon by ja@id.dtu.dk)",2
- dialog
- ENDP
-
- PROC x244:
- DelCur:
- ENDP
-
- PROC x252:
- DelRang:
- ENDP
-
- PROC x262: rem psion-b = Begin project
- local proj$(255),stat%,pronum%,newpro$(20)
- if prolist$<>""
- pronum%=1
- dinit "Begin project"
- dchoice pronum%,"Project:","<New project>,"+prolist$
- lock on :stat%=dialog :lock off
- else
- Rem No projects defined
- Rem Simulate selection of <NEW>
- pronum%=1 :stat%=1
- endif
- if stat%
- if pronum%=1
- dinit "Begin new project"
- dedit newpro$,"Project name:",20
- lock on :stat%=dialog :lock off
- if stat% and newpro$<>""
- proj$=newpro$
- if len(proj$)+len(prolist$)>254
- giprint "Project list too long; Cannot add"
- else
- if prolist$<>"" :prolist$=prolist$+"," :endif
- prolist$=prolist$+proj$
- SaveSet: Rem update change to project list
- endif
- else
- proj$=""
- endif
- else
- proj$=prolist$
- while pronum%>2 and loc(proj$,",")
- proj$=right$(proj$,len(proj$)-loc(proj$,","))
- pronum%=pronum%-1
- endwh
- if loc(proj$,",") :proj$=left$(proj$,loc(proj$,",")-1) :endif
- endif
- ProStart:(proj$)
- endif
- ENDP
-
- PROC ProStart:(proj$) rem Start project
- local wd%,tim&,today&
- tim&=Now&:
- MovTo:(tim&,1)
- today&=Early&:(tim&)
- if a.leave&=0 and a.meet&>today& and a.meet&<today&+sad&
- rem if exists% and a.leave&=0
- if a.normal& :a.leave&=Now&:+setup&(9) :else a.leave&=Now&: :endif
- update
- Reorder:
- MovTo:(tim&,1)
- endif
- if proj$<>""
- if cur&>tim& :MovCurs:(1) :endif
- a.meet&=tim&
- a.leave&=0
- a.normal&=0 Rem Projects won't use this
- a.comment$=proj$
- append
- Reorder:
- Repaint:
- MovTo:(tim&,1)
- endif
- ENDP
-
- PROC x263: rem psion-c = Copy
- if exists%
- CopyBuf:
- giprint "Copied"
- else
- giprint "Nothing to Copy"
- endif
- ENDP
-
- PROC x264: rem psion-d = Delete Project/Entry
- local pronum%,stat%,proj$(255),delproj$(20)
- if a%(2) and 2 rem Shift
- DelCur:
- elseif prolist$=""
- giprint "No projects to delete"
- else
- dinit "Delete project"
- dchoice pronum%,"Project:",prolist$
- lock on :stat%=dialog :lock off
- if stat%
- proj$=""
- while loc(prolist$,",")
- pronum%=pronum%-1
- if pronum% :proj$=proj$+left$(prolist$,loc(prolist$,",")) :else :delproj$=left$(prolist$,loc(prolist$,",")-1) :endif
- prolist$=right$(prolist$,len(prolist$)-loc(prolist$,","))
- endwh
- pronum%=pronum%-1
- if pronum% :proj$=proj$+prolist$ :else :delproj$=prolist$ :if len(proj$) :proj$=left$(proj$,len(proj$)-1) :endif :endif
- prolist$=proj$
- giprint "Project '"+delproj$+"' deleted"
- endif
- endif
- ENDP
-
- PROC x265: rem psion-e = Edit
- RecED:
- ENDP
-
- PROC x266: rem psion-f = Font type
- local stat%,typ%
- if fonttyp%=5 :typ%=1 :else :typ%=2 :endif
- dinit "Font type"
- dchoice typ%,"","Roman,Swiss"
- lock on :stat%=dialog :lock off
- if stat%
- if typ%=1 :fonttyp%=5 :else fonttyp%=9 :endif
- SetFont: :Repaint:
- SaveSet:
- endif
- ENDP
-
- PROC x269: rem psion-i = Insert
- if bmeet&
- a.meet&=bmeet&-Early&:(bmeet&)+Early&:(cur&)
- if bleave& :a.leave&=bleave&-Early&:(bleave&)+Early&:(cur&) :else :a.leave&=0 :endif
- a.normal&=bnormal&
- a.comment$=bcomnt$
- append
- Reorder:
- Repaint:
- MovTo:(cur&,1)
- else
- giprint "Nothing to insert"
- endif
- ENDP
-
- PROC x26a: rem psion-j = Jump to date
- JumpDate:
- ENDP
-
- PROC JumpDate:
- local to&,ret%
- to&=days(day,month,year)
- dinit "Jump to date"
- ddate to&,"",d1970&,d2038&
- lock on :ret% = dialog :lock off
- if ret%
- Rem point to last entry of the day
- MovTo:((to&-d1970&+1)*sad&-1,1)
- endif
- ENDP
-
- PROC x26c: rem psion-l = Slack
- dinit "Slack setup"
- dtime setup&(8),"Arrival",1,0,datetosecs(1970,1,1,0,59,59)
- dtime setup&(9),"Leave",1,0,datetosecs(1970,1,1,0,59,59)
- lock on :if dialog :SaveSet: :endif :lock off
- ENDP
-
- PROC x26d: rem psion-m = Make new
- local file$(128),ret%
- dinit "Make new file"
- dfile file$,"",$9
- lock on :ret% = dialog :lock off
- if ret%
- SaveFile:
- MkFile:(file$)
- endif
- ENDP
-
- PROC x26e: rem psion-n = Normal worktime
- local n%
- dinit "Normal worktime"
- n%=1
- while n%<=7
- dtime setup&(n%),dayname$(n%),1,0,maxday&
- n%=n%+1
- endwh
- lock on :if dialog :SaveSet: :endif :lock off
- ENDP
-
- PROC SaveSet:
- local n%,set$(255)
- busy "Saving setup"
- first :n%=1
- while n%<=10
- set$=set$+num$(setup&(n%),5)+chr$(13)
- n%=n%+1
- endwh
- if len(set$)+len(prolist$)>254
- set$=set$+left$(prolist$,254-len(set$))+chr$(13)
- giprint "Long project list only saved partially"
- else
- set$=set$+prolist$+chr$(13)
- endif
- a.comment$=set$
- update :Reorder:
- busy off
- giprint "Saved"
- ENDP
-
- PROC x26f: rem psion-o = Open/Load
- local file$(128),ret%
- dinit "Open file"
- dfile file$,"",$10
- lock on
- if dialog
- SaveFile:
- OpenFile:(file$)
- endif
- lock off
- ENDP
-
- PROC x270: rem psion-p Print
- local outfile$(128),stat%,from&,to&,showsec%,showpro%
- local yr%,mo%,da%,ho%,m%,s%,yrd%,wd%
- local p%,pcnt%,proj$(30,20),puse&(30)
- local transf&,projlen%
- local oldcur&,oldpos%,oldex%,oldcurd&
-
- outfile$="LOC::M:\Time.out"
- showpro%=2
- dinit "Print to file"
- dfile outfile$,"File",1
- from&=days(1,month,year)
- if month<12 :to&=days(1,month+1,year) :else :to&=days(1,1,year+1) :endif
- ddate from&,"from",d1970&,d2038&
- ddate to&,"to (excl.)",d1970&,d2038&
- dchoice showsec%,"Show secs","No,Yes"
- dchoice showpro%,"Show Projects","No,Yes"
- lock on :stat% = dialog :lock off
- if stat%=0 :return :endif
-
- from&=(from&-d1970&)*sad&
- to&=(to&-d1970&)*sad&
- showsec%=showsec%-1
- showpro%=showpro%-1
-
- oldpos%=pos :oldcur&=cur& :oldex%=exists%
- lopen outfile$
- busy "Printing"
- MovTo:(from&,0)
- if exists% :back :endif
- transf&=a.total&
- if exists% :next :endif
- lprint "Transfer";rept$(" ",41+12*showsec%)+Time$:(transf&,1,showsec%)
- while (cur& < to&)
- secstodate cur&,yr%,mo%,da%,ho%,m%,s%,yrd%
- wd% = dow(da%,mo%,yr%)
- lprint dayname$(wd%);" ";num$(da%,-2);". ";month$(mo%);
- if exists%
- lprint " ";Time$:(cur&,0,showsec%);" -";
- if a.leave&
- lprint " ";Time$:(a.leave&,0,showsec%);" ";Time$:(a.leave&-cur&,0,showsec%);" ";Time$:(a.normal&,0,0);" ";Time$:(a.leave&-cur&-a.normal&,1,showsec%);" ";Time$:(a.total&,1,showsec%);
- transf&=a.total&
- if a.comment$<>""
- lprint " ";a.comment$;
- if showpro%
- p%=1 :while p%<=pcnt% and proj$(p%)<>a.comment$ :p%=p%+1 :endwh
- if proj$(p%)<>a.comment$ and pcnt%<30
- pcnt%=pcnt%+1
- proj$(pcnt%)=a.comment$ :p%=pcnt%
- projlen%=max(projlen%,len(a.comment$))
- endif
- puse&(p%)=puse&(p%)+a.leave&-cur&
- endif
- endif
- elseif a.comment$<>""
- lprint rept$(" ",38+12*showsec%);a.comment$;
- endif
- endif
- lprint
- MovRel:(1,0)
- endwh
- lprint "Transfer";rept$(" ",41+12*showsec%)+Time$:(transf&,1,showsec%)
- if pcnt%
- lprint :lprint "Project totals:"
- p%=1 :projlen%=projlen%+2
- while p%<=pcnt%
- lprint proj$(p%);rept$(" ",projlen%-len(proj$(p%)));Time$:(puse&(p%),0,showsec%)
- p%=p%+1
- endwh
- endif
- lclose
- busy off
- position oldpos% :cur&=oldcur& :exists%=oldex%
- ENDP
-
- PROC x272: rem psion-r - Repaint
- if a%(2) and 2 rem Shift
- DelRang:
- else
- Repaint:
- endif
- ENDP
-
- PROC x273: rem psion-s = Sort
- local last%,e%,e&,lpos%,total&
- busy "Sorting"
- last :last%=pos
- if count>0
- while last%<>0
- position last% :e%=pos
- e&=a.meet&
- do
- if a.meet&<e& :e&=a.meet& :e%=pos :endif
- lpos%=pos :BACK
- until POS=1 and lpos%=1
- position e%
- if a.leave& :total&=total&+a.leave&-a.meet&-a.normal& :endif
- a.total&=total&
- update :last%=last%-1
- endwh
- endif
- busy off
- giprint num$(count-1,5)+" entries sorted"
- Repaint:
- ENDP
-
- PROC x275: Rem Psion-U Project Usage
- local yr%,mo%,da%,ho%,m%,s%,yrd%,wd%
- local p%,po%,pcnt%,lin$(255),proj$(30,20),puse&(30)
- local oldcur&,oldpos%,oldex%,oldcurd&
- local stat%,from&,to&,showsec%
- showsec%=2
- dinit "Project Usage"
- from&=days(1,month,year)
- if month<12 :to&=days(1,month+1,year) :else :to&=days(1,1,year+1) :endif
- ddate from&,"from",d1970&,d2038&
- ddate to&,"to (excl.)",d1970&,d2038&
- dchoice showsec%,"Show secs","No,Yes"
- lock on :stat% = dialog :lock off
- if stat%=0 or from&>to& :return :endif
- from&=(from&-d1970&)*sad&
- to&=(to&-d1970&)*sad&
- showsec%=showsec%-1
- REM Calc
- oldpos%=pos :oldcur&=cur& :oldex%=exists%
- busy "Calculating"
- MovTo:(from&,0)
- if not exists% :next :endif
- while a.meet&<to& and not eof
- if a.leave& and a.comment$<>""
- p%=1 :while p%<=pcnt% and proj$(p%)<>a.comment$ :p%=p%+1 :endwh
- if proj$(p%)<>a.comment$ and pcnt%<30
- pcnt%=pcnt%+1 :proj$(pcnt%)=a.comment$ :p%=pcnt%
- endif
- puse&(p%)=puse&(p%)+a.leave&-a.meet&
- endif
- next
- endwh
- busy off
- if pcnt%
- po%=1
- while 1
- dinit "Project totals"
- p%=po%
- while p%<po%+5 and p%<=pcnt%
- dtext proj$(p%),Time$:(puse&(p%),0,showsec%),1
- p%=p%+1
- endwh
- if pcnt%<8
- elseif po%<2 :dbuttons "Down",&101
- elseif po%>pcnt%-5 :dbuttons "Up",&100
- else :dbuttons "Up",&100,"Down",&101
- endif
- lock on :stat% = dialog :lock off
- if stat%=&100 :po%=po%-1
- elseif stat%=&101 :po%=po%+1
- else
- break
- endif
- endwh
- else
- giprint "No projects found"
- endif
- position oldpos% :cur&=oldcur& :exists%=oldex%
- ENDP
-
- PROC x277: rem psion-w = Who created this ?
- WhoInfo:
- ENDP
-
- PROC x278: rem psion-x = Exit
- SaveFile: :stop
- ENDP
-
- PROC x27a: rem psion-z = Zoom
- if a%(2) and 2 rem Shift
- zoom%=zoom%-1 :if zoom%<0 :zoom%=3 :endif
- else
- zoom%=zoom%+1 :if zoom%>3 :zoom%=0 :endif
- endif
- SetFont: :Repaint: :SaveSet:
- ENDP
-
- PROC x401: rem Foreground
- ENDP
-
- PROC x402: rem Background
- ENDP
-
- Rem To enable wakeup (power on) signals
- Rem add the following call at start of
- Rem the program:
- Rem
- Rem call($6c8d) rem want wakeup signal
- Rem How come the signal comes in anyway ?
- Rem
- PROC x403: rem Powerup
- ENDP
-
- PROC x404: rem sys request
- local c$(129)
- c$ = getcmd$
- SysReq:(left$(c$,1),mid$(c$,2,128))
- ENDP
-
- PROC x405: rem Date change
- MovTo:(Now&:,1)
- ENDP
-
- PROC x2000: rem + contrast
- ENDP
-
- PROC x2001: rem - contrast
- ENDP
-
- REM ===== Project keys =====
-
- PROC x6c: REM 'l'-key
- ProStart:("Lunch")
- ENDP
-
- PROC x6d: REM 'm'-key
- ProStart:("Meeting")
- ENDP
-
- PROC x74: REM 't'-key
- ProStart:("Transport")
- ENDP
-
-