TweetFollow Us on Twitter

BASIC Menus
Volume Number:7
Issue Number:1
Column Tag:BASIC School

Related Info: Menu Manager

Menus in QuickBASIC

By Steven Leach, Santa Clara, CA

Using MENU Resources in Microsoft QuickBASIC

Now that Microsoft has released QuickBASIC for the Macintosh it has become possible to access the entire Macintosh ROM using the ToolBox call. This article describes the use of these ToolBox calls to utilize MENU resources. This use is not described at all in the QuickBASIC manual, nor in any of the example programs that are supplied with QuickBASIC. I have supplied actual tested code, that will allow you to see how each of the routines are used, and will describe the pitfalls that await the user of these calls.

Warning!! This type of programming is not for the faint of heart, make any mistakes, and the best you can expect is that nothing happens. The more likely result of not following the rules that I describe later is an instant bomb, and the need for a manual reset using the programmer’s switch. You may be asking yourself at this point why should I go to all this trouble when QuickBASIC gives me the MENU functions to perform these operations already? My answer is no reason at all unless you want to follow the Macintosh interface guidelines, put icons in your menus, or access the full power of the Macintosh menu system.

Resource Rules

Before I describe the routines and how to use them let me state the rules of using these calls, and how to avoid problems. I will also describe some of the resources that I will discuss.

The following rules apply only if you are going to use your routines in the interpreter mode of QuickBASIC

1) Never use a MENU resource that has the same ID number as one of the QuickBASIC MENU resources, or the same MenuID as QuickBASIC. This means that the resource ID’s of your MENU resources should not be in the range 256-262 , and the number of the MenuID should not be in the range of 1-7. This last number is the one that is returned in the function MENU(0). The first number is the unique ID that is seen when you open up the MENU resource inside ResEdit.

2) Never use a DLOG resource that has the same ID number as one of the DLOG resources used by QuickBASIC. That means that dialog boxes that you use in your program should not have a resource ID number in the range 128-145. The reason for this is that if you need to perform a search and your DLOG resource has the same ID number as the search DLOG, your dialog box will be shown not the one that QuickBASIC uses for searching. As you can imagine this can cause all sorts of problems, and funny situations.

3) Always initialize any and all variables that you use in any ToolBox call. Failure to do so will result in many spectacular bombs. Because of this, and other reasons I suggest that you always save your program before you tell the interpreter to start running the program. If this program is a minor revision and you can keep the changes in your head, then go for it. I always manage somehow.

The following rules apply whether you are using the interpreter or a compiled version of your program.

1)The MENU(0) function will always return one less than the ResEdit MenuID. For example, in my example program, my file menu has a ResEDit MenuID of 10, but the QuickBASIC MENU(0) function returns an ID of 9. This is because QuickBASIC, starts numbering the menus from zero. The MENU(1) function returns the proper code, so no problem here.

2)Do Not remove the open and close braces which I have placed around many of the variables that are referenced in the various ToolBox functions. Without the braces the information is not passed properly, and so you will get nothing but garbage in your menus.

3)If you place these toolbox calls in subroutines be sure to use braces around the same information when you call the subroutine.

4) If you use ICON’s in you MENU resources remember they must be numbered in the range 256-512, and you access them as 1,2,.... 255 not by their resource ID. This basically means the number you feed to the ToolBox routines is the icon resource ID - 255.

5) Be sure to transfer the resources over using ResEdit when you compile the application. QuickBasic doesn’t do this for you except for a few resources.

6) Note the subroutines which I have provided to convert from BASIC variable to Pascal variable types the Macintosh ROMs require. These routines are necessary to convert the 4 character resource string that is used in BASIC to the 4 byte variable that is used by the Macintosh ROM. The other routines convert the style string that is customarily used in the resource compilers into an integer that is compatible with the Macintosh ROM and vice versa. Also note the intermittent use of the BASIC SADD function in order to send the address of a string variable to the ROM routine, in some cases using the SADD function is deadly. I have experimented with all these routines on a Mac Plus, Mac SE and a Mac II to make sure they work properly. The lesson is change them at your own risk.

The Calls

Those are the “rules” to follow, if you follow them diligently all will be well, if you don’t; good luck. Now for a description of the Calls and what they can be used for. In each of the QuickBASIC calls you must specify the type of return if any by using a single or double letter code. As you can see from the listing only four of the functions associated with Menus return a value, in most cases a handle to a menu, in the other case an integer number corresponding to the number of items in the menu. I have used a “Q” following each function in order to disable the argument checking function that is built into QuickBASIC. If you wish you may use the specially converted ResEdit that is supplied with the QuickBASIC to create argument checking functions for each of these calls.

With each of the functions I have provided a Trap value that is used to call the particular ROM routine, an example template of the ToolBox call, and the argument checking template that can be inputted using the QuickBASIC converted ResEdit. At this point I would like to thank Stephen Chernicoff the author of Macintosh Revealed, which I used extensively, and of course the authors and editors of Inside Macintosh.

The example program I have included starts off by reading the MENU resources from it’s own resource fork, and then sets up a processing loop to perform the various functions when the user selects an item from the function menu. I don’t perform any cut,copy paste so I just trap this function and print out the choice you made. The Graph Menu and File Menus show some of the reasons you may decide that using resource MENU’s instead of application built ones are more fun and just as easy to use.

