FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

CONTROLS

Use Appearance manager controls


You can create all of the new appearance mngr. controls using the NEWCONTROL toolbox call with the appropriate ID of the CDEF (I just started adding numbers). I played arround with it one afternoon and was able to create the little arrow control, the round spinning arrows control, the new progress bar, and all kinds of goodies in between, which then then be controlled with the control mngr calls. You have to make sure the appearance mngr is available oryou will get a crash.
I use :
gCHandle& = FN NEWCONTROL (wPtr&,cRect,cTitle$,isVisible%,currValue%, ¨
                               cMinValue%,cMaxValue%,CDEFid%,0)
Then for CDEFid%, just change it to the appropriate number :

96 = spinner control
80 = progress bar
52 = slider control (add 4 at a time to this one to get different options)
64 = rotating arrow (expand / retract window arrow)
120 = round spinning arrows

John

This is terrific! Did you know you can also use these numbers directly in FB's BUTTON statement, to make an "FB - controlled" button of these new types? The secret is to add 1 to one of the "CDEFid%" numbers listed above, and then use the result as FB's "btnType" parameter. Here's a demo :
LOCAL FN DoDialog
  DIM evnt, id
  evnt = DIALOG(0)
  id = DIALOG(1)
  SELECT CASE evnt
    CASE _btnClick
      SELECT CASE id
        CASE 1
          SELECT CASE BUTTON(1)
            CASE _activeBtn : BUTTON 1, _markedBtn
            CASE _markedBtn : BUTTON 1, _activeBtn
          END SELECT
      END SELECT
  END SELECT
END FN
WINDOW 1
'Make a "list expander" arrow : 
BUTTON 1, _activeBtn, "", (10,10) - (50,50), 65
ON DIALOG FN DoDialog
DO
  HANDLEEVENTS
UNTIL _false
Rick

A short time ago I posted a similar question but it failed to make the list. Since then, I have been researching CDEFs and the Appearance Manager and have made some discoveries that may help you. (I have not yet received my copy of FB^3, and have no way of knowing if this information will be obsoleted or not. In my initial post, I asked if FB^3 is Appearance Manager compliant, but my question remains unanswered.)

Several new MacOS system controls can safely be called and utilized with the FBII "BUTTON" statement. These basically include some nice new 3-D buttons. The new buttons offer more states than what we are used to in FBII. The new states include: inactive (grayed out), active, marked and mixed. The latter is a new one and I'm still waiting to see how it can best be used.

With other new controls, you use the FBII BUTTON statement to open and view the control (sliders, spinners and pop-up menus included) but the BUTTON statement does not offer enough parameters to utilize the new controls.

At first I thought the only way to call those controls was by hard-coding from resource files-- a process still beyond my ability.

But recently I have discovered that it is possible to call and use at least some of the new controls-- which already are embedded in the System file and Appearance Manager--directly from FBII.

In a subsequent posts, I will include some demonstration code. If you have old issues of InsideBASIC or the InsideBASIC CD in Issue 53 there are two helpful articles: Understanding Control Definitions, by Raoul Watson, and a follow-up, Using Other People's CDEFs, by Ross Lambert. These articles will help you understand how to set the enhance control parameters from with FBII.

I recommend that everyone on the list download Apple's Appearance Manager software development kit. It's a 3.8 meg file, but includes a wonderful 500k demo of many of Appearance Manager's new features that will leave you drooling. (Be sure to check out the various menu functions!) If you would just like to look at the official Apple demo without downloading the entire file, e-mail me offline. The file also includes the latest edition of Appearance Manager, v. 1.0.4, which fixes some major bugs. You can download it at:

ftp://ftp.apple.com//devworld/Development_Kits/Appearance_SDK_1.0.4.sit.hqx

The Apple download includes a Resourcer file with the new Appearance Manager templates. If you only have ResEdit, you can modify it to include the same templates with this file:

http://hyperarchive.lcs.mit.edu/HyperArchive/Archive/dev/resedit-appea rance-tmpl.hqx

