TweetFollow Us on Twitter

cdev Debugging
Volume Number:6
Issue Number:2
Column Tag:Pascal Procedures

Related Info: Control Panel Dialog Manager

CDEV Debugging

By J. Peter Hoddie, Palo Alto, CA

A cdev Shell

This article describes a shell program created to simplify the process of writing, testing, and debugging Control Panel devices. The shell is written in MPW Pascal (actually it was developed in TML Pascal II, but the two are compatible) and so is appropriate for use with cdev’s written in the MPW environment. The cdev shell has been tested with Apple’s SADE debugger. This article does not describe how to write a cdev. For the details on writing a cdev, including a working example, see Inside Macintosh Volume 5.

Without a cdev shell, the process of testing a cdev is less then simple. You must compile and link the cdev, place it in the system folder, and select the Control Panel. Under these circumstances you cannot use a source level debugger, only MacsBug. Using the cdev shell, you simply link your cdev with the shell code and run it as a normal application which gives you access to a source level debugger. The cdev shell has several features designed specifically for testing. The shell itself does not appear graphically identical to the Control Panel, however as far as the cdev itself is concerned there is no difference.

The cdev shell was designed not only to allow the use of a source level debugger, but also to provide a collection of features for easily testing the many messages to which a cdev is expected to respond. Further, because as you are developing a cdev you may not have written code to handle each messages, a dialog presented from the “Message Masks...” menu item allows you to filter out any combination of cdev messages. Your message mask settings are stored as a resource type ‘msks’ so that you don’t have to reset them each time you use the shell.

An option to force the cdev to update its entire window to test your drawing code is available as the “Force Update” menu item.

A small window named “Other Window” appears above and to the right of the Control Panel window. This window allows you to test the activate and deactivate messages by making the “Other Window” the active window. By covering areas of your cdev’s panel with the “Other Window” you can further test the screen updating capabilities of your cdev.

All of the options on the standard Edit menu are passed to the cdev as the corresponding cdev messages.

When you start up the cdev shell, the test cdev is not selected. Either click on its icon or select Open from the file menu. To close the cdev, select Close from the file menu or click on the stop sign icon. This allows you to test the open and close cdev messages multiple times without having to relaunch the cdev shell. By not immediately selecting the test cdev in the shell, you have the opportunity to set break points, modify the message masks, and perform any other required actions.

Tech Note #215 - “New” cdev Messages - describes a cdev message, cursorDev, that is not documented in Inside Macintosh. It states that if a ‘CURS’ -4064 (cursor) resource is present in the cdev file, that the cdev will receive a cursorDev message (number 14) whenever the cursor is inside the cdev’s window. This allows the cdev to have its own cursor as appropriate. The shell fully supports this new message.

The shell also checks that certain required resources are present. If a required resource is missing, an error message is generated and the shell aborts. The cdev resources that the shell must have to run are ‘DITL’, ‘mach’, ‘nrct’, and ‘ICN#’ all with ID -4064. The only required resources that the shell does not check for are the ‘cdev’ code, ‘BNDL’ and ‘FREF’ resources.

The shell does other error checking as appropriate. For example, the macDev message is only allowed to return one of two values. If any other value is returned, the shell issues a warning alert.

The shell will only send the cdev the macDev message if the values of the hard and soft masks in the ‘mach’ -4064 resource are set as documented in Inside Macintosh. Otherwise the shell compares these to HwCfgFlags and ROM85 in low memory as described in Inside Macintosh. While Inside Macintosh claims that HwCfgFlags is a low memory global, its location is never given. I had to fish it out of one the “private” MPW Assembler equates files.

This article does not include a sample cdev to use with the shell. It is currently set up to work with the Sample provide in Inside Macintosh Volume 5. The only call the cdev shell makes to code outside itself is to the entry point of the cdev unit that is being tested. The name of the unit that the cdev shell expects to find is “cdev” and the name of the main cdev routine (really its entry point) is “Sample” - exactly as the sample unit in Inside Macintosh.

There is one minor bug in the Sample cdev from Inside Macintosh. In the function EnoughRoomToRun the call to GetResource should be replaced with a call to RGetResource or the cdev will not run.

The shell is not a great example of how to write a Macintosh application. It clearly demonstrates what Tech Note #203 - Don’t Abuse the Managers - tries to drive home: the Dialog Manager is not a user interface! Unfortunately, since the Control Panel relies on the Dialog Manager, there was no choice for the cdev shell. Also, the shell was originally written in THINK C, and then translated to Pascal when I found out that a cdev shell was shipping with THINK C Version 4. Anyone who is interested in the C version may contact me directly for a copy. Converting the code presented in this article to run under THINK Pascal should be an easy task.

File: cdevShell.make