By using the function provided in the Function Menu you can change any of the current menus,load another resource menu that you have created in ResEdit, or create a new menu and add items to it. This simple program does not allow you to save your work, although you could change the File Menu to include a save function and then use the WriteRes or AddRes functions that are described in the QuickBASIC manual.

The general procedure that I have implemented in using these functions in any of my QuickBASIC programs is as follows:

1) Create a BASIC program with a minimal amount of code to act as a holding place for the resources.

2) Use ResEDit to create the necessary resources in that QuickBASIC file. Remembering to write down the Resource ID numbers and other ID’s. For example, in the dialog boxes I use to prompt the user for information to feed the ToolBox calls, I must specifically reference each element by number.

3) Save my work when ResEdit asks me to save the work I have done.

4) Use the ToolBox functions instead of the BASIC Menu functions to change the state and look of the menus. If you try to use the QuickBASIC Menu function, to change any of the menus you have brought in as resources you will only cause problems for yourself. It’s OK to use the MENU(0) and MENU(1) functions to determine which menus the user has selected.

REM Define function to get MenuID from MenuHandle that is in memory
    DEF FN GetMenuID(MenuHandle&) = PEEKW(PEEKL(MenuHandle&))

REM initialize QuickBASIC toolBox routines This is a must !!!!
ToolBox “I”

REM these are the Toolbox Trap values and examples of how to use the 
ToolBox calls
REM I have also included the Values for the MTBS resource template for 
error checking
REM In that case you can elect not to put in the Q i.e. use “P” not “PQ”

ReleaseResource% = &HA9A3 
REM ToolBox “PQ”,ReleaseResource%,(MenuHandle&)
DrawMenuBar% = &HA937
REM ToolBox “PQ”,DrawMenuBar%
NewMenu% = &HA931
REM ToolBox “LQ”,NewMenu%,(MenuID%),SADD(Pascal.MenuTitle$),MenuHandle&
GetMenu% = &HA9BF
REM ToolBox “LQ”,GetMenu%,(MenuRsrcID%),MenuHandle&
DisposeMenu% = &HA932
REM  ToolBox “PQ”,DisposeMenu%,(MenuHandle&)
InsertMenu% = &H935
REM ToolBox “PQ”,InsertMenu%, (MenuHandle&),(beforeID%)
ClearMenuBar% = &HA934
REM ToolBox “PQ”,ClearMenuBar%
AppendMenu% = &HA933
REM ToolBox “PQ”,AppendMenu%,(MenuHandle&),SADD(Pascal.defString$)
AddResMenu% = &HA94D
REM ToolBox “PQ”,AddResMenu%,(MenuHandle&),(ResType&)
InsertResMenu% = &HA951
REM ToolBox “PQ”,InsertResMenu%,(MenuHandle&),(ResType&),(afterItem%)
CountMItems%  = &HA950
REM ToolBox “WQ”,CountMItems%,(MenuHandle&),NMenuItems%
DeleteMenu% = &HA936
REM ToolBox “PQ”,DeleteMenu%,(MenuID%)
GetMHandle% = &HA949
REM ToolBox “LQ”,GetMHandle%,(MenuID%),MenuHandle&
SetItem% = &HA947
REM ToolBox “PQ”,SetItem%,(MenuHandle&),(theItem%),SADD(Pascal.itemString$)
GetItem% = &HA946
REM  ToolBox “PQ”,GetItem%,(MenuHandle&),(theItem%),itemString$
DisableItem% = &HA93A
REM ToolBox “PQ”,DisableItem%,(MenuHandle&),(theItem%)
EnableItem% = &HA939
REM ToolBox “PQ”,EnableItem%,(MenuHandle&),(theItem%)
SetItemStyle% = &HA942
REM ToolBox “PQ”,SetItemStyle%,(MenuHandle&),(theItem%),(theStyle%)
GetItemStyle% = &HA941
REM ToolBox “PQ”,GetItemStyle%,(MenuHandle&),(theItem%),theStyle%
CheckItem% = &HA945
REM ToolBox “PQ”,CheckItem%,(MenuHandle&),(theItem%),(Checked%) ( 0,1)
SetItemMark% = &HA944
REM ToolBox “PQ”,SetItemMark%,(MenuHandle&),(theItem%),(markChar%)
GetItemMark% = &HA943
REM ToolBox “PQ”,GetItemMark%,(MenuHandle&),(theItem%),markChar%
SetItemIcon% = &HA940
REM ToolBox “PQ”,SetItemIcon%,(MenuHandle&),(theItem%),(iconNum%)
GetItemIcon% = &HA93F
REM ToolBox “PQ”,GetItemIcon%,(MenuHandle&),(theItem%),iconNum%
SetMenuFlash% = &HA94A
REM ToolBox “PQ”,SetMenuFlash%,(flashCount%)
FlashMenuBar% = &HA94C
REM ToolBox “PQ”,FlashMenuBar%,(MenuID%)

True% = (1<2)
False% = (1>2)

REM Initialize some variables and arrays that are used to keep track 
of the Menus, and their states
res.ref% = 0
DIM MenuHandle&(10),ResMenu%(10),MenuID%(10)
ResType& = 0&
Dialog.Hnd& = 0&
tMenuHandle& = 0&
Num.of.Menu% = 5

res.ref% = SYSTEM(7)

REM Delete File and Edit Menu that QuickBASIC pout up when you are using 
the interpretor
REM Remove these lines if you complie the program with the No Default 
Menus Option.
ToolBox “PQ”,DeleteMenu%,(2)
ToolBox “PQ”,DeleteMenu%,(3)