Here is a demo of a new MacOS Appearance compliant slider control with parameters set directly from FBII.
'tedd sperling originally posted this code
'to demonstrate arrow buttons. With some modification
'it appears to be able to set necessary parameters
'to utilize some of the new Appearance Manager compliant
'controls, such as this slider. Try changing the BUTTON
'type from 52 to 53 or 57 or 49 or 17. BTW, tedd's original
'control number here would be 97. The nice thing about this
'is that you can call directly from FB without needing a
'resource file.

'-------- Will run as is ----------

COMPILE 0,_dimmedVarsOnly
_arrowWnd = 10
_arrowBtn = 10
_arrowFld = 10
_arrowX = 80
_arrowY = 90

DIM gKissOfDeath
DIM gArrowValue

END GLOBALS

LOCAL FN init
  DIM x,y,x1,y1
  DIM arrowValue&
  DIM a, a$
  
  WINDOW OFF
  COORDINATE WINDOW
  
  WINDOW _arrowWnd,"Control Demo",(0,0)-(200,200),_docNoGrow
  PRINT:PRINT " Press command period,"
  PRINT " or close window to end."
  
  x = _arrowX
  y = _arrowY
  
  x1 = x + 18                                   'Moves button to right from TEXT BOX
  y1 = y + 100                                  'Sets length of slider control
  BUTTON _arrowBtn,_activeBtn,,(x,y)-(x1,y1),53 '<-- Adjust this control number to experiment
  
  arrowValue& = BUTTON&(_arrowBtn)
  
  LONG IF arrowValue&
    
    CALL SETCTLMIN(arrowValue&, 0)
    CALL SETCTLMAX(arrowValue&, 10)
    a  =       FN GETCTLVALUE(arrowValue&)
    
    x = _arrowX - 25
    y = _arrowY + 5
    x1 = x + 20
    y1 = y + 15
    gArrowValue = 10 - a
    a$ = STR$(gArrowValue)
    
    EDIT FIELD _arrowFld, a$,(x,y)-(x1,y1), _statNoFramed
  END IF
END FN

LOCAL FN doDialog
  DIM evnt, id
  DIM a, a$
  DIM arrowValue&
  
  evnt = DIALOG(0)
  id   = DIALOG(evnt)
  
  SELECT CASE evnt
      
    CASE _btnClick
      arrowValue& = BUTTON&(_arrowBtn)
      LONG IF arrowValue&
        a      =       FN GETCTLVALUE(arrowValue&)
        gArrowValue = 10 - a
        a$ = STR$(gArrowValue)
        EDIT$(_arrowFld) = a$
      END IF
    CASE _wndClose
      END
  END SELECT
  
END FN

LOCAL FN Quit
  gKissOfDeath = _true
END FN

gKissOfDeath = _false

ON DIALOG FN doDialog
ON BREAK FN Quit

FN init

DO
  HANDLEEVENTS
UNTIL gKissOfDeath
Ken Shmidheiser

This is a demo of some new Appearance Manager compliant buttons and controls that I have called directly from FBII without problem:
'-------------- Stand Alone Demo ------

'Demo of Mac OS8 Appearance Manager compliant buttons
'called with FBII button statements
'Code by Ken Shmidheiser, September 1999

'--------------- Globals ---------------
DIM gProgramEnds
END GLOBALS