# Commands to build cdev Shell using MPW Pascal
#
# put the name of your cdev files in place of cdev.p, 
# cdev.p.o, and cdev.r below
#
    Pascal cdev.p -sym on
    Pascal cdevShell.p -sym on
    Link -w -t ‘APPL’ -c ‘????’ -sym on 
 cdev.p.o 
   cdevShell.p.o 
 “{Libraries}”Runtime.o 
 “{Libraries}”Interface.o 
 “{PLibraries}”PasLib.o 
 “{PLibraries}”SANELib.o
 -o cdevShell
    Rez -append -o cdevShell cdev.r
    Rez -append -o cdevShell cdevShell.r
File: cdevShell.p

PROGRAM cdevShell;

USES  MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf,
 cdev;

CONST
 cursorDev = 14;
 HwCfgFlgs = $0B22;
 ROM85 = $028E;

TYPE
 IntPtr = ^integer;
 IntHandle = ^IntPtr;
 RectPtr = ^rect;
 EventPtr = ^EventRecord;

PROCEDURE doMenu(l: longInt); FORWARD;
PROCEDURE updateDial;FORWARD;
PROCEDURE drawIcon(ih: Handle; selected: Boolean;
 r: Rect);FORWARD;
PROCEDURE startupCdev;  FORWARD;
PROCEDURE shutDownCdev; FORWARD;
PROCEDURE cdevInitDev;  FORWARD;
PROCEDURE cdevHitDev(item: integer; e: EventPtr);
 FORWARD;
PROCEDURE cdevUpdateDev;  FORWARD;
PROCEDURE cdevNulDev(e: EventPtr); FORWARD;
PROCEDURE cdevCloseDev; FORWARD;
PROCEDURE cdevEdit(c: integer);  FORWARD;
PROCEDURE cdevKeyEvtDev(e: EventPtr);FORWARD;
PROCEDURE cdevActivate(e: EventPtr); FORWARD;
PROCEDURE cdevMacDev;FORWARD;
PROCEDURE cdevCursorDev;  FORWARD;
PROCEDURE fatalError(s : Str255);  FORWARD;
PROCEDURE warningError(s : Str255);FORWARD;
PROCEDURE doMsgDialog;  FORWARD;
FUNCTION callCdev( msgCode : integer; item : integer;
 e : EventPtr; st : longInt) :longInt; FORWARD;
PROCEDURE doNRCTs; FORWARD;
PROCEDURE getNRCTrgn;FORWARD;
PROCEDURE HiliteDefault(d: DialogPtr); FORWARD;

VAR
 cdevDial:DialogPtr;
 dP:    DialogPeek;
 cdevItems: integer;
 userItems: integer;
 teWas: integer;
 cdevStorage:  longInt;

 nrctRgn: RgnHandle;
 greyRgn: RgnHandle;
 userArea:Rect;

 stopRect,
 startRect: Rect;
 myStopIcon,
 myStartIcon:  Handle;

 cursorIsArrow:  Boolean;
 cdevMsgOff:array[0 .. 16] of Boolean;
 selected:Boolean;
 running: Boolean;

 env:   SysEnvRec;
 entryVref: integer;
 otherWindow:  WindowPtr;
 error: integer;

 i,j:   integer;
 temp, cdevDITL: Handle;
 e:EventRecord;
 rH:    RgnHandle;
 whichWindow:  WindowPtr;
 key:   char;
 p:Point;
 s:Str255;
 hasCursor: Boolean;
 teH:   TEHandle;
 trashB:Boolean;

PROCEDURE doMenu(l: longInt);
VARmenu, choice, i:integer;
 daName:Str255;
 d:DialogPtr;
BEGIN
 menu := HiWord(l);
 choice := LoWord(l);
 
 case menu of
 1:BEGIN
 if choice = 1 then BEGIN
 d := GetNewDialog(132, nil, WindowPtr(-1));
 HiliteDefault(d);
 repeat
 ModalDialog(nil, i)
 until i = 1;
 DisposDialog(d);
 END;
 if choice > 1 then BEGIN
 GetItem(GetMHandle(1), choice, daName);
 error := OpenDeskAcc(daName);
 END;
 END;
 2:case choice of
 1: startupCdev;
 2: shutDownCdev;
 4: running := false;
 END;
 3:if FrontWindow = cdevDial then
 cdevEdit(choice)
 else
 trashB := SystemEdit(choice - 1);
 4:case choice of
 1: doMsgDialog;
 2: 
 InvalRect(GrafPtr(cdevDial)^.portRect);
 END; { of case }
 END; { of case }
 HiliteMenu(0);
END;

PROCEDURE updateDial;
VAR
 r:Rect;
 patHand: PatHandle;
 i:integer;
 h:Handle;