REM Load in my resource Menus that included in this BASIC program
FOR indx% = 0 TO Num.of.Menu%-1
    MenuRsrcID% = 263+indx%
    ToolBox “LQ”,GetMenu%,(MenuRsrcID%),tMenuHandle&
    IF (tMenuHandle& > 0) THEN
        MenuHandle&(indx%+1) = tMenuHandle&
        ToolBox “PQ”,InsertMenu%, (MenuHandle&(indx%+1)),(0)
        ResMenu%(indx%+1) = True%
        MenuID%(indx%+1) = FN GetMenuID(MenuHandle&(indx%+1))
    ELSE
        PRINT  indx% “Has an invalid Menu handle “
        STOP
    END IF
NEXT

REM now that all the MENU resources are in memory Draw the Menu Bar to 
show them.
ToolBox “PQ”,DrawMenuBar%

REM This is the Main processing loop that checks for Menu activity
Quit% = False%
CLS
WHILE MOUSE(0) <> 0 : WEND

WHILE NOT Quit%
    Menu0 = MENU(0)+1
    menu1 = MENU(1)
    MENU
    IF (Menu0 >=10 ) THEN
        ON Menu0 - MenuID%(1)+1 GOSUB FileMenu,EditMenu,menu1,Menu2,Menu3
        PRINT Menu0,MENU(1)
    END IF
WEND

REM Dispose of all menu handles to free memory that was allocated by 
program and user
REM Note the use of two forms of memory deallocation
REM One to resource MENU’s and one for menus built from scratch.
FOR indx% = 1 TO Num.of.Menu%
    IF (ResMenu%(indx%)) THEN
        ToolBox “PQ”,ReleaseResource%,(MenuHandle&(indx%))
    ELSE
         ToolBox “PQ”,DisposeMenu%,(MenuHandle&(indx%))
     END IF
NEXT
ToolBox “PQ”,ClearMenuBar%
REM finally end the program
END

FileMenu:
Quit% = True%
RETURN

EditMenu:

Nothing:
RETURN

menu1: REM My Icon MENU
PRINT “You have Chosen Menu #”;Menu0; “ Item Number “;menu1
RETURN

Menu2: REM My Sample Menu and Menu to try the various dialog boxes that 

REM I use TO entry of information
Entry0$ = “Entry 0”
Entry1$ = “Entry 1”
Entry2$ = “Entry 3”
ON MENU(1) GOSUB singleEntry,DoubleEntry,TripleEntry
PRINT “You have Chosen Menu #”;Menu0; “ Item Number “;menu1
RETURN

Menu3: REM Function Menu
IF (MENU(1) <= 10) THEN
ON MENU(1) GOSUB GetMenu,NewMenu,AppendMenu,AddResMenu,InsertResMenu,DeleteMenu, 
GetMenuHandle,CountMItems,SetItem,GetItem,DisableItem,EnableItem
ELSE
ON MENU(1)-12 GOSUB SetItemStyle,GetItemStyle,CheckItem,SetItemMark,GetItemMark, 
SetItemIcon,GetItemIcon,FlashMenuBar
END IF
RETURN

GetMenu: REM Get a MENU resource that is sitting in this file
    IF Num.of.Menu% >= 10 THEN
        PRINT “ You have too many Menus already “
        RETURN
    END IF
    Entry0$ = “ID of MENU resource ?”
    GOSUB singleEntry
    IF (LEN(Entry0$) < 1 ) THEN RETURN
    MenuRsrcID% = VAL(Entry0$)
    tMenuHandle& = 0&
    ToolBox “LQ”,GetMenu%,MenuRsrcID%,tMenuHandle&
    IF (tMenuHandle& <> 0) THEN
        Num.of.Menu% = Num.of.Menu%+1
        MenuHandle&(Num.of.Menu%) = tMenuHandle&
        ResMenu%(Num.of.Menu%) = True%
        MenuID%(Num.of.Menu%) = 10
        ToolBox “PQ”,InsertMenu%, (MenuHandle&(Num.of.Menu%)),(0)
        ToolBox “PQ”,DrawMenuBar%
    ELSE
        PRINT “ Resource was not valid “
    END IF
RETURN

NewMenu: REM create a whole new menu and append it to the Menu bar
    Entry0$ = “Menu Title ?”
    Entry1$ = “Menu ID% ? “
    GOSUB DoubleEntry
    IF (LEN(Entry0$) < 1) THEN RETURN
    MenuID% = VAL(Entry1$)
    FOR indx% = 1 TO Num.of.Menu%
        IF(MenuID%(indx%) = MenuID%) THEN
            PRINT  “The Menu Id Conflicts with a Previous Menu”
            RETURN
        END IF
    NEXT
    Pascal.MenuTitle$ = “”
    B2PStr Entry0$,Pascal.MenuTitle$
    ToolBox “LQ”,NewMenu%,(MenuID%),SADD(Pascal.MenuTitle$),tMenuHandle&
    IF (tMenuHandle& <> 0) THEN
        Num.of.Menu% = Num.of.Menu% +1
        MenuHandle&(Num.of.Menu%) = tMenuHandle&
        ResMenu%(Num.of.Menu%) = False%
        MenuID%(Num.of.Menu%) = MenuID%
        ToolBox “PQ”,InsertMenu%, (tMenuHandle&),(0)
        ToolBox “PQ”,DrawMenuBar%
    ELSE
        PRINT “ The Menu Handle returned was not valid”
    END IF

