Beeping Button Brouhaha

First Problem

The first thing that happens when we write in a number and then press the Beep button is a notification on the Newton: "Sorry, a problem has occurred. (-48807)". Let's turn on breakOnThrows (clicking the icon in the Inspector Window) and press the button again. Now, the Inspector prints out

   Undefined variable: numBeeps
   evt.ex.fr.intrp;type.ref.frame
   -48807
(#6008D1D1).buttonClickScript(), 3: Push 'text
Entering break loop: level 1
If we look at the code we see that we're trying to access the numBeeps variable from our buttonClickScript. That variable should refer to our protoLabelInputLine view. What could be wrong? If we've correctly declared numBeeps to the protoFloatNGo, the protoFloatNGo view should have a slot named numBeeps. Let's look in that view for numBeeps. (That view is the parent of our current self.). First, let's get self:

// get current self
beepingButton := GetCurrentReceiver(0); 

#440F63D {_parent: {_parent: {#440D221}, 
                     _proto: {#6008D0C1}, 
                     viewCObject: 0x110926D, 
                     viewclipper: 17863292, 
                     base: <1>, 
                     viewFlags: 577, 
                     viewBounds: {#440F5C1}}, 
           _proto: {buttonClickScript:<function, 0 arg(s)#6008D239>,
                    text: "Beep", 
                    viewBounds: {#6008D539}, 
                    _proto: {@226}}, 
           viewCObject: 0x110A530, 
           viewFlags: 515}
Now, let's get the parent slot and we will have the right view:

floatNGo := beepingButton._parent
#440F5DD  {_parent: {minute: 178, 
                     downButton: {#440B2E9}, 
                     calculator: {#4406159}, 
                     mailEditor: {#44064C1}, 
                     extrasDrawer: {#4409671}, 
                     defaultTransport:Newton: {#4405DD9}, 
                     OutOfMemoryAlert: {#4405D95}, 
                     notification: {#4405D35}, 
                     remindSlip: {#44060C5}, 
                     namesButton: {#44063D9}, 
                     folderEdit: {#4405DF1}, 
                     phoneKeyboard: {#4405ECD}, 
                     ovButton: {#440643D}, 
                     upButton: {#4406461}, 
                     thegang: {#44065F9}, 
                     printerSerialPicker: {#4405D05}, 
                     ...}, 
         _proto: {viewBounds: {#6008D199}, 
                    stepChildren: [#6008D1B9], 
                    _proto: {@180}, 
                    debug: "myFloatNGo", 
                    appSymbol: |Demo:NTK.Demo|}, 
         viewCObject: 0x110926D, 
         viewclipper: 17863292, 
         base: <1>, 
         viewFlags: 577, 
         viewBounds:{left:-25, top:173, right:139, bottom:265}}
The numBeeps slot doesn't seem to be in the floatNGo. The view otherwise appears to be correct. It sounds like a problem in declaring. Let's check the Template Info dialog for that template (see FIGURE 8.19). Well, well, well. Turns out it actually wasn't declared. We'll checkmark the "Declare To:" checkbox and rebuild.

FIGURE 8.19 : Template Info dialog showing undeclared numBeeps.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996