BEGIN
 SetPort(cdevDial);
 TextSize(9);
 
 PenSize(2,2);
 
 patHand := GetPattern(-16000);
 PenPat(patHand^^);
 PaintRgn(nrctRgn);
 PenPat(black);

 doNRCTs;
 r := cdevDial^.portRect;
 InsetRect(r, -2, -2);
 r.top := r.top + 1;
 FrameRect(r);

 GetDItem(cdevDial, 2, i, h, r);
 r.top := r.top - 2;
 r.bottom := r.bottom -1;
 r.left := r.left - 2;
 r.right := r.right + 1;
 FrameRect(r);

 GetDItem(cdevDial, 1, i, h, r);
 r.top := r.top - 2;
 r.bottom := r.bottom + 2;
 r.left := r.left - 2;
 r.right := r.right + 2;
 FrameRect(r);

 PenSize(1,1);

 drawIcon(myStopIcon, not selected, stopRect);
 drawIcon(myStartIcon, selected, startRect);
END;

PROCEDURE drawIcon(ih: Handle; selected: Boolean; r: Rect);
VAR
 iconBitMap:BitMap;
 fromR: Rect;
BEGIN
 SetRect(fromR, 0, 0, 32, 32);
 iconBitMap.rowBytes := 4;
 iconBitMap.bounds := fromR;
 HLock(iH);
 if (selected) then BEGIN
 iconBitMap.baseAddr := Ptr(ORD4(iH^) + longInt(128));
 CopyBits(iconBitMap, GrafPtr(cdevDial)^.portBits, fromR, r,
 srcCopy, nil);

 iconBitMap.baseAddr := ih^;
 CopyBits(iconBitMap, GrafPtr(cdevDial)^.portBits, fromR, r,
 srcXor, nil);
 END
 else BEGIN
 iconBitMap.baseAddr := ih^;
 CopyBits(iconBitMap, GrafPtr(cdevDial)^.portBits, fromR, r,
 srcCopy, nil);
 END;
 HUnlock(iH);
END;

PROCEDURE startupCdev;
VAR
 temp:  Handle;
 i,j,totalItems: integer;
 hardMask, softMask: integer;
 p:Ptr;
 c:ControlHandle;
 tempD: DialogPtr;
 r:Rect;
BEGIN
 selected := true;
 
 getNRCTrgn;
 
 temp := GetResource(‘mach’, -4064);
 if temp = nil then
 fatalError(‘mach -4064 resource not found’);
 softMask := IntHandle(temp)^^;
 hardMask := IntPtr(2+ORD4(temp^))^;
 if (softMask = 0) and (hardMask = $ffff) then BEGIN
 cdevMacDev;
 if cdevStorage = 0 then
 fatalError(‘cdev refuses to run on this machine’);
 if cdevStorage <> 1 then
 fatalError(‘Invalid result returned from macDev call’);
 END
 else BEGIN
 if integer(BitAnd(softMask, IntPtr(ROM85)^))
 <> Intptr(ROM85)^ then
 fatalError(‘cdev failed SoftMask test’);
 if integer(BitAnd(hardMask, IntPtr(HwCfgFlgs)^))
 <> hardMask then
 fatalError(‘cdev failed HardMask test’);
 END;
 ReleaseResource(temp);

 IntHandle(dP^.items)^^ := cdevItems + userItems;
 dP^.editField := teWas;
 if teWas <> -1 then
 TEActivate( dP^.textH);
 SetPort(cdevDial);
 TextSize(9);
 for i:= cdevItems + 1 to cdevItems + userItems do
 ShowDItem(cdevDial,i);

 doNRCTs;
 
 DisableItem(GetMHandle(2),1);
 EnableItem(GetMHandle(2), 2);

 cdevInitDev;

 InvalRect(GrafPtr(cdevDial)^.portRect);
END;

PROCEDURE shutDownCdev;
VARi: integer;
BEGIN
 cdevCloseDev;

 SetCursor(arrow);
 cursorIsArrow := true;

 if cdevStorage <> 0 then
 warningError(‘Close call did not return zero’);

 for i := cdevItems + 1 to cdevItems + userItems do
 HideDItem(cdevDial, i);
 
 IntHandle(dP^.items)^^ := cdevItems;
 dP^.editField := -1;
 if teWas <> -1 then
 TEDeactivate(dP^.textH);

 selected := false;

 getNRCTrgn;

 EnableItem(GetMHandle(2), 1);
 DisableItem(GetMHandle(2), 2);

 InvalRect(GrafPtr(cdevDial)^.portRect);
END;

PROCEDURE cdevInitDev;
BEGIN
 cdevStorage := callCdev(initDev, 0, nil, cdevUnset);
END;

PROCEDURE cdevHitDev(item: integer; e: EventPtr);
BEGIN
 cdevStorage := callCdev(hitDev, item, e, cdevStorage);
END;

PROCEDURE cdevUpdateDev;
BEGIN
 cdevStorage := callCdev(updateDev, 0, nil, cdevStorage);
END;