RETURN

AppendMenu: REM Append a string to a currently defined menu wether visible 
or not
    Entry0$ = “Which Menu ?”
    Entry1$ = “String to Append ?”
    GOSUB DoubleEntry
    IF LEN(Entry0$) <1 THEN RETURN
    MenuID% = VAL(Entry0$)
    Pascal.defString$ = “”
    B2PStr Entry1$,Pascal.defString$
    ToolBox “PQ”,AppendMenu%,(MenuHandle&(MenuID%)),SADD(Pascal.defString$)
    ToolBox “PQ”,DrawMenuBar%
RETURN

AddResMenu: REM add a menu to the Menu bar that contains the names of 
the resources of the 
REM type specified by User, examples are FONT, DRVR, ICON etc.
    CLS
    IF (Num.of.Menu% >=10) THEN RETURN
    Entry0$ = “Which Resource to put in Menu “+STR$(Num.of.Menu%+1)
    Entry1$ = “Title of Menu ?”
    Entry2$ = “Menu ID (integer) ?”
    GOSUB TripleEntry
    IF LEN(Entry0$) <1 THEN RETURN
    IF (LEN(Entry0$) < 1 OR LEN(Entry0$) > 4) THEN RETURN
    IF (LEN(Entry1$) < 1) THEN Entry1$ = “Empty”
    MenuID% = VAL(Entry2$)
    Num.of.Menu% = Num.of.Menu%+1
    CALL StringtoResType(Entry0$,ResType&)
    Pascal.MenuTitle$ = “”
    B2PStr Entry1$,Pascal.MenuTitle$
    
    tMenuHandle& = 0
    ToolBox “LQ”,NewMenu%,(MenuID%),SADD(Pascal.MenuTitle$),tMenuHandle&
    IF (tMenuHandle& <> 0) THEN
        MenuHandle&(Num.of.Menu%) = tMenuHandle&
        ResMenu%(Num.of.Menu%) = False%
        MenuID%(Num.of.Menu%) = MenuID%
        ToolBox “PQ”,AddResMenu%,(tMenuHandle&),(ResType&)
        ToolBox “PQ”,InsertMenu%, (tMenuHandle&),(0)
        ToolBox “PQ”,DrawMenuBar%
    ELSE
        PRINT “ The Menu Handle returned was not valid”
    END IF
    RETURN
    
InsertResMenu: REM Insert roesource Menu at a place in a currently defined 
menu
    Entry0$ = “Which Menu ?”
    Entry1$ = “Which Item to Insert after ?”
    Entry2$ = “Which Resource ?”
    GOSUB TripleEntry
    IF(LEN(Entry0$) < 1) THEN RETURN
    MenuID% = VAL(Entry0$)
    afterItem% = VAL(Entry1$)
    ResType& = 0&
    CALL StringtoResType(Entry2$,ResType&)
    ToolBox “PQ”,InsertResMenu%,(MenuHandle&(MenuID%)), (ResType&),(afterItem%)
RETURN

DeleteMenu: REM Delete a currently shown Menu and deallocate the memory 
for it
    Entry0$ = “ID of Menu to Delete ?”
    GOSUB singleEntry
    IF LEN(Entry0$) <1 THEN RETURN
    MenuID% =VAL(Entry0$)
    WhichMenu% = 0
    FOR indx% = 1 TO Num.of.Menu%
        IF MenuID% = MenuID%(indx%) THEN WhichMenu% = indx%
    NEXT
    IF WhichMenu% = 0 THEN RETURN
    ToolBox “PQ”,DeleteMenu%,(MenuID%)
    IF (ResMenu%(WhichMenu%)) THEN
        ToolBox “PQ”,ReleaseResource%,(MenuHandle&(WhichMenu%))
    ELSE
         ToolBox “PQ”,DisposeMenu%,(MenuHandle&(WhichMenu%))
     END IF
        
    PRINT “ Menu “MenuID%” has been deleted”
    FOR indx% = WhichMenu% TO Num.of.Menu%-1
        MenuHandle&(indx%) =MenuHandle&(indx%+1)
    NEXT
    Num.of.Menu% = Num.of.Menu% -1
    ToolBox “PQ”,DrawMenuBar%
RETURN

GetMenuHandle: REM return the Handle for a currently shown menu
    Entry0$ = “Which Menu ?”
    GOSUB singleEntry
    IF (LEN(Entry0$) < 1) THEN RETURN
    tMenuHandle& = 0
    MenuPlace% = VAL(Entry0$)
    ToolBox “LQ”,GetMHandle%,(MenuID%(MenuPlace%)),tMenuHandle&
    PRINT “The Handle for Menu “MenuID% “ is “tMenuHandle&” the ID is 
“MenuID%(MenuPlace%)
RETURN

CountMItems: REM Count the number of items in a currently defined menu
    NMenuItems% = 0
    Entry0$ = “Count Items in Which Menu ?”
    GOSUB singleEntry
    IF LEN(Entry0$) <1 THEN RETURN
    MenuID% = VAL(Entry0$)
    ToolBox “WQ”,CountMItems%,(MenuHandle&(MenuID%)),NMenuItems%
    PRINT  “Number of Menu Items in “;MenuID%;” is “NMenuItems%
RETURN

