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
$97.03
Apple Inc.
-0.16
MSFT
$44.40
Microsoft Corpora
-0.47
GOOG
$593.35
Google Inc.
-2.63

MacTech Search:
Community Search:

Software Updates via MacUpdate

Audio Hijack Pro 2.11.0 - Record and enh...
Audio Hijack Pro drastically changes the way you use audio on your computer, giving you the freedom to listen to audio when you want and how you want. Record and enhance any audio with Audio Hijack... Read more
Intermission 1.1.1 - Pause and rewind li...
Intermission allows you to pause and rewind live audio from any application on your Mac. Intermission will buffer up to 3 hours of audio, allowing users to skip through any assortment of audio... Read more
Airfoil 4.8.7 - Send audio from any app...
Airfoil allows you to send any audio to AirPort Express units, Apple TVs, and even other Macs and PCs, all in sync! It's your audio - everywhere. With Airfoil you can take audio from any... Read more
Microsoft Remote Desktop 8.0.8 - Connect...
With Microsoft Remote Desktop, you can connect to a remote PC and your work resources from almost anywhere. Experience the power of Windows with RemoteFX in a Remote Desktop client designed to help... Read more
xACT 2.30 - Audio compression toolkit. (...
xACT stands for X Aaudio Compression Toolkit, an application that encodes and decodes FLAC, SHN, Monkey’s Audio, TTA, Wavpack, and Apple Lossless files. It also can encode these formats to MP3, AAC... Read more
Firefox 31.0 - Fast, safe Web browser. (...
Firefox for Mac offers a fast, safe Web browsing experience. Browse quickly, securely, and effortlessly. With its industry-leading features, Firefox is the choice of Web development professionals... Read more
Little Snitch 3.3.3 - Alerts you to outg...
Little Snitch gives you control over your private outgoing data. Track background activityAs soon as your computer connects to the Internet, applications often have permission to send any... Read more
Thunderbird 31.0 - Email client from Moz...
As of July 2012, Thunderbird has transitioned to a new governance model, with new features being developed by the broader free software and open source community, and security fixes and improvements... Read more
Together 3.2 - Store and organize all of...
Together helps you organize your Mac, giving you the ability to store, edit and preview your files in a single clean, uncluttered interface. Smart storage. With simple drag-and-drop functionality,... Read more
Cyberduck 4.5 - FTP and SFTP browser. (F...
Cyberduck is a robust FTP/FTP-TLS/SFTP browser for the Mac whose lack of visual clutter and cleverly intuitive features make it easy to use. Support for external editors and system technologies such... Read more

Latest Forum Discussions

See All

LEX Goes Free For One Day In Honor of Ne...
LEX Goes Free For One Day In Honor of New Update Posted by Jennifer Allen on July 24th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Thomas Was Alone Goes Universal, Slashes...
Thomas Was Alone Goes Universal, Slashes Price to $3.99 Posted by Ellis Spice on July 24th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Meerkatz Challenge Review
Meerkatz Challenge Review By Jennifer Allen on July 24th, 2014 Our Rating: :: FONDLY PUZZLINGUniversal App - Designed for iPhone and iPad Cute and challenging, Meerkatz Challenge is a fun puzzle game, particularly for fans of... | Read more »
Book Your Appointment with F.E.A.R. this...
Book Your Appointment with F.E.A.R. | Read more »
It Came From Canada: Epic Skater
For all the hate that it gets for being a pastime for slackers, skateboarding really does require a lot of skill. All those flips and spins take real athleticism, and there’s all the jargon to memorize. Fortunately for us less extreme individuals,... | Read more »
Cultures Review
Cultures Review By Jennifer Allen on July 24th, 2014 Our Rating: :: SLOW-PACED EMPIRE BUILDINGiPad Only App - Designed for the iPad Cute it might seem, but Cultures is a bit too slow paced when it comes to those pesky timers to... | Read more »
More Paintings Have Been Added to Paint...
More Paintings Have Been Added to Paint it Back! Posted by Jessica Fisher on July 24th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
The Order of Souls Review
The Order of Souls Review By Campbell Bird on July 24th, 2014 Our Rating: :: STORY GRINDUniversal App - Designed for iPhone and iPad The Order of Souls is a free-to-play, turn-based RPG with a genre-mixing art style, interesting... | Read more »
Revolution 60 Review
Revolution 60 Review By Jordan Minor on July 24th, 2014 Our Rating: :: LASS EFFECTUniversal App - Designed for iPhone and iPad Revolution 60 is a bold, cinematic action game with ambition to spare.   | Read more »
Matter (Photography)
Matter 1.0.1 Device: iOS Universal Category: Photography Price: $1.99, Version: 1.0.1 (iTunes) Description: Add stunning 3D effects to your photos with real-time shadows and reflections. Export your creations as photos or video loops... | Read more »

Price Scanner via MacPrices.net

Save on 5th generation refurbished iPod touch...
The Apple Store has Apple Certified Refurbished 5th generation iPod touches available starting at $149. Apple’s one-year warranty is included with each model, and shipping is free. Many, but not all... Read more
What Should Apple’s Next MacBook Priority Be;...
Stabley Times’ Phil Moore says that after expanding its iMac lineup with a new low end model, Apple’s next Mac hardware decision will be how it wants to approach expanding its MacBook lineup as well... Read more
ArtRage For iPhone Painting App Free During C...
ArtRage for iPhone is currently being offered for free (regularly $1.99) during Comic-Con San Diego #SDCC, July 24-27, in celebration of the upcoming ArtRage 4.5 and other 64-bit versions of the... Read more
With The Apple/IBM Alliance, Is The iPad Now...
Almost since the iPad was rolled out in 2010, and especially after Apple made a 128 GB storage configuration available in 2012, there’s been debate over whether the iPad is a serious tool for... Read more
MacBook Airs on sale starting at $799, free s...
B&H Photo has the new 2014 MacBook Airs on sale for up to $100 off MSRP for a limited time. Shipping is free, and B&H charges NY sales tax only. They also include free copies of Parallels... Read more
Apple 27″ Thunderbolt Display (refurbished) a...
The Apple Store has Apple Certified Refurbished 27″ Thunderbolt Displays available for $799 including free shipping. That’s $200 off the cost of new models. Read more
WaterField Designs Unveils Cycling Ride Pouch...
High end computer case and bag maker WaterField Designs of San Francisco now enters the cycling market with the introduction of the Cycling Ride Pouch – an upscale toolkit with a scratch-free iPhone... Read more
Kingston Digital Ships Large Capacity Near 1T...
Kingston Digital, Inc., the Flash memory affiliate of Kingston Technology Company, Inc.,has announced its latest addition to the SSDNow V300 series, the V310. The Kingston SSDNow V310 solid-state... Read more
Apple’s Fiscal Third Quarter Results; Record...
Apple has announced financial results for its fiscal 2014 third quarter ended June 28, 2014, racking up quarterly revenue of $37.4 billion and quarterly net profit of $7.7 billion, or $1.28 per... Read more
15-inch 2.0GHz MacBook Pro Retina on sale for...
B&H Photo has the 15″ 2.0GHz Retina MacBook Pro on sale for $1829 including free shipping plus NY sales tax only. Their price is $170 off MSRP. B&H will also include free copies of Parallels... Read more

Jobs Board

Sr Software Lead Engineer, *Apple* Online S...
Sr Software Lead Engineer, Apple Online Store Publishing Systems Keywords: Company: Apple Job Code: E3PCAK8MgYYkw Location (City or ZIP): Santa Clara Status: Full Read more
Senior Interaction Designer, *Apple* Online...
**Job Summary** Apple is looking for a hands on Senior…will be a key player in designing for the Apple Online Store. The ideal designer will have a Read more
*Apple* Sales Chat Rep - Apple (United State...
…is looking for motivated, outgoing, and tech savvy individuals who want to offer Apple Customers an unparalleled customer experience over chat. At Apple , we believe Read more
Mac Expert - *Apple* Online Store Mexico -...
…MUST be fluent in English and Spanish to be considered for this position At Apple , we believe that hard work, a fun environment, creativity and innovation fuel the Read more
*Apple* Industrial Design CAD Sculptor - App...
**Job Summary** The Apple Industrial Design team is looking for a CAD sculptor/Digital 3D modeler to create high quality CAD models used in the industrial design process Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.