PROCEDURE cdevNulDev(e: EventPtr);
BEGIN
 cdevStorage := callCdev(nulDev, 0, e, cdevStorage);
END;

PROCEDURE cdevCloseDev;
BEGIN
 cdevStorage := callCdev(closeDev, 0, nil, cdevStorage);
END;

PROCEDURE cdevEdit(c: integer);
BEGIN
 case c of
 1:i := undoDev;
 3:   i := cutDev;
 4:i := copyDev;
 5:i := pasteDev;
 6:i := clearDev;
 END;
 cdevStorage := callCdev(i, 0, nil, cdevStorage);
END;

PROCEDURE cdevKeyEvtDev(e: EventPtr);
BEGIN
 cdevStorage := callCdev(keyEvtDev, 0, e, cdevStorage);
END;

PROCEDURE cdevActivate(e: EventPtr);
VARi:   integer;
BEGIN
 if BitAnd(e^.modifiers, activeFlag) <> 0 then
 i := activDev
 else
 i := deactivDev;
 cdevStorage := callCdev(i, 0, e, cdevStorage);
END;

PROCEDURE cdevMacDev;
BEGIN
 cdevStorage := callCdev(macDev, 0, nil, cdevStorage);
END;

PROCEDURE cdevCursorDev;
BEGIN
 cdevStorage := callCdev(cursorDev, 0, nil, cdevStorage);
END;

FUNCTION callCdev( msgCode : integer; item : integer; 
 e : EventPtr; st : longInt) :longInt;
 var  rValue:  longInt;
 error :integer;
BEGIN
 if (not selected) or (cdevMsgOff[msgCode]) 
 then BEGIN
 callCdev := st;
 exit(callCdev);
 END;

 SetPort(cdevDial);
 TextSize(9);
 error := SetVol(nil, env.sysVRefNum);
 rValue := Sample(msgCode, item, cdevItems, 0, e^,
 st, cdevDial);
 error := SetVol(nil, entryVref);

 if (msgCode <> macDev) and 
 (msgCode <> closeDev) then
 case rValue of
 cdevGenErr:fatalError(‘General cdev error’);
 cdevMemErr: fatalError(‘cdev insufficient memory error’);
 cdevResErr: fatalError
 (‘cdev could not locate needed resource’);
 END; { of case }
 callCdev := rValue;
END;

PROCEDURE fatalError(s : Str255);
BEGIN
 ParamText(s, ‘’, ‘’, ‘’);
 error := Alert(130, nil);
 ExitToShell;
END;

PROCEDURE warningError(s : Str255);
BEGIN
 ParamText(s, ‘’, ‘’, ‘’);
 error := Alert(131, nil);
END;

PROCEDURE doMsgDialog;
VARd:   DialogPtr;
 i,kind:integer;
 r:Rect;
 h:Handle;
BEGIN
 d := GetNewDialog(128, nil, WindowPtr(-1));
 HiliteDefault(d);

 for i:= initDev + 3 to cursorDev + 3 do BEGIN
 GetDItem(d, i, kind, h, r);
 kind := integer(cdevMsgOff[i-3]);
 if kind <> 0 then
 kind := 1;
 SetCtlValue(ControlHandle(h), kind);
 END;
 
 repeat
 ModalDialog(nil, i);
 if i > 2 then BEGIN
 GetDItem(d, i, kind, h, r);
 SetCtlValue(ControlHandle(h),
 ABS(GetCtlValue(ControlHandle(h)) - 1));
 END
 until i <= 2;

 if i = 1 then BEGIN
 for i:= initDev + 3 to cursorDev + 3 do BEGIN
 GetDItem(d, i, kind, h, r);
 cdevMsgOff[i-3] :=
 Boolean(GetCtlValue(ControlHandle(h)));
 END;
 h := GetResource(‘msks’, 128);
 if h <> nil then BEGIN
 BlockMove(Ptr(@cdevMsgOff), h^, 16);
 ChangedResource(h);
 WriteResource(h);
 END;
 END;

 DisposDialog(d);
END;

PROCEDURE doNRCTs;
VARh:   Handle;
 r:RectPtr;
 i:integer;
BEGIN
 if not selected then
 exit(doNRCTs);

 h := GetResource(‘nrct’, -4064);
 r := RectPtr(2 + ORD4(h^));
 for i:= 1 to IntHandle(h)^^ do BEGIN
 EraseRect(r^);
 FrameRect(r^);
 r := RectPtr(ORD4(r) + sizeof(Rect));
 END; { of loop }
 ReleaseResource(h);
END;

PROCEDURE getNRCTrgn;
VAR
 h:Handle;
 r:RectPtr;
 rct: Rect;
 i:integer;
 rRgn:  RgnHandle;