SetItem: REM Set the Item string for a currently defined menu
REM you may use all of formating characters permissible in MENU resources
Entry0$ = “Which Menu ?”
Entry1$ = “Which Item ? “
Entry2$ = “String to change Item to”
GOSUB TripleEntry
IF LEN(Entry0$) <1 THEN RETURN
MenuID% = VAL(Entry0$)
theItem% = VAL(Entry1$)
Pascal.itemString$ = “”
B2PStr Entry2$,Pascal.itemString$
ToolBox “PQ”,SetItem%,(MenuHandle&(MenuID%)),(theItem%), SADD(Pascal.itemString$) 

RETURN

GetItem: REM Retrieve the item string for a currently defined MENU resource
    Entry0$ = “Which Menu ?”
    Entry1$ = “Which Item ?”
    GOSUB DoubleEntry
    IF (LEN(Entry0$) < 1) THEN RETURN
    MenuID% = VAL(Entry0$)
    theItem% = VAL(Entry1$)
    itemString$ = “”
    ToolBox “PQ”,GetItem%,(MenuHandle&(MenuID%)),(theItem%),itemString$
    PRINT  “The Item “theItem%” in Menu “MenuID%” is “itemString$
    RETURN
    
DisableItem: REM Disable or Grey out an Item in a currently defined Menu
    Entry0$ = “Disable Which Item ?”
    Entry1$ = “Which Menu ?”
    GOSUB DoubleEntry
    IF LEN(Entry0$) <1 THEN RETURN
    MenuID% = VAL(Entry1$)
    theItem% = VAL(Entry0$)
    ToolBox “PQ”,DisableItem%,(MenuHandle&(MenuID%)),(theItem%)
    PRINT “ Item “theItem%” in Menu # “MenuID% “ was disabled”
    RETURN
    
EnableItem:REM Enable of make active an item in a currently defined menu
    Entry0$ = “Enable Which Item ?”
    Entry1$ = “Which Menu ?”
    GOSUB DoubleEntry
    IF LEN(Entry0$) <1 THEN RETURN
    MenuID% = VAL(Entry1$)
    theItem% = VAL(Entry0$)
    ToolBox “PQ”,EnableItem%,(MenuHandle&(MenuID%)),(theItem%)
    PRINT “ Item “theItem%” in Menu # “MenuID% “ was enabled”
    RETURN

SetItemStyle: REM Set the style of an item in a currently defined Menu
    Entry0$ = “Which Menu ?”
    Entry1$ = “Which Item ?”
    Entry2$ = “The Style String ?”
    GOSUB TripleEntry
    IF(LEN(Entry0$) < 1 ) THEN RETURN
    theStyle% = 0
    CALL StringtoStyle(Entry2$,theStyle%)
    MenuID% = VAL(Entry0$)
    theItem% = VAL(Entry1$)
    ToolBox “PQ”,SetItemStyle%,(MenuHandle&(MenuID%)),(theItem%),(theStyle%)
RETURN

GetItemStyle: REM retrieve the stryle string for a particular item in 
a currently defined Menu
    Entry0$ = “Which Menu ? “
    Entry1$ = “Which Item ?”
    GOSUB DoubleEntry
    IF(LEN(Entry0$) < 1) THEN RETURN
    MenuID% = VAL(Entry0$)
    theItem% = VAL(Entry1$)
    theStyle% = 0
    ToolBox “PQ”,GetItemStyle%,(MenuHandle&(MenuID%)),(theItem%),theStyle%
    CALL StyletoString(StyleString$,theStyle%)
    PRINT “The Style of item “theItem%” in Menu “MenuID%” is “theStyle%”,”StyleString$
    RETURN
    
 CheckItem:REM Put a check by an item in a currently defined Menu
     Entry0$ = “Which Menu ?”
     Entry1$ = “Which Item ? “
     Entry2$ = “Check (1) or Uncheck(0) Item ?”
     GOSUB TripleEntry
     IF (LEN(Entry0$) < 1 ) THEN RETURN
     MenuID% = VAL(Entry0$)
     theItem% = VAL(Entry1$)
     Checked% = 256*ABS(VAL(Entry2$) = 1) ‘ acount for using 2 bytes 
instead on one
     ToolBox “PQ”,CheckItem%,(MenuHandle&(MenuID%)),(theItem%),(Checked%)
 RETURN
    
SetItemMark:REM mark a particular item ina currently defined menu
REM  with the character whose ASCII code is given by the user
    Entry0$ = “Which Menu ?”
    Entry1$ = “Which Item ?”
    Entry2$ = “What is the mark ASCII code ?”
    GOSUB TripleEntry
    IF LEN(Entry0$) <1 THEN RETURN
    MenuID% = VAL(Entry0$)
    theItem% = VAL(Entry1$)
    markChar% = VAL(Entry2$) ‘ account for use of integer instead of 
single byte
    ToolBox “PQ”,SetItemMark%,(MenuHandle&(MenuID%)),(theItem%),(markChar%)
    REM markChar% = markChar%/256
    PRINT  “Item “theItem%” of Menu “MenuID%” was marked with “CHR$(markChar%)”,”markChar%
    RETURN
RETURN