'--------------- Functions -------------
LOCAL FN buildWnd
  WINDOW -1, "Appearance Tester Demo",(0,0)-(500,350),_docNoGrow
  
  MENU 1, 0, _enable, "File"
  MENU 1, 1, _enable, "Quit /Q"
  
  EDIT = 3
  EDIT FIELD 1, "",(8,30)-(492,342),_statFramed
  EDIT FIELD 2, "Click on any of the buttons or tabs to cycle themthrough their states.", ¨
                (10,38)-(450,50),_statNoFramed,_leftJust
  EDIT FIELD 3, "Expander Arrows 64. Click me.",(28,270)-(220,283),_statFramed, _leftJust
  
  EDIT FIELD 5, "Thanks for opening me... I hate hiding!",(220,320)-(490,283),_framed, _leftJust
  
  BUTTON 1, _activeBtn, "Button 368", (10,225)-(220,255), 369'New push button
  BUTTON 2, _activeBtn, "Check Box 369", (10,60)-(200,75), 370'New check box
  BUTTON 3, _activeBtn, "Radio Button 370", (10,90)-(200,105),371'New radio button
  BUTTON 4, _activeBtn, "Bevel Button 32 (small bevel)",(10,120)-(220,145), 33'small bevel button
  BUTTON 5, _activeBtn, "Bevel Button 33 (normal bevel)",(10,155)-(220,180), 34'Normal bevel button
  BUTTON 6, _activeBtn, "Bevel Button 34 (large bevel)",(10,190)-(220,215), 35'large bevel button
  
  BUTTON 7, _activeBtn, "Tab control 128", (5,5)-(120,30), 129'Compliant tab
  BUTTON 8, _activeBtn, "Tab control 128", (119,5)-(255,30), 129'Compliant tab
  BUTTON 9, _activeBtn, "Tab control 128", (254,5)-(390,30), 129'Compliant tab
  BUTTON 10, _activeBtn, "Press to quit...", (389,5)-(495,30),129'Compliant tab
  
  BUTTON 11, _activeBtn, "", (8,270)-(20,292), 65             'New expander arrows
  
  WINDOW 1
END FN

LOCAL FN doDialog
  evnt = DIALOG(0)
  id = DIALOG(1)
  
  SELECT CASE evnt
    CASE _btnClick
      
      SELECT CASE id
        CASE 1
          BUTTON 1, 2, "Button Pressed": DELAY 850
          BUTTON 1, 0,"Button Grayed" : DELAY 1000
          BUTTON 1, 1, "Momentary Button 368"
        CASE 2
          BUTTON 2, 2, "Marked": DELAY 850
          BUTTON 2, 3, "Mixed":DELAY 1000
          BUTTON 2, 0, "Grayed" : DELAY 1000
          BUTTON 2, 1, "CheckBox 369"
        CASE 3
          BUTTON 3, 2, "Marked": DELAY 850
          BUTTON 3, 3, "Mixed":DELAY 1000
          BUTTON 3, 0, "Grayed" : DELAY 1000
          BUTTON 3, 1, "Radio Button 370"
        CASE 4
          BUTTON 4, 2, "Button Marked": DELAY 850
          BUTTON 4, 3, "Button Mixed": DELAY 1000
          BUTTON 4, 0, "Button Grayed" : DELAY 1000
          BUTTON 4, 1, "Bevel Button 32 (small bevel)"
        CASE 5
          BUTTON 5, 2, "Button Marked": DELAY 850
          BUTTON 5, 3,"Button Mixed": DELAY 1000 
          BUTTON 5, 0, "Button Grayed" : DELAY 1000
          BUTTON 5, 1, "Bevel Button 33 (normal bevel)"
        CASE 6
          BUTTON 6, 2, "Button Marked": DELAY 850
          BUTTON 6, 3,"Button Mixed": DELAY 1000
          BUTTON 6, 0, "Button Grayed" 
          DELAY 1000 : BUTTON 6, 1, "Bevel Button 34 (large bevel)"
        CASE 7
          BUTTON 7, 2, "Tab 128 Marked": DELAY 850
          BUTTON 7, 0, "Tab 128 Grayed" : DELAY 1000
          BUTTON 7, 1, "Tab 128 Normal"
        CASE 8
          SELECT CASE BUTTON(8)
            CASE 1 : BUTTON 8, 0, "Grayed. 2 clicks for on ->"
          END SELECT
        CASE 9
          SELECT CASE BUTTON(9)
            CASE 1 : BUTTON 9, 2, "Highlighted; Click again"
            CASE 2 : BUTTON 9, 1, "Tab 128 Normal" : BUTTON 8, 1,"Tab 128 Normal"
          END SELECT
        CASE 10
          BUTTON 10, 0
          BUTTON CLOSE 1
          BUTTON CLOSE 2
          BUTTON CLOSE 3
          BUTTON CLOSE 4
          BUTTON CLOSE 5
          BUTTON CLOSE 6
          BUTTON CLOSE 11
          EDIT FIELD CLOSE 2
          EDIT FIELD 3,""
          EDIT FIELD -3,"Goodbye! Click Reset to run again.",(230,140)-(305,250), ¨
                        _statNoframed, _centerJust
          BUTTON 12, _enable, "Quit", (420,300)-(475,322),_shadow
          BUTTON 13, _enable, "Reset", (355,300)-(410,322),_push
        CASE 11
          SELECT CASE BUTTON(11)
            CASE _activeBtn
              BUTTON 11, _markedBtn
              EDIT FIELD 3,"Pretty neat, eh!!! Notice how this box expands to fit the text. ¨
                           Click again to reset the box to its previous size if you want ¨ 
                           to try again.",(28,270)-(220,330),_statFramed, _leftJust
              
            CASE _markedBtn
              BUTTON 11, _activeBtn : EDIT FIELD 3,"Go ahead and click me!", ¨
                                                (28,270)-(220,283), _statFramed, _leftJust'
              EDIT$(2) = "Go ahead and click me!"
          END SELECT
        CASE 12
          gProgramEnds = _true
        CASE 13
          WINDOW CLOSE 1    'Closes old window and redraw it correctly in center of screen
          FN buildWnd
      END SELECT
      
    CASE _wndClose
      gProgramEnds = _true
      
  END SELECT