BEGIN
 if not selected then
 BEGIN
 SetRect(rct, 86, -1, 322, 255);
 nrctRgn := NewRgn;
 RectRgn(nrctRgn, rct);
 exit(getNRCTrgn);
 END;

 h := GetResource(‘nrct’, -4064);
 if h = nil then
 fatalError(‘nrct -4064 resource is missing’);
 nrctRgn := NewRgn;
 HLock(h);
 r := RectPtr(2+ORD4(h^));
 for i:= 1 to IntHandle(h)^^ do BEGIN
 rRgn := NewRgn;
 RectRgn(rRgn, r^);
 r := RectPtr(ORD4(r) + sizeof(Rect));
 UnionRgn(nrctRgn, rRgn, nrctRgn);
 DisposeRgn(rRgn);
 END; { of loop }
 HUnlock(h);
 ReleaseResource(h);

 SetRect(rct, 86, -1, 322, 255);
 rRgn := NewRgn;
 RectRgn(rRgn, rct);
 DiffRgn(rRgn, nrctRgn, nrctRgn);
 DisposeRgn(rRgn);
END;

PROCEDURE mvWindow(w: WindowPtr; p: Point);
VARtrashR:Rect;
BEGIN
 trashR := screenBits.bounds;
 InsetRect(trashR, 6, 6);
 DragWindow(w, p, trashR);
END;

PROCEDURE HiliteDefault(d: DialogPtr);
VARi:   integer;
 box:   Rect;
 h:Handle;
BEGIN
 SetPort(d);
 GetDItem(d, 1, i, h, box);
 PenSize(3,3);
 InsetRect(box, -4, -4);
 FrameRoundRect(box, 16, 16);
END;