GetItemMark:REM get the Marking character if any 
            REM FOR a particular item in a currently defined MENU
    markChar% = 0
    Entry0$ = “Which Menu ?”
    Entry1$ = “Which Item ?”
    GOSUB DoubleEntry
    IF LEN(Entry0$) <1 THEN RETURN
    MenuID% = VAL(Entry0$)
    theItem% = VAL(Entry1$)
    ToolBox “PQ”,GetItemMark%,(MenuHandle&(MenuID%)),(theItem%),markChar%
    PRINT “The Mark Character for item “ theItem%” in Menu Number “MenuID%” 
is “markChar%”,”CHR$(markChar%)
    RETURN
    
SetItemIcon: REM Give a particular item in a currently defined Menu an 
ICON that
REM already exists in the resources of this program.
    Entry0$ = “Which Menu ?”
    Entry1$ = “Which Item ?”
    Entry2$ = “Resource # of ICON”
    GOSUB TripleEntry
    IF LEN(Entry0$) <1 THEN RETURN
    MenuID% = VAL(Entry0$)
    theItem% = VAL(Entry1$)
    iconRsrcID% = VAL(Entry2$)
    iconNum% = ABS((iconRsrcID% -256)*(iconRsrcID% > 256))
     ToolBox “PQ”,SetItemIcon%,(MenuHandle&(MenuID%)),(theItem%),(iconNum%)
RETURN

GetItemIcon:REM Retrieve the ICON number of a particular item in a currently 
defined Menu
                    REM If there is no ICON it will return 0
    iconNum% = 0
    Entry0$ = “Which Menu ?”
    Entry1$ = “Which Item ? “
    GOSUB DoubleEntry
    MenuID% = VAL(Entry0$)
    theItem% = VAL(Entry1$)
    ToolBox “PQ”,GetItemIcon%,(MenuHandle&(MenuID%)),(theItem%),iconNum%
    iconRsrcID% = iconNum%+256
    PRINT  “The Icon Number assiciated with Item “theItem%” in Menu “MenuID%” 
is “iconNum%
    PRINT “The resource number of this icon is “iconRsrcID%
RETURN

FlashMenuBar: REM Flash a Particular Menu, or inver the entire Menu bar
REM if the MenuID is 0 then the entire Menu Bar is inverted
Entry0$ = “Enter Menu ID (integer)”
GOSUB singleEntry
IF LEN(Entry0$) <1 THEN RETURN
MenuID% = VAL(Entry0$)
ToolBox “PQ”,FlashMenuBar%,(MenuID%)
RETURN

REM Dialog Box to single additional parameter for calling func
singleEntry:
ButtonPushed% = 0
GETNEWDIALOG res.ref%,146,Dialog.Hnd&
SetDialogText Dialog.Hnd&,4,Entry0$

ModalDialog Dialog.Hnd&,ButtonPushed%

REM if Cancel Button is pushed then send back nothing
IF ButtonPushed% = 2 THEN
    DisposeDialog Dialog.Hnd&
    Entry0$ = “”
    RETURN
END IF

GetDialogText Dialog.Hnd&,3,Entry0$

DisposeDialog Dialog.Hnd&
RETURN

DoubleEntry:
ButtonPushed% = 0
GETNEWDIALOG res.ref%,147,Dialog.Hnd&
SetDialogText Dialog.Hnd&,3,Entry0$
SetDialogText Dialog.Hnd&,4,Entry1$

ModalDialog Dialog.Hnd&,ButtonPushed%

REM if Cancel Button is pushed then send back nothing
IF ButtonPushed% = 2 THEN
    DisposeDialog Dialog.Hnd&
    Entry0$ = “”
    Entry1$ = “”
    RETURN
END IF

GetDialogText Dialog.Hnd&,5,Entry0$
GetDialogText Dialog.Hnd&,6,Entry1$

DisposeDialog Dialog.Hnd&
RETURN

TripleEntry:
ButtonPushed% = 0
GETNEWDIALOG res.ref%,148,Dialog.Hnd&
SetDialogText Dialog.Hnd&,3,Entry0$
SetDialogText Dialog.Hnd&,4,Entry1$
SetDialogText Dialog.Hnd&,5,Entry2$

ModalDialog Dialog.Hnd&,ButtonPushed%

REM if Cancel Button is pushed then send back nothing
IF ButtonPushed% = 2 THEN
    DisposeDialog Dialog.Hnd&
    Entry0$ = “”
    Entry1$ = “”
    Entry2$ = “”
    RETURN
END IF

GetDialogText Dialog.Hnd&,6,Entry0$
GetDialogText Dialog.Hnd&,7,Entry1$
GetDialogText Dialog.Hnd&,8,Entry2$

DisposeDialog Dialog.Hnd&
RETURN

REM Function to translate a string containing the name of a resource 
into 
REM the 4 byte packed character array that is required by the ROM routines
SUB StringtoResType(bString$,ResType&) STATIC
    IF (LEN(bString$) < 4) THEN EXIT SUB
    ResType& = ASC(RIGHT$(bString$,1))
    ResType& = ResType& + &H100*ASC(MID$(bString$,3,1))
    ResType& = ResType&+&H10000&*ASC(MID$(bString$,2,1))
    ResType& = ResType&+&H1000000&*ASC(LEFT$(bString$,1))
END SUB

