TweetFollow Us on Twitter

Managers for Sys 6
Volume Number:4
Issue Number:10
Column Tag:Forth Forum

The Manager

By Jörg Langowski, MacTutor Editorial Staff

Notification Manager, List Manager and UserItems

System updates are almost too frequent to keep track of. It has been only a couple of months since I installed release 6.0; already there are a couple of bug fixes out. I couldn’t get them as of this writing, but System 6.0 has behaved stable so far, examples of ill-behaved applications are only very rare.

The scene keeps moving. As I write this, System 6.0.1 is almost released and 7.0 is being talked about; true to the old wisdom “if one version of the operating system finally behaves, go install a new one”. Anyway, the example I am giving today explores a new service added in System 6.0 under MultiFinder; the notification manager.

This is one of the little things - one might say - added on the way to ‘Real Inter-Process Communication’, and it is responsible for the little printer icon you see flashing with the Apple symbol in the menu bar when your background printer has a problem, or the clock icon when your alarm clock goes off.

Actually, this month’s program deals with many different things, the notification manager being only one of them. I wanted to create some useful utility that can keep track of appointments and remind me if something’s coming up, just like the Reminder DA in one of my recent columns. However, this time I wanted to be able to enter date and time in a well-readable format, and also keep a file with the appointments that is automatically read in on startup and updated on exit. It turned out that doing these things in a nice way required some use of the list manager and a user item in a modeless dialog; so the example will show you some of those things as well.

The Plan

The program consists of a modeless dialog window which displays a list of appointments with their dates and corresponding messages. Selection, updating and scrolling of the list is handled by the list manager. The dialog allows the user to edit a list item, add and delete appointments, and exit the program.

As long as the dialog window is up, a background task (easily created under Mach2) keeps doing the following things:

- Each time the list is changed (by adding/editing/ deleting things), it gets the time and message of the next upcoming appointment from the list.

- When the system time exceeds the time of the upcoming appointment, a Notification Manager (NM) request is set up. The NM then displays an alert message with the appointment message. After the message, the program gets the next appointment from the list.

- When the main dialog window is closed, the background task writes the appointment list back to the file and terminates the program.

Figure 1. Main dialog window of this month’s example

Implementation

First of all, we need to create a modeless dialog window that contains a list. Since that is not a standard dialog item, it has to be implemented as a user item. Just as a reminder: a user item is anything in a dialog that has to be drawn using our own procedure when the dialog is updated. A pointer to the drawing procedure is passed to the dialog manager by calling SetDItem, as described in TN34:

First call:

GetDItem  (DialogPtr, itemNo, type, item, box);

check if necessary whether type is really the type of a userItem, and then call

SetDItem  (DialogPtr, itemNo, type, @drawProc, box);

where @drawProc is a pointer to the user-supplied draw procedure. Note that it is really a pointer that is passed here, not a handle like in the case of other dialog items. DialogPtr, of course, is the pointer to the dialog window, where the item itemNo has been defined as a userItem, and box is the rectangle where the item will be drawn.

We can install a user item procedure from Mach2, but, if we just passed any Mach2 routine’s pointer to the SetDItem trap, the machine would crash gloriously when trying to draw the item, because the procedure is not called from the Mach2 context, but through the dialog manager. This means, glue code has to be written-something you should be used to by now.

In the example, the routine gUser provides this service, setting up space on the stack for the local Forth and DO...LOOP stacks, saving all the registers, and moving the dialog pointer and item numbers on the Forth stack. It then calls the UserDraw procedure and cleans up after it has returned.

List Manager