END FN

LOCAL FN doMenu
  menuID = MENU(_menuID)
  itemID = MENU(_itemID)
  
  SELECT CASE
    CASE menuID = 1 AND itemID = 1
      END
  END SELECT
END FN

'--------------- Main ---------------
WINDOW OFF
COORDINATE WINDOW

FN buildWnd

ON DIALOG FN doDialog
ON MENU FN doMenu

DO
  HANDLEEVENTS
UNTIL gProgramEnds

'--------------- End ----------------
Ken Shmidheiser

At the end please find some info from an earlier post. (Sorry, I lost the poster's name.) You may find some discrepancies here, but it will serve as a rough guideline. I prefer to use the official Apple Mac OS8 Control Manager Reference which is downloadable in pdf form from www.apple.com.

I have found that when working with Appearance Manager compliant calls in FBII I often have to close FBII and restart the file again for the new controls to become effective.

There are several new controls which look really interesting—group boxes for items like radio buttons (160-166), clickable image wells (176 & 177), user panes for window menu bars (256), 3-D edit fields (272), and an assortment of sliders and pop-up menus. As I mentioned earlier, you can see some of these effects using an FB BUTTON statement, but they won't work without coding the parameters. (Try the group boxes, image wells and edit fields in window with a mid-gray background for the best 3-D effect.)

I would really like to get the image well to work. I anyone has had any success with this, please post for the rest of us!

I have not been successful in making fields of some of the new controls to work with colored window backgrounds. They always appear white.

Recently as a programming exercise, I have been playing with a shell for a calculator with a printable ribbon that I developed using Appearance Manager compliant controls. I will post the code to give you an idea of my problem vs. control problem.

p.s. Due to a quirk between FB and the Mac OS, you must add +1 to Apple's official numbers for control calls listed in the Control Manager Reference.
'Examples of new Appearance manager buttons

' I use:
'
' gCHandle& = FN
NEWCONTROL(wPtr&,cRect,cTitle$,isVisible%,currValue%,cMinValue%,cMaxValue%,CDEFid%,0)
'
' Then for CDEFid%, just change it TO the appropriate number:
'
' 3 = radio push button
' 4 = 3-D outline push button
' 7 = rounded corner push putton
' 10 = check box
' 17 = blue thumb scroll bar
' 20 = scroll bar
' 35 = 3-D push button
' 40 = square push button
' 49 = pointer to right scroll slider
' 52 = slider control (ADD 4 at a time TO this one TO GET different options)
' 53 = pointer to left scroll slider
' 57 = square blue scroll slider
' 65 = right facing rotating arrow (expand/retract WINDOW arrow)
' 66 = left facing rotating arrow (expand/retract WINDOW arrow)
' 67 = right facing rotating arrow toggle only (expand/retract WINDOW arrow)
' 68 = left facing rotating arrow toggle only (expand/retract WINDOW arrow)
' 96 = spinner control
' 80 = progress bar
' 120 = round spinning arrows
' 130 = square "x" check box
' 131 = round radio check box
' 132 = highlighted push button
' 134 = sizeable "x" check box
' 135 = sizeable radio check box
' 137 = highlightable outline button
' 141 = invisible but highlightable check button
' 144 = heavy outline plain button
' 193 to 208 = various size and direction non-toggleable arrows

 ' 210 = 3-D square check box
' 219 = 3-D round check box
' 241 to 256 = various clock adjustment boxes
Ken Shmidheiser

The following shell is strictly a work in progress undertaken as a programming exercise using some Appearance Manager (v1.4) controls from Mac OS 8.

One problem is the Expander Arrow control which opens the printable ribbon window. It is on a white background, and I do not know how to change it to the window color. Instead, I have disguised it here with some lines, but would like to know how handle it properly.

p.s. Any hints for adding the math functions to make this thing actually work will be appreciated! I have been experimenting with arrays, DATA structures, linked lists, etc. I readily acknowledge that this code is very loose and can stand a good optimizing (or maybe a good trashing!) I am in severe brain drain now and can no longer see the forest for the trees. How do I put two lines of code in an Edit Field and add them?!? For that matter, how do I put one line of numbers in a EF and call it back later? How do I use an Enter key? What is 1+1?

I'mmm mmmeeelllltttingggg...
'----------------- Begin ---------------------

'This calculator/keypad shell is coded
'in FutureBASIC II by Ken Shmidheiser,
'September 1999. It uses Appearance
'Manager compliant controls for Mac OS 8
'or above.

'----------------- Constants -----------------
_numField = 4
_alphaField = 8

_gZero = 48                               'ASCII key equivalents for keypad
_gOne = 49
_gTwo = 50
_gThree = 51
_gFour = 52
_gFive = 53
_gSix = 54
_gSeven = 55
_gEight = 56
_gNine = 57

_gMultiply = 42
_gPlus = 43
_gMinus = 45
_gDivide = 47

_gDecimal = 46

_gReturn = 13
_gEnter = 3
_gClear = 27

_gEquals = 61

_gExpandArrows = 65

'----------------- Globals -------------------
DIM gProgramEnds
DIM gKeyPress%
DIM gBtnClick%
END GLOBALS

'----------------- Functions -----------------
CLEAR LOCAL
DIM rect;8
LOCAL FN mainRefresh       'This function adds refreshable background color

   CALL SETRECT(rect, 0, 0, 460, 300)  'Background color rectangle same size as main window
   PEN  0, 0,1, 8, 0
   LONG COLOR -13000,-14660,-14660                 'Mid-gray
   CALL PAINTRECT(rect)
   PEN  0, 0,1, 8, 0
   LONG COLOR  0, 0, 0
   CALL FRAMERECT(rect)

   CALL PENNORMAL:COLOR=_zBlack

   PLOT 212,41 TO 212,55                           'Left
   PEN 1,1
   PLOT 212,41 TO 225,41                           'Top
   PLOT 225,41 TO 225,55                           'Right
   PLOT 212,55 TO 225,55                           'Bottom

END FN

CLEAR LOCAL
DIM rect.8
LOCAL FN mainBuild

   WINDOW # -1,"Ken's Calculator",( 0, 0)-( 246, 300),_docNoGrow, 1

   APPLE MENU "(Ken's Demo Calculator"

   MENU 1,0, _enable, "File"
   MENU 1,1, _enable, "Quit /Q"

   EDIT MENU 2

   EDIT = 6
   TEXT _geneva,13,0,0:COLOR=_zBlack
   EDIT FIELD -1,"",( 45, 40)-( 200, 60),_framed, _rightJust + _numField'Number Fields are 4, alpha fields are 8
   EDIT FIELD 2,"",( 45, 13)-( 200, 28),_framedNoCR, _rightJust + _numField'Number Fields are 4, alpha fields are 8

   EDIT FIELD -4,"",(260,40)-(410,275),_framed, _rightJust'+ _numField'Number Fields are 4, alpha fields are 8
   SCROLL BUTTON -4,1,1,1,20,(415,34)-(431,281),_scrollOther

   TEXT _sysFont,12,0,0:COLOR=_zBlack
   BUTTON _gClear, 1,"Clear",( 38, 70)-( 80, 112),35
   BUTTON _gEquals, 1,"=",( 80, 70)-( 122, 112),35
   BUTTON _gDivide, 1,"/",( 122, 70)-( 166, 112),35
   BUTTON _gMultiply, 1,"*",( 166, 70)-( 208, 112),35

   BUTTON _gSeven, 1,"7",( 38, 112)-( 80, 154),35
   BUTTON _gEight, 1,"8",( 80, 112)-( 122, 154),35
   BUTTON _gNine, 1,"9",( 122, 112)-( 166, 154),35
   BUTTON _gMinus, 1,"-",( 166, 112)-( 208, 154),35

   BUTTON _gFour, 1,"4",( 38, 154)-( 80, 196),35
   BUTTON _gFive, 1,"5",( 80, 154)-( 122, 196),35
   BUTTON _gSix, 1,"6",( 122, 154)-( 166, 196),35
   BUTTON _gPlus, 1,"+",( 166, 154)-( 208, 196),35

   BUTTON _gOne, 1,"1",( 38, 196)-( 80, 238),35
   BUTTON _gTwo, 1,"2",( 80, 196)-( 122, 238),35
   BUTTON _gThree, 1,"3",( 122, 196)-( 166, 238),35

   BUTTON _gZero, 1,"0",( 38, 238)-( 122, 280),35
   BUTTON _gDecimal, 1,".",( 122, 238)-( 166, 280),35

   BUTTON _gEnter, 1,"Enter",( 166, 196)-( 208, 280),35

   BUTTON _gExpandArrows, _activeBtn, "", (213,43)-(225,55), 65'Appearance expander arrows (64 + 1 = 65)

   EDIT FIELD  1

   WINDOW  1

END FN

CLEAR LOCAL
DIM rect.8
LOCAL FN twoBuild

   WINDOW # -1,"Ken's Calculator",( 0, 0)-( 460, 300),_docNoGrow, 1

   APPLE MENU "(Ken's Demo Calculator"

   MENU 1,0, _enable, "File"
   MENU 1,1, _enable, "Quit /Q"

   EDIT MENU 2

   EDIT = 6
   TEXT _geneva,13,0,0:COLOR=_zBlack
   EDIT FIELD -1,"",( 45, 40)-( 200, 60),_framed, _rightJust + _numField'Number Fields are 4, alpha fields are 8

   EDIT FIELD 2,"",( 45, 13)-( 200, 28),_framedNoCR, _rightJust + _numField'Number Fields are 4, alpha fields are 8

EDIT FIELD -4,"",(260,40)-(410,275),_framed, _rightJust'+ _numField'Number Fields are 4, alpha fields are 8
   SCROLL BUTTON -4,1,1,1,20,(415,34)-(431,281),_scrollOther

   TEXT _sysFont,12,0,0:COLOR=_zBlack
   BUTTON _gClear, 1,"Clear",( 38, 70)-( 80, 112),35
   BUTTON _gEquals, 1,"=",( 80, 70)-( 122, 112),35
   BUTTON _gDivide, 1,"/",( 122, 70)-( 166, 112),35
   BUTTON _gMultiply, 1,"*",( 166, 70)-( 208, 112),35

   BUTTON _gSeven, 1,"7",( 38, 112)-( 80, 154),35
   BUTTON _gEight, 1,"8",( 80, 112)-( 122, 154),35
   BUTTON _gNine, 1,"9",( 122, 112)-( 166, 154),35
   BUTTON _gMinus, 1,"-",( 166, 112)-( 208, 154),35

   BUTTON _gFour, 1,"4",( 38, 154)-( 80, 196),35
   BUTTON _gFive, 1,"5",( 80, 154)-( 122, 196),35
   BUTTON _gSix, 1,"6",( 122, 154)-( 166, 196),35
   BUTTON _gPlus, 1,"+",( 166, 154)-( 208, 196),35

   BUTTON _gOne, 1,"1",( 38, 196)-( 80, 238),35
   BUTTON _gTwo, 1,"2",( 80, 196)-( 122, 238),35
   BUTTON _gThree, 1,"3",( 122, 196)-( 166, 238),35

   BUTTON _gZero, 1,"0",( 38, 238)-( 122, 280),35
   BUTTON _gDecimal, 1,".",( 122, 238)-( 166, 280),35

   BUTTON _gEnter, 1,"Enter",( 166, 196)-( 208, 280),35

   BUTTON _gExpandArrows, _markedBtn, "", (213,43)-(225,55), 65'Appearance expander arrows (64 + 1 = 65)

   EDIT FIELD  1

   WINDOW  1

END FN

LOCAL FN doMath

   EDIT$(2) = "Math function goes here."
   EDIT$(4) = "Math function goes here."

END FN

LOCAL FN errorWarning
   BEEP
END FN

LOCAL FN checkKeys
   EFnum = WINDOW(_EFnum)         'Figures out what window it's looking at
   key$ = TEKEY$                  'Once it has the window, grabs keystrokes for massaging

   SELECT WINDOW(_EFclass)/4      'Check for the right kind of window

       LONG IF ASC(key$) => ASC("0") AND ASC(key$) <=ASC("9") OR ASC(key$) = 46'Numbers and decimal point
         TEKEY$ = key$
       XELSE
         'FN errorWarning
       END IF

       gKeyPress% = ASC(key$)

       LONG IF ASC(STR$(gKeyPress%))  'Push button feedback for number keys
         BUTTON gKeyPress%, 2 : DELAY 50 : BUTTON gKeyPress%, 1
       XELSE
         FN errorWarning
       END IF

       LONG IF ASC(key$) = _gPlus

         'plus$ = EDIT$(1) + CHR$(_gPlus) + CHR$(13) + CHR$(13) + "OK"
         'TEKEY$ = plus$

         EDIT$(2) = "Plus key pressed"
         EDIT$(4) = "Plus key pressed"
         DELAY 800
         FN doMath
       XELSE
       END IF

       LONG IF ASC(key$) = _gMinus
         EDIT$(2) = "Minus key pressed"
         EDIT$(4) = "Minus key pressed"
         DELAY 800
         FN doMath

       XELSE
       END IF

       LONG IF ASC(key$) = _gMultiply
         EDIT$(2) = "Multiply key pressed"
         EDIT$(4) = "Multiply key pressed"
         DELAY 800
         FN doMath

       XELSE
       END IF

       LONG IF ASC(key$) = _gDivide
         EDIT$(2) = "Divide key pressed"
         EDIT$(4) = "Divide key pressed"
         DELAY 800
         FN doMath

       XELSE
       END IF

       LONG IF ASC(key$) = _gEquals
         EDIT$(2) = "Equals key pressed"
         EDIT$(4) = "Equals key pressed"
         DELAY 800
         FN doMath

       XELSE
       END IF

       LONG IF ASC(key$) = _gEnter
         EDIT$(2) = "Enter key pressed"
         EDIT$(4) = "Enter key pressed"
         DELAY 800
         FN doMath

       XELSE
       END IF

   END SELECT

END FN

LOCAL FN doDialog
   evnt = DIALOG(0)
   id = DIALOG(evnt)

   key$ = TEKEY$

   SELECT CASE evnt

     CASE _btnClick

       SELECT CASE id
         CASE _gZero
           TEKEY$ = "0"
         CASE _gOne
           TEKEY$ = "1"
         CASE _gTwo
           TEKEY$ = "2"
         CASE _gThree
           TEKEY$ = "3"
         CASE _gFour
           TEKEY$ = "4"
         CASE _gFive
           TEKEY$ = "5"
         CASE _gSix
           TEKEY$ = "6"
         CASE _gSeven
           TEKEY$ = "7"
         CASE _gEight
           TEKEY$ = "8"
         CASE _gNine
           TEKEY$ = "9"
         CASE _gDecimal
           TEKEY$ = "."

         CASE _gClear
           EDIT$(1) = ""
           EDIT$(2) = ""
           EDIT$(4) = ""                           'Clears the input field
           BUTTON _gClear, 2 : DELAY 50 : BUTTON _gClear, 1'Highlights the Clear button

         CASE _gPlus
           EDIT$(2) = "Plus button clicked"
           EDIT$(4) = "Plus button clicked"
           DELAY 800
           FN doMath

         CASE _gMinus
           EDIT$(2) = "Minus button clicked"
           EDIT$(4) = "Minus button clicked"
           DELAY 800
           FN doMath

         CASE _gMultiply
           EDIT$(2) = "Multiply button clicked"
           EDIT$(4) = "Multiply button clicked"
           DELAY 800
           FN doMath

         CASE _gDivide
           EDIT$(2) = "Divide button clicked"
           EDIT$(4) = "Divide button clicked"
           DELAY 800
           FN doMath

         CASE _gEquals
           EDIT$(2) = "Equals button clicked"
           EDIT$(4) = "Equals button clicked"
           DELAY 800
           FN doMath

         CASE _gEnter
           EDIT$(2) = "Enter _gEnter button clicked"
           EDIT$(4) = "Enter _gEnter button clicked"
           DELAY 800
           FN doMath
           BUTTON _gEnter, 2 : DELAY 50 : BUTTON _gEnter, 1'Highlights the Enter button

         CASE _gExpandArrows
           SELECT CASE BUTTON(_gExpandArrows)
             CASE _activeBtn
               BUTTON _gExpandArrows, _markedBtn
               WINDOW CLOSE 1
               FN twoBuild
             CASE _markedBtn
               BUTTON _gExpandArrows, _activeBtn
               WINDOW CLOSE 1
               FN mainBuild
           END SELECT
       END SELECT

     CASE _efReturn
       SELECT CASE BUTTON(_efReturn)
         CASE 1
           EDIT$(2) = "Enter _efReturn button pushed"
           EDIT$(4) = "Enter _efReturn button pushed"
           DELAY 800
           FN doMath
           BUTTON _gEnter, 2 : DELAY 50 : BUTTON _gEnter, 1'Highlights the Enter button
         CASE ELSE
       END SELECT

     CASE _efClear
       EDIT$(1) = ""
       EDIT$(2) = ""                        'Clears the input field
       EDIT$(4) = ""
       BUTTON _gClear, 2 : DELAY 50 : BUTTON _gClear, 1'Highlights the Clear button

     CASE _wndClose                         'When calculator window closes, program ends
       gProgramEnds = _true

     CASE _wndRefresh                       'In this app calls the mid-gray background color
       FN mainRefresh

   END SELECT

END FN

LOCAL FN doMenu
   menuID = MENU(_menuID)
   itemID = MENU(_itemID)

   SELECT CASE
     CASE _menuID = 1 AND _itemID = 1
       gProgramEnds = _true
     CASE ELSE
   END SELECT

END FN

'----------------- Main -----------------
WINDOW OFF
COORDINATE WINDOW

ON EDIT FN checkKeys
ON DIALOG FN doDialog
ON MENU FN doMenu

FN mainBuild

DO
   HANDLEEVENTS
UNTIL gProgramEnds

'----------------- End ---------------------
Ken Shmidheiser