REM Subroutine to convert the Style integer into a string that is understandable 
to us humans
SUB StyletoString(StyleString$,theStyle%) STATIC
    IF (theStyle% = 0) THEN
        StyleString$ = “<P”
        EXIT SUB
    END IF
    
    StyleString$ = “”
    IF (theStyle% AND 1) THEN StyleString$ =”<B”
    IF (theStyle% AND 2) THEN StyleString$ = StyleString$+”<I”
    IF(theStyle% AND 4) THEN StyleString$ = StyleString$+”<U”
    IF (the Style% AND 8) THEN StyleString$ = StyleString$ +”<O”
    IF(theStyle% AND 16) THEN StyleString$ = StyleString$ +”<S”
    IF(theStyle% AND 32) THEN StyleString$ = StyleString$ +”<C”
    IF(theStyle% AND 64) THEN StyleString$ = StyleString$+”<E”
END SUB

REM Subroutine to conver the Style String we humans understand into a 
style byte that the ROIM routines want and use
SUB StringtoStyle(StyleString$,theStyle%) STATIC
    IF (LEN(StyleString$) < 2) THEN
        theStyle% = 0
        EXIT SUB
    END IF
    
    strlen = LEN(StyleString$)
    TmpString$ = LEFT$(StyleString$,2)
    WHILE strlen > 0
        TmpString$ = LEFT$(StyleString$,2)
        IF (TmpString$ = “<P”) THEN theStyle% = 0 : EXIT SUB
        IF (TmpString$ = “<B”) THEN theStyle% = theStyle% OR 1 ‘ Bold 
Type
        IF (TmpString$ = “<I”) THEN theStyle% = theStyle% OR 2 ‘Italic 
Type
        IF (TmpString$ = “<U”) THEN theStyle% = theStyle% OR 4 ‘ Underline 
type
        IF (TmpString$ = “<O”) THEN theStyle% = theStyle% OR 8 ‘Outline 
type
        IF (TmpString$ = “<S”) THEN theStyle% = theStyle% OR 16 ‘ Shadow 
Type
        IF (TmpString$ = “<C”) THEN theStyle% = theStyle% OR 32 ‘Condensed 
Type
        IF (TmpString$ = “<E”) THEN theSytle% = theStyle% OR 64 ‘Extended 
type
        StyleString$ = RIGHT$(StyleString$,LEN(StyleString$)-2)
        strlen = LEN(StyleString$)
    WEND
END SUB

 
AAPL
$107.59
Apple Inc.
+0.61
MSFT
$46.76
Microsoft Corpora
+0.71
GOOG
$556.34
Google Inc.
+6.03

MacTech Search:
Community Search:

Software Updates via MacUpdate

Dropbox 2.10.44 - Cloud synchronization...
Dropbox is an application that creates a special Finder folder that automatically syncs online and between your computers. It allows you to both backup files and keep them up-to-date between systems... Read more
Sandvox 2.9.2 - Easily build eye-catchin...
Sandvox is for Mac users who want to create a professional looking website quickly and easily. With Sandvox, you don't need to be a Web genius to build a stylish, feature-rich, standards-compliant... Read more
Cocktail 8.0.1 - General maintenance and...
Cocktail is a general purpose utility for OS X that lets you clean, repair and optimize your Mac. It is a powerful digital toolset that helps hundreds of thousands of Mac users around the world get... Read more
LibreOffice 4.3.3.2 - Free Open Source o...
LibreOffice is an office suite (word processor, spreadsheet, presentations, drawing tool) compatible with other major office suites. The Document Foundation is coordinating development and... Read more
VMware Fusion 7.0.1 - Run Windows apps a...
VMware Fusion allows you to create a Virtual Machine on your Mac and run Windows (including Windows 8.1) and Windows software on your Mac. Run your favorite Windows applications alongside Mac... Read more
OneNote 15.3.2 - Free digital notebook f...
OneNote is your very own digital notebook. With OneNote, you can capture that flash of genius, that moment of inspiration, or that list of errands that's too important to forget. Whether you're at... Read more
Audio Hijack Pro 2.11.4 - 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
Iridient Developer 3.0.0 beta 3 - Powerf...
Iridient Developer (was RAW Developer) is a powerful image conversion application designed specifically for OS X. Iridient Developer gives advanced photographers total control over every aspect of... Read more
TextWrangler 4.5.11 - Free general purpo...
TextWrangler is the powerful general purpose text editor, and Unix and server administrator's tool. Oh, and also, like the best things in life, it's free. TextWrangler is the "little brother" to... Read more
NeoFinder 6.6 - Catalog your external me...
NeoFinder (formerly CDFinder) rapidly organizes your data, either on external or internal disks, or any other volumes. It catalogs all your data, so you stay in control of your data archive or disk... Read more

Latest Forum Discussions

See All