PROCEDURE Initialize;
BEGIN
 InitGraf(@thePort);
 InitFonts;
 InitWindows;
 TEInit;
 InitDialogs(nil);
 InitCursor;
 cursorIsArrow := true;
 MaxApplZone;
 
 SetMenuBar( GetNewMBar(256) );
 AddResMenu( GetMHandle(1), ‘DRVR’);
 DrawMenuBar;
 DisableItem(GetMHandle(2),2);
 
 error := SysEnvirons(0, env);
 error := GetVol(@s, entryVref);

 getNRCTrgn;
 
 temp := GetResource(‘msks’, 128);
 if temp <> nil then
 BlockMove(temp^, Ptr(@cdevMsgOff), 16);

 hasCursor := ( GetResource(‘CURS’, -4064) <> nil );

 SetRect(userArea, 87, 0, 322, 255);
 SetRect(stopRect, 25, 15, 25+32, 15+32);
 SetRect(startRect, 25, 85, 25+32, 85+32);

 myStartIcon := GetResource(‘ICN#’, -4064);
 if (myStartIcon = nil) then
 fatalError(‘Unable to find cdev ICN# -4064 resource’);
 myStopIcon := GetResource(‘ICN#’, 128);

 selected := false;

 cdevDITL := GetResource(‘DITL’, -16000);
 HNoPurge(cdevDITL);
 temp := GetResource(‘DITL’, -4064);
 if temp = nil then
 fatalError(‘Unable to find cdev DITL -4064 resource’);
 cdevItems := 1 + IntHandle(cdevDITL)^^;
 
 userItems := IntHandle(temp)^^;
 IntHandle(cdevDITL)^^ := cdevItems + userItems;
 i := GetHandleSize( cdevDITL );
 j := GetHandleSize( temp );
 SetHandleSize(cdevDITL, i+j-2);
 BlockMove(Ptr(2 + ORD4(temp^)), 
 Ptr(i + ORD4(cdevDITL^)), j-2);
 
 SetDAFont(1);
 cdevDial := GetNewDialog(-16000, nil, WindowPtr(-1));
 SetDAFont(0);
 dP := DialogPeek(cdevDial);
 SetPort(cdevDial);
 TextSize(9);
 ShowWindow(cdevDial);
 for i:= cdevItems + 1 to cdevItems+userItems do
 HideDItem(cdevDial, i);

 IntHandle(dP^.items)^^ := cdevItems;
 teWas := dP^.editField;
 dP^.editField := -1;
 if teWas >= 0 then BEGIN
 teH := dp^.textH;
 teH^^.txSize := 9;
 END;

 otherWindow := GetNewWindow(128, nil, WindowPtr(0));
END; { of Initialize}

PROCEDURE DoNullEvent;
BEGIN
 cdevNulDev(@e);
 SetPort(cdevDial);
 GetMouse(p);
 if (FrontWindow = cdevDial) and 
 PtInRect(p, userArea) then BEGIN
 if hasCursor then 
 cdevCursorDev
 else 
 if cursorIsArrow then
 SetCursor(GetCursor(crossCursor)^^);
 cursorIsArrow := false;
 END
 else
 if not cursorIsArrow then BEGIN
 SetCursor(arrow);
 cursorIsArrow := true
 END
END; { of doNullEvent }

PROCEDURE DoMouseDown;
BEGIN
 i := FindWindow(e.where, whichWindow);
 case i of
 inMenuBar: doMenu( MenuSelect(e.where) );
 inDrag:BEGIN
 mvWindow(whichWindow, e.where);
 e.what := nullEvent;
 END;
 inGoAway:if TrackGoAway(whichWindow, e.where)                 
 then running := false;
 inSysWindow: SystemClick(e, whichWindow);
 inContent: BEGIN
 if FrontWindow <> whichWindow
 then BEGIN
 SelectWindow(whichWindow);
 e.what := nullEvent
 END
 else if (FrontWindow = cdevDial)
 then BEGIN
 p := e.where;
 GlobalToLocal(p);
 if (not selected) and    PtInRect(p, startRect) then
 startUpCdev;
 if selected and
 PtInRect(p, stopRect) then
 shutDownCdev;
 END; { of if frontWindow}
 END; { of inContent}
 END; { end of case }
END;


BEGIN
 Initialize;

 running := true;
 while running do BEGIN
 SystemTask;
 
 if dp^.editField >= 0 then
 TEIdle( dp^.textH);
 
 if GetNextEvent(everyEvent, e) then BEGIN

 if (e.what = keyDown) or (e.what = autoKey) 
 then BEGIN
 key := char(BitAnd(e.message,charCodeMask));
 if BitAnd(e.modifiers, cmdKey) <> 0 then                      BEGIN
 doMenu(MenuKey(key));
 e.what := nullEvent;
 END;
 END;
 
 if e.what = mouseDown then
 DoMouseDown;

 if (e.what = updateEvt) and
 (e.message=longInt(otherWindow))
 then BEGIN
 BeginUpdate(otherWindow);
 EndUpdate(otherWindow);
 END;
 if IsDialogEvent(e) then BEGIN
 if (e.what = updateEvt) and
 (e.message = longInt(cdevDial))
 then BEGIN
 rH :=
 WindowPeek(cdevDial)^.updateRgn;
 error := HandToHand(Handle(rH));
 BeginUpdate(cdevDial);
 updateDial;
 cdevUpdateDev;
 EndUpdate(cdevDial);
 WindowPeek(cdevDial)^.updateRgn
 := rH;
 END;
 if (e.what = keyDown) or
 (e.what = autoKey) then
 cdevKeyEvtDev(@e);
 if e.what = activateEvt then
 cdevActivate(@e);
 
 SetPort(cdevDial);
 TextSize(9);
 if DialogSelect(e, cdevDial, i) then
 BEGIN
 if e.what = mouseDown then BEGIN
 if i =1 then
 error := 
 Alert(-16000, nil);
 if i > cdevItems then
 cdevHitDev(i, @e);
 END;
 END; { of DialogSelect if }
 END; { of DialogEvent if }
 END; { end of GNE if }
 if e.what = nullEvent then
 doNullEvent;

 END;

 cdevCloseDev;
 DisposDialog(cdevDial);
 DisposeWindow(otherWindow);
END.
File: cdevShell.r

#include “SysTypes.r”
#include “Types.r”

resource ‘PAT ‘ (-16000, purgeable) {
 $”40 00 04 00 40 00 04"
};

resource ‘ICN#’ (128, “Other”) {
 { /* array: 2 elements */
 /* [1] */
 $”00 00 00 00 00 7F FF 80 00 80 00 40 01 00 00 20"
 $”02 00 00 10 04 3C 00 08 08 24 00 04 08 20 00 02"
 $”08 3D F0 02 08 04 40 02 08 24 40 02 08 3C 5E 02"
 $”08 00 52 02 08 00 52 02 08 00 12 02 08 00 12 F2"
 $”08 00 1E 92 08 00 00 92 08 00 00 F2 08 00 00 82"
 $”08 00 00 82 04 00 00 82 02 00 00 02 01 00 00 04"
 $”00 80 00 08 00 40 00 10 00 20 00 20 00 1F FF C0",
 /* [2] */
 $”00 00 00 00 00 7F FF 80 00 FF FF C0 01 FF FF E0"
 $”03 FF FF F0 07 FF FF F8 0F FF FF FC 0F FF FF FE”
 $”0F FF FF FE 0F FF FF FE 0F FF FF FE 0F FF FF FE”
 $”0F FF FF FE 0F FF FF FE 0F FF FF FE 0F FF FF FE”
 $”0F FF FF FE 0F FF FF FE 0F FF FF FE 0F FF FF FE”
 $”0F FF FF FE 07 FF FF FE 03 FF FF FE 01 FF FF FC”
 $”00 FF FF F8 00 7F FF F0 00 3F FF E0 00 1F FF C0"
 }
};

resource ‘DLOG’ (-16000, purgeable) {
 {58, 117, 311, 437},
 documentProc,
 invisible,
 goAway,
 0x0,
 -16000,
 “Control Panel”
};

resource ‘DLOG’ (128, “Msg Masks”) {
 {50, 60, 286, 450},
 dBoxProc,
 visible,
 goAway,
 0x0,
 128,
 “”
};

resource ‘DLOG’ (132, “About...”) {
 {62, 104, 172, 398},
 dBoxProc,
 visible,
 noGoAway,
 0x0,
 132,
 “”
};

resource ‘DITL’ (-15999, purgeable) {
 { {65, 85, 85, 155},
 Button {
 enabled,
 “OK”
 },
 {8, 60, 56, 235},
 StaticText {
 disabled,
 “”
 },
 {61, 81, 89, 159},
 UserItem {
 disabled
 },
 {10, 20, 42, 52},
 Icon {
 enabled,
 0
 }
 }
};

resource ‘DITL’ (-16000, purgeable) {
 { {241, 1, 253, 87},
 StaticText {
 enabled,
 “3.3.1”
 },
 {1, 1, 242, 88},
 UserItem {
 enabled
 }
 }
};

resource ‘DITL’ (-15998, purgeable) {
 { {5, 7, 100, 227},
 StaticText {
 disabled,
 “Contributions by:\n   Steve Horowitz--the “
 “main man\n   scott douglass\n   Kristee Kr”
 “eitman\n   Amy Goldsmith”
 },
 {113, 155, 134, 224},
 Button {
 enabled,
 “Continue”
 }
 }
};

resource ‘DITL’ (130) {
 { {139, 189, 159, 249},
 Button {
 enabled,
 “OK”
 },
 {29, 30, 124, 251},
 StaticText {
 disabled,
 “Fatal Error: ^0”
 }
 }
};

resource ‘DITL’ (128) {
 { {202, 300, 222, 360},
 Button {
 enabled,
 “OK”
 },
 {201, 212, 221, 272},
 Button {
 enabled,
 “Cancel”
 },
 {40, 24, 62, 102},
 CheckBox {
 enabled,
 “initDev”
 },
 {70, 24, 84, 110},
 CheckBox {
 enabled,
 “hitDev”
 },
 {100, 24, 115, 104},
 CheckBox {
 enabled,
 “closeDev”
 },
 {130, 24, 146, 106},
 CheckBox {
 enabled,
 “nulDev”
 },
 {160, 24, 176, 112},
 CheckBox {
 enabled,
 “updateDev”
 },
 {40, 160, 61, 251},
 CheckBox {
 enabled,
 “activDev”
 },
 {70, 160, 92, 276},
 CheckBox {
 enabled,
 “deActiveDev”
 },
 {100, 160, 116, 253},
 CheckBox {
 enabled,
 “keyEvtDev”
 },
 {130, 160, 148, 261},
 CheckBox {
 enabled,
 “macDev”
 },
 {160, 160, 180, 268},
 CheckBox {
 enabled,
 “undoDev”
 },
 {40, 282, 69, 368},
 CheckBox {
 enabled,
 “cutDev”
 },
 {70, 282, 100, 367},
 CheckBox {
 enabled,
 “copyDev”
 },
 {100, 282, 127, 369},
 CheckBox {
 enabled,
 “pasteDev”
 },
 {130, 282, 154, 374},
 CheckBox {
 enabled,
 “clearDev”
 },
 {160, 282, 184, 365},
 CheckBox {
 enabled,
 “cursorDev”
 },
 {8, 8, 33, 278},
 StaticText {
 disabled,
 “Mark Boxes to Disable cdev Messages:”
 }
 }
};

resource ‘DITL’ (131) {
 { {106, 168, 126, 228},
 Button {
 enabled,
 “OK”
 },
 {7, 14, 98, 228},
 StaticText {
 disabled,
 “Warning: ^0”
 }
 }
};

resource ‘DITL’ (132) {
 { {80, 217, 100, 277},
 Button {
 enabled,
 “OK”
 },
 {12, 51, 32, 238},
 StaticText {
 disabled,
 “cdev Shell for Pascal”
 },
 {48, 52, 68, 235},
 StaticText {
 disabled,
 “© 1989 by J. Peter Hoddie”
 }
 }
};

resource ‘CNTL’ (-4048, purgeable) {
 {26, 122, 43, 170},
 0,
 visible,
 1,
 0,
 radioButProcUseWFont,
 0,
 “Show”
};

resource ‘MENU’ (128, “Apple Menu”) {
 1,
 textMenuProc,
 0x7FFFFFFD,
 enabled,
 apple,
 { “About it...”, noIcon, noKey, noMark, plain,
 “-”, noIcon, noKey, noMark, plain
 }
};

resource ‘MENU’ (129, “Files”) {
 2,
 textMenuProc,
 0x7FFFFFFB,
 enabled,
 “File”,
 { “Open”, noIcon, “O”, noMark, plain,
 “Close”, noIcon, “W”, noMark, plain,
 “-”, noIcon, noKey, noMark, plain,
 “Quit”, noIcon, “Q”, noMark, plain
 }
};

resource ‘MENU’ (130, “Edit”, preload) {
 3,
 textMenuProc,
 0x7FFFFFFD,
 enabled,
 “Edit”,
 { “Undo”, noIcon, “Z”, noMark, plain,
 “-”, noIcon, noKey, noMark, plain,
 “Cut”, noIcon, “X”, noMark, plain,
 “Copy”, noIcon, “C”, noMark, plain,
 “Paste”, noIcon, “V”, noMark, plain,
 “Clear”, noIcon, noKey, noMark, plain
 }
};

resource ‘MENU’ (131, “Options”) {
 4,
 textMenuProc,
 allEnabled,
 enabled,
 “Options”,
 { “Msg Masks...”, noIcon, noKey, noMark, plain,
 “Force Update”, noIcon, noKey, noMark, plain
 }
};

resource ‘MBAR’ (256) {
 { 128,
 129,
 130,
 131
 }
};

resource ‘ALRT’ (-16000, purgeable) {
 {48, 128, 188, 368},
 -15998,
 {
 OK, visible, silent,
 OK, visible, silent,
 OK, visible, silent,
 OK, visible, silent
 }
};

resource ‘ALRT’ (130, “Fatal Error”) {
 {56, 126, 238, 410},
 130,
 { OK, visible, sound1,
 OK, visible, sound1,
 OK, visible, sound1,
 OK, visible, sound1
 }
};

resource ‘ALRT’ (131, “Warning Error”) {
 {54, 134, 192, 378},
 131,
 { OK, visible, sound1,
 OK, visible, sound1,
 OK, visible, sound1,
 OK, visible, sound1
 }
};

data ‘msks’ (128) {
 $”00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
 };

resource ‘WIND’ (128, “Other Window”) {
 {38, 388, 80, 510},
 documentProc,
 visible,
 noGoAway,
 0x0,
 “OtherWindow”
};

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »
Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »
Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »

Price Scanner via MacPrices.net

Sunday Sale: Apple Studio Display with Standa...
Amazon has the standard-glass Apple Studio Display on sale for $300 off MSRP for a limited time. Shipping is free: – Studio Display (Standard glass): $1299.97 $300 off MSRP For the latest prices and... Read more
Apple is offering significant discounts on 16...
Apple has a full line of 16″ M3 Pro and M3 Max MacBook Pros available, Certified Refurbished, starting at $2119 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free... Read more
Apple HomePods on sale for $30-$50 off MSRP t...
Best Buy is offering a $30-$50 discount on Apple HomePods this weekend on their online store. The HomePod mini is on sale for $69.99, $30 off MSRP, while Best Buy has the full-size HomePod on sale... Read more
Limited-time sale: 13-inch M3 MacBook Airs fo...
Amazon has the base 13″ M3 MacBook Air (8GB/256GB) in stock and on sale for a limited time for $989 shipped. That’s $110 off MSRP, and it’s the lowest price we’ve seen so far for an M3-powered... Read more
13-inch M2 MacBook Airs in stock today at App...
Apple has 13″ M2 MacBook Airs available for only $849 today in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty is included,... Read more
New today at Apple: Series 9 Watches availabl...
Apple is now offering Certified Refurbished Apple Watch Series 9 models on their online store for up to $80 off MSRP, starting at $339. Each Watch includes Apple’s standard one-year warranty, a new... Read more
The latest Apple iPhone deals from wireless c...
We’ve updated our iPhone Price Tracker with the latest carrier deals on Apple’s iPhone 15 family of smartphones as well as previous models including the iPhone 14, 13, 12, 11, and SE. Use our price... Read more
Boost Mobile will sell you an iPhone 11 for $...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering an iPhone 11 for $149.99 when purchased with their $40 Unlimited service plan (12GB of premium data). No trade-in is required... Read more
Free iPhone 15 plus Unlimited service for $60...
Boost Infinite, part of MVNO Boost Mobile using AT&T and T-Mobile’s networks, is offering a free 128GB iPhone 15 for $60 per month including their Unlimited service plan (30GB of premium data).... Read more
$300 off any new iPhone with service at Red P...
Red Pocket Mobile has new Apple iPhones on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide MVNO using all the major wireless carrier... Read more

Jobs Board

Licensed Practical Nurse - Womens Imaging *A...
Licensed Practical Nurse - Womens Imaging Apple Hill - PRN Location: York Hospital, York, PA Schedule: PRN/Per Diem Sign-On Bonus Eligible Remote/Hybrid Regular Read more
DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Operating Room Assistant - *Apple* Hill Sur...
Operating Room Assistant - Apple Hill Surgical Center - Day Location: WellSpan Health, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.