Our user item will contain a list. How do we handle it? IM Vol.IV describes the List Manager routines, and using those the job becomes pretty easy. I am not going to review the List Manager in detail; IM gives a pretty good description, and we also had an article last year describing the list manager (V3#4).

For the drawing procedure, all we need is a call to LUpdate, which redraws the list. This is implemented in UserDraw (see Listing). However, here we assume the list has already been setup. This is done at the start of the program, calling installUserDraw which calls MakeList. The latter routine (taken from Palo Alto Shipping’s ListManager example) creates a list in a given rectangle and window with vertical and horizontal cell size given in pixels. Looking at the example you will also notice that our list has a vertical scroll bar; the list manager handles scrolling automatically. Note that the list rectangle was inset by one pixel with respect to the user item rectangle, except for the right side where the scroll bar appears, where it had to be inset by 16 pixels (the scroll bar is drawn outside the list). After the list is created, its handle is stored in a variable for further use.

We now need a handler for mouse down events in the user item; and also routines that will allow us to edit, add and delete list items when the appropriate buttons in the modeless dialog are pushed. The words userList-handler, userEdit, userAdd, and userDelete are provided for this purpose.

Mouse down events in the user item are handled by userList-handler. It calls LClick with the local mouse position, the modifiers word of the event record and the list handle. (Note that event-record is a Mach2 system variable which points to the latest event record). LClick handles selection of list elements, highlighting, scrolling, and double clicks. If a list item is double-clicked, the userEdit procedure is called; otherwise, the routine just returns, with the list selection changed.

userEdit and userAdd set up a modal dialog which allow a date and text to be entered into a message field. While userAdd adds a new field at the end of the list, userEdit takes the current selection, puts the date and message into the modal dialog, and lets the user edit it. getMsg is the routine that parses the message string into its date and message fields and displays the edit dialog. update-cell writes the current date/message string into the selected cell. userDelete simply deletes the currently selected cell.

A number of things could be improved here: mainly, I did not implement automatic sorting by date when a list item is added or edited. This is straightforward and would require one or two more pages of code; since it is not really essential for the operation, I’m leaving it as an exercise for you.

The list is initially filled from a file called ‘dates’ which has to be in the same folder as the application. If it doesn’t exists, it will be created. dates contains the date/message strings, separated by carriage returns, and can be edited like any text file. fill-list opens - or creates - the file, reads the strings and adds rows to the list. At the end of the program, write-list writes the list back to the file. This way, by making the program one of your Multifinder startup applications, you will be automatically reminded of any upcoming appointment that was entered into the list.

Modeless Dialog Handling in Mach2

What has to be done to handle modeless dialogs correctly in a multitasking environment like Mach2? Since events are handled for us by the I-O task, we need not - and should not - call WaitNextEvent, IsDialogEvent, or DialogSelect from our program. This has already been done for us. All we need to do to connect a modeless dialog window with one particular task is install the task pointer in the dialog window’s refCon field. The I-O task will look at the front window’s refCon and pass the event information to the owning task. In the case of a dialog event it will put the dialog pointer and the item number into the user variables DialogHandle and DialogData (offsets 140 and 136). When data is stored there, the owning task will run the modeless dialog handling routine whose pointer is stored in the user variable modelessVector (offset 132). This routine gets passed the item number and the dialog pointer. Our program uses the word dialog-handler to call the handlers for the individual dialog items. The pointer to this routine is installed on starting up the task; likewise we install a pointer to a menu handling routine, which allows to handle desk accessories, a simple file menu which can only quit the program, and an Edit menu which allows for editing in desk accessories (in case you ever want to run this program from the finder, which is not very likely). Setting up the menus and menu handlers should be self-explanatory from the listing.

The Main Program

The main program window is hidden behind the menu bar, its coordinates being (1,1,16,16). This is because Mach2 can only assign a menu bar to a terminal task, therefore we need a main window. I have not tried whether - since we also have the dialog window associated with the task - the main window can be simply made invisible by calling HideWindow, so I simply used the ‘tiny-window-behind-menu-bar’ method that one would use in Mach2 for having menus without a window.

The main task loop does two things:

- checks whether an appointment has ‘matured’ and must be displayed using the Notification Manager (check_next_date);

- checks whether the dialog window is still visible. If it is not, the user has closed it and the program should write the list back to the file and exit (check_dialog_up).

A flag, nmChanged, is kept to indicate whether check_next_date should search the list for the next appointment due or simply compare the time of the last appointment read with the system time. The flag is set by the list editing routines, and by check_next_date itself when it has displayed an appointment. It is reset by the routine that gets the next appointment from the list. check_next_date calls say_it when the system time has exceeded the time of the appointment. say_it (finally!) calls the Notification Manager.

Notifying the User

The actual notification routine, as it turns out, is the smallest part of the program and of my column. say_it first checks the flag, nmPresent, which has been set at startup time to indicate whether the NM traps are present. If not, we’re running under an older system version, and say_it simply beeps. Otherwise, it calls notify-request, our glue routine to the NMInstall trap. The NM traps are explained in TN184, and I’ll repeat some of the information here.

notify-request takes the following parameters from the stack:

mark, contains 1 if the application should be marked in the Apple menu, 0 if not, or the reference number of a desk accessory to mark that desk accessory.

SIcon, contains a handle (non-purgeable) to a SICN resource if a small icon should flash with the Apple icon in the menu bar, 0 otherwise.

sound, contains a handle to a sound record to be played with SndPlay if a special sound is to be played on the notification; 0 if no sound should be made and -1 for the system beep.

str, a pointer to a string to appear in the NM alert box, or 0 if no alert.

resp, a pointer to a response procedure. This is explained in more detail in TN184; we simply use -1 to indicate the standard system response procedure which simply removes the NM request from the queue. If 0 is passed, no response procedure is called, and the program itself would be responsible for removing the NM request using NMRemove.

refCon, a constant available for general use, TN184 suggest to store A5 of the calling program here to allow access to the application globals.

myNMRec will contain the NM record in the format given in TN184, and NMInstall is called passing its address in A0.

That’s it; the alert will come up when an appointment is due if you let the ‘appts’ application (provided on the source code disk) turn in the background. Try to experiment with the other NM options, the small icons and sounds.

One last remark: in some cases it might happen that not the actual appointment is displayed in the alert box, but the next one on the list. This happens when it takes the NM longer than one second to get the resources and display the alert. In that case, the background task will already have continued and put the next message string in the msgTxt global variable! This can be remedied by increasing the wait period (presently, 60 ticks) after calling say_it in check_next_date.

The necessary resources which have to be added to the MACH.RSRC file for running the program are given in Listing 2, in Rez format. Don’t forget to add a SIZE -1 resource as well, with the canBackground bit set, and a size of approx. 120K. Good luck.

Mach 2.14 (beta)

The latest news is a beta version 2.14 of Mach2, which I received recently; as you read this, 2.14 might be released, and I’ll give you a list of the main changes in one of the next columns. Here just a very brief summary:

- compiler optimization has been improved.

- local variable handling has been greatly improved, with the possibility to reserve blocks of local variable space (i.e. for parameter blocks), and customizing the local variable compiler.

- some words have been added, among them SHIFT which takes the function of SCALE that I previously defined.

- more trap words have been added to the system. The NM traps, which I defined here, are included.

- the disassembler has been enhanced, with listing of references to USER and global variables.

That’s it; till next month.

{1}
Listing 1: Notification Manager example
\ notification manager example System Ver 6.0 needed
\ JL 15.8.88

only forth definitions
also assembler also mac also i/o
decimal 

\ structure of a NM record

0CONSTANT qLink  \ pointer
4CONSTANT qType  \ integer
6CONSTANT nmFlags\ integer
8CONSTANT nmPrivate\ longint
12 CONSTANT nmReserved  \ integer
14 CONSTANT nmMark \ integer
16 CONSTANT nmSIcon\ handle
20 CONSTANT nmSound\ handle
24 CONSTANT nmStr\ StringPtr
28 CONSTANT nmResp \ ProcPtr
32 CONSTANT nmRefCon \ longint

8CONSTANT nmType
 
.TRAP _NMInstall $A05E
.TRAP _NMRemove  $A05F

CODE  NMInstall  ( NMRec -- result )
 MOVE.L (A6)+,A0
 _NMInstall
 MOVE.L D0,-(A6)
 RTS
END-CODE MACH

CODE  NMRemove ( NMRec -- result )
 MOVE.L (A6)+,A0
 _NMRemove
 MOVE.L D0,-(A6)
 RTS
END-CODE MACH

$5E CONSTANT nmTrap#
$9F CONSTANT unkTrap#

variable myNMRec 32 vallot
variable nmPresent 
 \ for checking whether the NM is implemented
variable nmChanged 
 \ flag for telling supervisor task
 \ that something has changed
variable nmSecs  
 \ time in seconds for next notify alert

: notify-request
 { mark SIcon sound str resp refCon | -- 
 nmPtr result }

 nmType mynmRec qType + w!
 mark   mynmRec nmMark + w!
 SIcon  mynmRec nmSIcon + !
 sound  mynmRec nmSound + !
 str    mynmRec nmStr + !
 resp   mynmRec nmResp + !
 refCon mynmRec nmRefCon + !

 mynmRec dup NMInstall
;

300 CONSTANT AppleID
301 CONSTANT FileID
302 CONSTANT EditID

2000 CONSTANT updID
2001 CONSTANT msgID

110 CONSTANT wVisible \ offset into window record

132 USER modelessVector
 60 USER fID

CREATE APPLESTRING  $01 C,  $14 C, 

NEW.WINDOW nmWindow

“ NM” nmWindow TITLE
1 1 16 16 nmWindow BOUNDS
Plain Visible NoCloseBox NoGrowBox nmWindow ITEMS

600 4000 TERMINAL nmTask

NEW.MBAR nmBar 

NEW.MENU AppleMenu
APPLESTRING AppleMenu TITLE
0 APPLEID AppleMenu BOUNDS
“ About Appointments ...;(-” AppleMenu ITEMS

NEW.MENU FileMenu
“ File” FileMenu TITLE
0 FileID FileMenu BOUNDS
“ Close;Quit”  FileMenu ITEMS

NEW.MENU EditMenu
“ Edit” EditMenu TITLE
0 EditID EditMenu BOUNDS
“ (Undo/Z;(-;Cut/K;Copy/C;Paste/V;Clear” EditMenu ITEMS

VARIABLE DAName 60 VALLOT
VARIABLE updStore 160 VALLOT 
 \ for ‘update appointments’ dialog
VARIABLE updPtr
VARIABLE msgPtr  \ for storing the dialog pointers
VARIABLE updRect 4 vallot
VARIABLE hUpdList\ stores list handle
VARIABLE listRows\ total # of rows in list 
VARIABLE datim 10 VALLOT 
 \ 14 bytes for date-time record
VARIABLE msgTxt 252 VALLOT 
 \ 256 bytes for item text

\ ***** list manager support

\ List Manager select flags.
128CONSTANT OnlyOne
 64CONSTANT ExtendDrag
 32CONSTANT NoDisjoint
 16CONSTANT NoExtend
  8CONSTANT NoRect
  4CONSTANT UseSense
  2CONSTANT NoNilHilite
  
\ Offsets into the List record
 12CONSTANT IndentOffset
 36CONSTANT SelFlags
 80CONSTANT LDataHandle

CREATE ArrayDim  \ Initially we will have an empty array.
 \ We’ll add rows and columns later.
 0 W,   \ Row-o.
 0 W,   \ Column-o.
 0 W,   \ Row-i.
 1 W,   \ Column-i.

: NewVList ( rview databounds size wPtr - lhandle )
 0 \ LDEF proc id
 swap \ window pointer
 0 \ DrawIt flag
 0 \ HasGrow flag
 0 \ scrollHoriz flag
 -1\ scrollVert flag
 (CALL) LNew
;

: MakeList { rect vcell hcell wPtr | 
 lhandle cellpt rectbr recttl -- lhandle }
 rect  @ $10001 + -> recttl
 rect 4 + @ $10010 - -> rectbr
 ^ recttl \ Pass rectangle.
 ArrayDim \ Pass bounds.
 vCell ^ cellpt W!
 hCell ^ cellpt 2+ W!
 cellpt \ Pass cell size.
 wPtr
 NewVList -> lhandle
 
 OnlyOne NoNilHilite +    
 \ Select only one cell at a time.
 lhandle @ SelFlags + C!  
 \ Don’t hilite empty cells.
 lhandle
;

: read1line { ^pfile string | pStr char -- flag }
 string -> pStr
 BEGIN
 ^pfile @ virtual c@ -> char
 1 ^pfile +!
 char 0= char 13 = OR 0= WHILE
 1 +> pStr 
 char pStr c!
 REPEAT
 pStr string - string c!
 char
;
 
: open-dates-file
 “ Dates” $open dup 0< 
 IF drop “ Dates” dup 
 $create drop 
 $open 
 THEN
 fID w!
;

: fill-list { | pfile theCell -- }
 0 listRows !
 open-dates-file
 0 -> pfile
 BEGIN
 ^ pfile msgTxt read1line WHILE
 1 listRows @ hupdList @ call LAddRow drop
 0 -> theCell
 listRows @ ^ theCell w!
 1 listRows +!
 msgtxt count theCell hupdList @ call LSetCell
 REPEAT
 fID w@ closefile
 -1 hUpdList @ call LDoDraw 
 hupdList @ call LAutoScroll
;

: write-list { | len theCell offset -- }
 open-dates-file
 0 -> offset
 listRows @ 0 DO
 0 -> theCell  i ^ theCell w!
 0 -> len  255 ^ len w!
 msgTxt ^ len theCell hUpdList @
 call LGetCell
 ^ len w@ -> len
 13 msgTxt len + c!
 1 +> len
 offset len msgTxt fID w@ write
 len +> offset
 LOOP
 0 msgtxt c!
 offset 1 msgTxt fID w@ write
 offset 1+ fID w@ setEOF
 fID w@ closefile
;

\ UserDraw procedure
\ must use (call) instead of call and use glue code
\ for saving registers and setting up Forth stack

: UserDraw { theDlg theItem | iType iHdl rectbr recttl -- }
 
 theDlg theItem ^ iType ^ iHdl ^ recttl
 (call) GetDItem
 ^ recttl (call) FrameRect
 theDlg 24 + @   \ visRgn of dialog window
 hUpdList @ \ list handle
 (call) LUpdate
;

\ UserDraw procedure glue code
\ sets up local stack etc.

CODE gUser
 LINK A6,#-512   ( 512 bytes of local Forth stack )
 MOVEM.L A0-A5/D0-D7,-(A7)( save registers )
 MOVE.L A6,A3    ( setup local loop return stack )
 SUBA.L #256,A3  ( in the low 256 local stack bytes )
 CLR.L  D1
 MOVE.W 8(A6),D1 ( theItem )
 MOVE.L 10(A6),D0( theDialog )
 MOVE.L D0,-(A6)
 MOVE.L D1,-(A6)

 UserDraw

 MOVEM.L (A7)+,A0-A5/D0-D7( restore registers )
 UNLK A6
 MOVE.L (A7)+,A0 ( return address )
 ADD.W  #6,A7    ( pop off 6 bytes of parameters )
 JMP    (A0)
 RTS
END-CODE MACH

: update-cell { string | theCell -- }
 0 -> theCell
 -1 ^ theCell hupdList @ call LGetSelect
 IF
 string count theCell hupdList @ 
 call LSetCell
 THEN
;

: getText { dlgPtr item# string | iType iHdl iBox -- string }
 dlgPtr item# ^ iType ^ iHdl ^ iBox
 call GetDItem
 iHdl string call GetIText
 string
;
 
: setText { dlgPtr item# string | iType iHdl iBox -- }
 dlgPtr item# ^ iType ^ iHdl ^ iBox
 call GetDItem
 iHdl string call SetIText
;

: setup-msg { editDlg string | -- string }
 editDlg  8 string getText ( year )
 editDlg  9 string 3 + getText ( month )
 editDlg 10 string 6 + getText ( day )
 editDlg 11 string 9 + getText ( hour )
 editDlg 12 string 12 + getText ( min )
 editDlg 13 string 15 + getText ( sec )

 editDlg 3 string 18 + getText ( message )
 c@ 18 + string c!

 ascii / dup string 3 + c! string 6 + c!
 32 string 9 + c! 32 string 18 + c!
 ascii : dup string 12 + c! string 15 + c!
 string
;

: parse-msg { string | sPtr -- }
 string c@ 18 - string 18 + c!
 6 0 do 
 string i 3 * + -> sPtr
 2 sPtr c!
 sPtr call stringtonum
 datim i 2* + w!  
 loop
 datim w@ 1900 + datim w!
;

: set-dlg { editDlg string | -- }
 editDlg  8 string setText ( year )
 editDlg  9 string 3 + setText ( month )
 editDlg 10 string 6 + setText ( day )
 editDlg 11 string 9 + setText ( hour )
 editDlg 12 string 12 + setText ( min )
 editDlg 13 string 15 + setText ( sec )
 editDlg 3 string 18 + setText ( message )   
;

: getMsg { text | editDlg itemHit iTyp iHdl iBox
 -- string_or_zero }
 msgID 0 -1 call GetNewDialog -> editDlg
 text parse-msg
 editDlg text set-dlg
 0 ^ itemHit call ModalDialog
 ^ itemHit w@ CASE
 1 OF editDlg msgTxt setup-msgENDOF
 2 OF ( Cancel ) 0 ENDOF
 ENDCASE
 editDlg call DisposDialog
;

: userEdit { | theCell len -- }
 0 -> theCell
 -1 ^ theCell hupdList @ call LGetSelect
 IF
 255 ^ len w!
 msgTxt 1+ ^ len theCell hupdList @ call LGetCell
 ^ len w@ msgtxt c!
 msgtxt getMsg ?dup IF
 update-cell 
 THEN
 THEN
 nmChanged on
;

: userAdd  { | theCell -- }
 “ yy/mm/dd hh:mm:ss Your message - “ 
 dup c@ 1+ msgtxt swap cmove
 msgtxt getMsg IF 
 0 -> theCell
 -1 ^ theCell hupdList @ call LGetSelect
 IF 0 theCell hUpdList @ call LSetSelect THEN            
 1 listRows @ hupdList @ call LAddRow
 0 -> theCell
 listRows @ ^ theCell w!
 1 listRows +!
 msgtxt count theCell hupdList @ call LSetCell
 -1 theCell hUpdList @ call LSetSelect
 hupdList @ call LAutoScroll
 THEN
 nmChanged on
;

: userDelete { | theCell -- }
 0 -> theCell
 -1 ^ theCell hupdList @ call LGetSelect
 IF
 1 ^ theCell w@ hupdList @ call LDelRow
 -1 listRows +!
 THEN
 nmChanged on
;

: userList-handler { | thePt thePort -- }
 ^ thePort call getPort
 call frontwindow call setport 
 ^ thePt call getMouse    
 thePt event-record modifiers + w@ 
 hUpdList @
 call LClick
 IF ( double click ) userEdit THEN
 thePort call setPort
;

: CloseMe
 updPtr @ call CloseDialog
;

: QuitMe CloseMe ;

: dialog-handler 
 { itemHit dlgPtr | -- }

 itemHit CASE 
 1 OF CloseMe  ENDOF
 2 OF userEdit   ENDOF
 3 OF userAdd  ENDOF
 4 OF userDelete ENDOF

 5 OF userList-handler  ENDOF
 ENDCASE
;

: installupdPtr
 updPtr @ ?dup IF
 nmTask @ 2+ call SetWRefCon
 ELSE
 cr .” Couldn’t create dialog”
 ABORT
 THEN
;

: installuserDraw { pUser | iType iHdl rectbr recttl -- }
 updPtr @ 5 ^ iType ^ iHdl ^ recttl
 call GetDItem 
 updPtr @ 5 ^ iType w@  pUser ^ recttl
 call SetDItem 
 ^ recttl 16 280 updPtr @ MakeList 
 hUpdList !
;

: UndoMe ;
: CutMe ;
: CopyMe ;
: PasteMe ;
: ClearMe ;

: do-about
 128 0 CALL Alert DROP
;

: do-apple   { item# }
 \ item# = 1 (About...)?
 item# 1 =  
 IFdo-about
 ELSE
 Applemenu @ item# DAName CALL GetItem
 DAName CALL OpenDeskAcc DROP
 THEN ;

: DO-FILE ( item# -  )  
 ( handles selections from the file menu )
 CASE
 1 OF   CloseMe  ENDOF
 2 OF    QuitMe  ENDOF
 ENDCASE  
;

: DO-EDIT ( item# - )
 ( handles selections from the edit menu )
 dup 1- call SysEdit ( item# flag )
 0= IF
 CASE
 1 OF UndoMeENDOF
 3 OF CutMe ENDOF
 4 OF CopyMeENDOF
 5 OF PasteMe    ENDOF
 6 OF ClearMe    ENDOF
 ENDCASE  
 THEN
;
 
: nmBAR-handler  ( item# menuID -  ) 
 CASE   
 APPLEID OF DO-APPLE    ENDOF
 FILEID  OF DO-FILE  ENDOF
 EDITID OF DO-EDIT ENDOF
 ENDCASE  
 0 CALL HILITEMENU  
;

\ setup notify request with text in (msgTxt + 18)

: say_it 
 nmPresent @ IF
 1 ( mark )
 0 ( no Icon )
 -1 ( system beep )
 msgTxt 18 + ( string to display )
 -1 ( remove request )
 0 ( no refCon )
 notify-request
 2drop
 ELSE 
 5 call sysbeep 
 THEN
;

: get_time { | time -- secs }
 ^ time call readdatetime drop @
;

: get_next_date { | len theCell secs -- }
 listRows @ 0 DO
 0 -> theCell i ^ theCell w!
 255 ^ len w!
 msgTxt 1+ ^ len theCell hupdList @ call LGetCell
 ^ len w@ msgtxt c!
 msgtxt parse-msg
 datim call date2secs -> secs
 get_time secs u< IF leave THEN
 -1 -> secs \ in case no date matches
 LOOP
 secs nmSecs !
 nmChanged off
;

: wait { ticks | time -- }
 call tickcount ticks + -> time
 begin
 pause
 call tickcount time > 
 until
;

: check_next_date 
 nmChanged @ IF get_next_date THEN
 nmSecs @ get_time
 u< IF 
 say_it
 60 wait 
 nmChanged on 
 THEN 
;

: check_dialog_up
 updPtr @ wVisible + c@
 0= IF write-list bye
 THEN
;

: go.nm 
 ACTIVATE
 fill-list
 [‘] dialog-handler modelessVector !
 [‘] nmBar-handler menu-vector !
 nmWindow dup call showWindow
 call selectWindow
 updPtr @ dup call showWindow
 call selectWindow
 call DrawMenuBar
 begin  
 PAUSE 
 check_next_date
 check_dialog_up
 again
;

: nmPresent?
 NMTrap# CALL GetTrapAddress
 UnkTrap# CALL GetTrapAddress
 = IF 0 ELSE 1 THEN
 nmPresent !
;

: start 
 nmPresent?
 nmWindow ADD
 nmWindow nmTask BUILD

 nmBar ADD
 nmBar AppleMenu ADD
 AppleMenu @ ascii DRVR CALL AddResMenu
 nmBar FileMenu ADD
 nmBar EditMenu ADD
 nmBar nmTask mbar>task

 updID updStore -1 call GetNewDialog
 updPtr !

 installupdPtr
 [‘] gUser installUserDraw

 nmChanged on
 nmTask go.nm 
;
{2}
Listing 2: Resources for example (MPW Rez format)
resource ‘DITL’ (2000, “date list”) {
 { /* array DITLarray: 5 elements */
 /* [1] */
 {272, 328, 296, 392},
 Button {
 enabled,
 “Exit”
 },
 /* [2] */
 {168, 328, 192, 392},
 Button {
 enabled,
 “Edit”
 },
 /* [3] */
 {200, 328, 224, 392},
 Button {
 enabled,
 “Add...”
 },
 /* [4] */
 {232, 328, 256, 392},
 Button {
 enabled,
 “Delete”
 },
 /* [5] */
 {8, 8, 312, 312},
 UserItem {
 enabled
 }
 }
};

resource ‘DITL’ (2001, “appt text”) {
 { /* array DITLarray: 15 elements */
 /* [1] */
 {160, 256, 184, 320},
 Button {
 enabled,
 “OK”
 },
 /* [2] */
 {160, 336, 184, 408},
 Button {
 enabled,
 “Cancel”
 },
 /* [3] */
 {49, 10, 145, 410},
 EditText {
 disabled,
 “”
 },
 /* [4] */
 {15, 275, 33, 295},
 StaticText {
 disabled,
 “:”
 },
 /* [5] */
 {15, 235, 33, 255},
 StaticText {
 disabled,
 “:”
 },
 /* [6] */
 {15, 129, 33, 149},
 StaticText {
 disabled,
 “/”
 },
 /* [7] */
 {15, 89, 33, 109},
 StaticText {
 disabled,
 “/”
 },
 /* [8] */
 {16, 58, 32, 86},
 EditText {
 disabled,
 “”
 },
 /* [9] */
 {16, 101, 32, 127},
 EditText {
 disabled,
 “”
 },
 /* [10] */
 {16, 140, 32, 167},
 EditText {
 disabled,
 “”
 },
 /* [11] */
 {16, 205, 32, 231},
 EditText {
 disabled,
 “”
 },
 /* [12] */
 {16, 244, 32, 271},
 EditText {
 disabled,
 “”
 },
 /* [13] */
 {16, 284, 32, 312},
 EditText {
 disabled,
 “”
 },
 /* [14] */
 {16, 8, 32, 50},
 StaticText {
 disabled,
 “Date:”
 },
 /* [15] */
 {16, 176, 32, 196},
 StaticText {
 disabled,
 “at”
 }
 }
};

resource ‘DITL’ (128, “About Appts”) {
 { /* array DITLarray: 2 elements */
 /* [1] */
 {159, 82, 188, 151},
 Button {
 enabled,
 “Okay <0>”
 },
 /* [2] */
 {35, 28, 128, 192},
 StaticText {
 disabled,
 “Appointment reminder - \nNotification Man”
 “ager example\n© 1988 J. Langowski / MacTu”
 “tor”
 }
 }
};

resource ‘DLOG’ (2000, “date list”) {
 {54, 38, 380, 446},
 noGrowDocProc,
 invisible,
 goAway,
 0x0,
 2000,
 “Appointments”
};

resource ‘DLOG’ (2001, “appt text”) {
 {48, 16, 248, 440},
 dBoxProc,
 visible,
 noGoAway,
 0x0,
 2001,
 “Edit Appointment”
};

resource ‘ALRT’ (128, “About Appts”) {
 {40, 40, 240, 280},
 128,
 { /* array: 4 elements */
 /* [1] */
 Cancel, visible, silent,
 /* [2] */
 Cancel, visible, silent,
 /* [3] */
 Cancel, visible, silent,
 /* [4] */
 Cancel, visible, silent
 }
};
 
AAPL
$102.47
Apple Inc.
+0.00
MSFT
$44.88
Microsoft Corpora
+0.00
GOOG
$526.54
Google Inc.
+0.00

MacTech Search:
Community Search:

Software Updates via MacUpdate

Apple Security Update 2014-005 - For OS...
Apple Security Update is recommended for all users and improves the security of Mac OS X. For information on the security content of this update, please visit this website: http://support.apple.com/... Read more
EyeTV 3.6.6 - Watch and record TV on you...
EyeTV brings a rich TV experience to your Mac. Watch live TV on your Mac. Pause, rewind, and record whenever you want. EyeTV gives you powerful control over what you watch and how you watch it. Put... Read more
RapidWeaver 6.0 - Create template-based...
RapidWeaver is a next-generation Web design application to help you easily create professional-looking Web sites in minutes. No knowledge of complex code is required, RapidWeaver will take care of... Read more
NTFS 12.0.39 - Provides full read and wr...
Paragon NTFS breaks down the barriers between Windows and OS X. Paragon NTFS effectively solves the communication problems between the Mac system and NTFS, providing full read and write access to... Read more
RestoreMeNot 2.0.3 - Disable window rest...
RestoreMeNot provides a simple way to disable the window restoration for individual applications so that you can fine-tune this behavior to suit your needs. Please note that RestoreMeNot is designed... Read more
Macgo Blu-ray Player 2.10.9.1750 - Blu-r...
Macgo Mac Blu-ray Player can bring you the most unforgettable Blu-ray experience on your Mac. Overview Macgo Mac Blu-ray Player can satisfy just about every need you could possibly have in a Blu-ray... Read more
Apple iOS 8.1 - The latest version of Ap...
The latest version of iOS can be downloaded through iTunes. Apple iOS 8 comes with big updates to apps you use every day, like Messages and Photos. A whole new way to share content with your family.... Read more
TechTool Pro 7.0.5 - Hard drive and syst...
TechTool Pro is now 7, and this is the most advanced version of the acclaimed Macintosh troubleshooting utility created in its 20-year history. Micromat has redeveloped TechTool Pro 7 to be fully 64... Read more
PDFKey Pro 4.0.2 - Edit and print passwo...
PDFKey Pro can unlock PDF documents protected for printing and copying when you've forgotten your password. It can now also protect your PDF files with a password to prevent unauthorized access and/... Read more
Yasu 2.9.1 - System maintenance app; per...
Yasu was originally created with System Administrators who service large groups of workstations in mind, Yasu (Yet Another System Utility) was made to do a specific group of maintenance tasks... Read more

Latest Forum Discussions

See All

Reshape Review
Reshape Review By Jennifer Allen on October 22nd, 2014 Our Rating: :: SIMPLE SHAPESUniversal App - Designed for iPhone and iPad Match triangles together to form cubes in this fast-paced and twitchy game.   | Read more »
Miika (Games)
Miika 1.0.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.0 (iTunes) Description: Miika is a beautiful 3D puzzle game based on camera perspectives combined with the use of optical illusions. Miika challenges... | Read more »
Infuse Pro (Photography)
Infuse Pro 3.0 Device: iOS Universal Category: Photography Price: $9.99, Version: 3.0 (iTunes) Description: ** All-new version 3 includes fully licensed and certified DTS® and DTS-HD® audio! ** | Read more »
Swap Heroes (Games)
Swap Heroes 1.0 Device: iOS Universal Category: Games Price: $.99, Version: 1.0 (iTunes) Description: **Half price for a limited time only** Swap Heroes is a casual turn-based strategy adventure. Form a group of heroes and guide them... | Read more »
Ghost Blade (Games)
Ghost Blade 1.1 Device: iOS Universal Category: Games Price: $4.99, Version: 1.1 (iTunes) Description: Get the most outstanding 3D Action Game from App Store NOW! For those who dare pursue dreams. Masterpiece of Yu Shi Game ---China... | Read more »
Fiete – A Day on a Farm Review
Fiete – A Day on a Farm Review By Amy Solomon on October 21st, 2014 Our Rating: :: A MEMORABLE EXPERIENCEUniversal App - Designed for iPhone and iPad Fiete – A day on a farm in an interactive app for young children full of... | Read more »
Tilt to Live: Gauntlet’s Revenge is Almo...
Tilt to Live: Gauntlet’s Revenge is Almost Here Posted by Jessica Fisher on October 21st, 2014 [ permalink ] One Man Left has announced the official release date of Tilt to Live: Gauntlet’s Re | Read more »
Starfly Review
Starfly Review By Jennifer Allen on October 21st, 2014 Our Rating: :: CHANGE OF PACEiPad Only App - Designed for the iPad Want a slightly different browsing experience? Starfly is a pretty personalized one but it’s also buggy.   | Read more »
Sago Mini Monsters Celebrates Halloween...
Sago Mini Monsters Celebrates Halloween with Fun Costumes and Special Treats. Posted by Jessica Fisher on October 21st, 2014 [ permal | Read more »
The Bot Squad: Puzzle Battles – Tips, Tr...
01000010 01101111 01110100 01110011 00100001: Curious to know what we though about all this robot-on-robot carnage? Then check out our Bot Squad review! The Bot Squad: Puzzle Battles offers nearly 200 stages based on its varied approach to tower... | Read more »

Price Scanner via MacPrices.net

AT&T accepting preorders for new iPads fo...
AT&T Wireless is accepting preorders for the new iPad Air 2 and iPad mini 3, cellular models, for $100 off MSRP with a 2-year service agreement: - 16GB iPad Air 2 WiFi + Cellular: $529.99 - 64GB... Read more
Apple offering refurbished Mac Pros for up to...
The Apple Store is offering Apple Certified Refurbished 2013 Mac Pros for up to $600 off the cost of new models. An Apple one-year warranty is included with each Mac Pro, and shipping is free. The... Read more
Select MacBook Airs $100 off MSRP, free shipp...
B&H Photo has 2014 a couple of MacBook Airs on sale for $100 off MSRP. Shipping is free, and B&H charges NY sales tax only. They also include free copies of Parallels Desktop and LoJack for... Read more
13-inch 2.5GHz MacBook Pro on sale for $100 o...
B&H Photo has the 13″ 2.5GHz MacBook Pro on sale for $999.99 including free shipping plus NY sales tax only. Their price is $100 off MSRP. Read more
Strong iPhone, Mac And App Store Sales Drive...
Apple on Monday announced financial results for its fiscal 2014 fourth quarter ended September 27, 2014. The Company posted quarterly revenue of $42.1 billion and quarterly net profit of $8.5 billion... Read more
Apple Posts How-To For OS X Recovery
OS X 10.7 Lion and later include OS X Recovery. This feature includes all of the tools you need to reinstall OS X, repair your disk, and even restore from a Time Machine backup. OS X Recovery... Read more
Mac OS X Versions (Builds) Supported By Vario...
Apple Support has posted a handy resource explaining which Mac OS X versions (builds) originally shipped with or are available for your computer via retail discs, downloads, or Software Update. Apple... Read more
Deals on 2011 13-inch MacBook Airs, from $649
Daily Steals has the Mid-2011 13″ 1.7GHz i5 MacBook Air (4GB/128GB) available for $699 with a 90 day warranty. The Mid-2011 13″ 1.7GHz i5 MacBook Air (4GB/128GB SSD) is available for $649 at Other... Read more
2013 15-inch 2.0GHz Retina MacBook Pro availa...
B&H Photo has leftover previous-generation 15″ 2.0GHz Retina MacBook Pros now available for $1599 including free shipping plus NY sales tax only. Their price is $400 off original MSRP. B&H... Read more
Updated iPad Prices
We’ve updated our iPad Air Price Tracker and our iPad mini Price Tracker with the latest information on prices and availability from Apple and other resellers, including the new iPad Air 2 and the... Read more

Jobs Board

Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
*Apple* Retail - Multiple Positions (US) - A...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
Position Opening at *Apple* - Apple (United...
…customers purchase our products, you're the one who helps them get more out of their new Apple technology. Your day in the Apple Store is filled with a range of Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.