This Is Not a Test Goes Free, Permanentl...
This Is Not a Test Goes Free, Permanently Posted by Jessica Fisher on October 31st, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Swap Heroes Review
Swap Heroes Review By Campbell Bird on October 31st, 2014 Our Rating: :: STRATEGIC SWAPPINGUniversal App - Designed for iPhone and iPad Rotate a cast of heroes to fend of waves of monsters in this difficult, puzzle rpg.   | Read more »
Night Sky Pro™ (Reference)
Night Sky Pro™ 3.0.1 Device: iOS Universal Category: Reference Price: $2.99, Version: 3.0.1 (iTunes) Description: Night Sky Pro™Wonder No More™ Night Sky Pro™ is the ultimate stargazing experience. From the creators of the original... | Read more »
Audio Defence : Zombie Arena (Games)
Audio Defence : Zombie Arena 1.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: A zombie shooter audio game. Made from gut-wrenching 3D binaural sound, for a new kind of weird immersion. You... | Read more »
RPG Asdivine Hearts (Games)
RPG Asdivine Hearts 1.1.0 Device: iOS Universal Category: Games Price: $3.99, Version: 1.1.0 (iTunes) Description: SPECIAL PRICE50% OFF (USD 7.99 -> USD 3.99)!!! Travel alongside four companions and a cat in the adventure of a... | Read more »
Haunt the House: Terrortown (Games)
Haunt the House: Terrortown 1.0.1 Device: iOS Universal Category: Games Price: $.99, Version: 1.0.1 (iTunes) Description: 66.6% OFF! SPECIAL SPOOKY HALLOWEEN LAUNCH PRICE! 66.6% OFF! ...What was that sound? Is somebody there? | Read more »
SAS: Zombie Assault 4 Review
SAS: Zombie Assault 4 Review By Jennifer Allen on October 30th, 2014 Our Rating: :: FLAWED SHOOTERUniversal App - Designed for iPhone and iPad Shoot everything that moves in this fun, if flawed, twin-stick shooter.   | Read more »
Naailde the Witch Review
Naailde the Witch Review By Amy Solomon on October 30th, 2014 Our Rating: :: PITCH-PERFECT STORYTELLINGUniversal App - Designed for iPhone and iPad Marvelous storytelling, narration, and moving illustrations make this storybook... | Read more »
1st & Goal Review
1st & Goal Review By Andrew Fisher on October 30th, 2014 Our Rating: :: FOR THE D&D LOVING QBUniversal App - Designed for iPhone and iPad 1st & Goal is a board gamer’s football game, a football fan’s board game, and... | Read more »
French Developer Pated Unveils Seashine
French Developer Pated Unveils Seashine Posted by Ellis Spice on October 30th, 2014 [ permalink ] French one-man studio Pated has unveiled Seashine, “a poetic journey into the abyss.” Players take on the role of a jellyfish strugglin | Read more »

Price Scanner via MacPrices.net

Apple Regains Momentum As Windows Stutters An...
The latest smartphone sales data from Kantar Worldpanel ComTech, for the three months to March 2014, shows Apple performing strongly in the first quarter of the year, with sales bouncing back in... Read more
Worldwide Smartphone Shipments Increase 25.2%...
New smartphone releases and an increased emphasis on emerging markets drove global smartphone shipments above 300 million units for the second consecutive quarter, according to preliminary data from... Read more
Apple now offering refurbished 2014 15-inch M...
The Apple Store is now offering Apple Certified Refurbished 2014 15″ Retina MacBook Pros for up to $400 off the cost of new models. An Apple one-year warranty is included with each model, and... Read more
Apple drops prices on refurbished 2013 Retina...
The Apple Store has dropped prices on 2013 Apple Certified Refurbished 13″ and 15″ Retina MacBook Pros, with Retina models now available starting at $999. Apple’s one-year warranty is standard, and... Read more
New 2.8GHz Mac mini on sale for $949, save $5...
Abt Electronics has the new 2.8GHz Mac mini in stock and on sale for $949.05 including free shipping. Their price is $50 off MSRP, and it’s the lowest price available for this model from any reseller... Read more
Sale! 3.7GHz Quad Core Mac Pro available for...
 B&H Photo has the 3.7GHz Quad Core Mac Pro on sale for $2649 including free shipping plus NY sales tax only. Their price is $350 off MSRP, and it’s the lowest price for this model from any... Read more
Mujjo Steps Up The Game With Refined Touchscr...
Netherlands based Mujjo have just launched their Refined Touchscreen Gloves, stepping up their game. The gloves feature a updated elegant design that takes these knitted gloves to the next level. A... Read more
Sale! Preorder the new 27-inch 5K iMac for $2...
 Abt Electronics has the new 27″ 3.5GHz 5K iMac on sale and available for preorder for $2374.05 including free shipping. Their price is $125 off MSRP, and it’s the lowest price available for this... Read more
Simplex Solutions Inc. Brings Secure Web Surf...
New York based Simplex Solutions Inc. has announced the release and immediate availability of Private Browser 1.0, its revolutionary new secure web browser developed for iPhone, iPad and iPod touch... Read more
Save up to $180 off MSRP with an Apple refurb...
The Apple Store has Apple Certified Refurbished 2014 MacBook Airs available for up to $180 off the cost of new models. An Apple one-year warranty is included with each MacBook, and shipping is free.... Read more

Jobs Board

Position Opening at *Apple* - Apple (United...
**Job Summary** Every day, business customers come to the Apple Store to discover what powerful, easy-to-use Apple products can do for them. As a Business Leader, Read more
Sr. Manager, *Apple* Deployment Programs fo...
**Job Summary** Apple is seeking candidates for a new position on the Education Content and Technology team. iPad and Mac is in the hands of millions of teachers and Read more
*Apple* Solutions Consultant (ASC) - Apple I...
…important role that the ASC serves is that of providing an excellent Apple Customer Experience. Responsibilities include: * Promoting Apple products and solutions Read more
*Apple* Solutions Consultant (ASC) - Apple I...
…important role that the ASC serves is that of providing an excellent Apple Customer Experience. Responsibilities include: * Promoting Apple products and solutions Read more
*Apple* Solutions Consultant (ASC) - Apple I...
…important role that the ASC serves is that of providing an excellent Apple Customer Experience. Responsibilities include: * Promoting Apple products and solutions Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.