Terrapin Resources

Menu Commands

This section explains the command that you can use to modify the menu of Terrapin Logo. Please note that menu handling has changed. The menu ID is not numeric anymore; it can also be a word (and it is actually for the built-in commands).

Also, referring to menus is now strictly by ID than by name. In Logo 4, you used the menu label to reference the menu, which is unfortunate if you want to translate a menu.

The Logo 4 commands ONCOMMAND and APPENDMENUCOMMAND commands are gone.

An example:

Note that Logo only checks commands that you have defined with the APPENDMENUITEM command. It does not check menu commands of built-in menu items such as File/Load or others.

APPENDMENU

Appends a new menu.

Syntax

Description

The APPENDMENU command appends a new menu to the menu bar of Logo. This menu may be filled with menu items with by using the APPENDMENUITEM command. The ID is needed so you can reference the menu by ID.

The ID of the new menu item must be unique; if it is not, Logo throws an error.

Example

A new menu “Other” appears on the menu bar

APPENDMENU “|Other| “MY.OTHER

APPENDMENUITEM

Appends a new menu item.

Syntax

Description

The APPENDMENUITEM command appends a new menu item to an existing menu which may then be selected by the user. Each menu as well as a menu item has its own ID. Whenever a menu item is selected, this ID is transmitted to Logo, and Logo executes the runlist associated to the ID number. If the menu item name begins with a dash (-) character, a separator line is added to the menu and the ID number is ignored.

Use the WHEN command to define a list of Logo commands which should be executed whenever a menu command ID is selected.

You can also append a menu item to the main menu bar when you use the ID “ (the empty word).

The ID of the new menu item must be unique; if it is not, Logo throws an error.

Example

A new menu Item “Choose me” appears on the “File” menu

APPENDMENUITEM “FILE “|Choose Me| 100

COMMAND

Invoke a menu command by its ID.

Syntax

Description

COMMAND executes the menu item associated with its input. The value associated with the particular menu item is transferred into Logo, and Logo performs that command associated with the menu item.

Use this command to simulate menu selections or to run Logo commands if a WHEN command monitors thagt menu item ID. Use the FINDMENUID command to find a menu item ID.

Please note that some of the build-it commands do not work in the Web version because of browser security restrictions.

Example

The File Open dialog pops up.

COMMAND “OPEN

DELETEMENU

Deletes a menu.

Syntax

Description

The DELETEMENU command deletes a menu from the menu bar. The menu cannot be restored. If you, for example, delete the “File” menu, it will be gone. You need to exit and restart Logo to have access to the File menu again.

Logo still understands the menu command IDs, however, so you can remove the File menu and still execute all the commands associated with the File menu. Use FINDMENUID to retrieve the command ID for a menu item, and COMMAND to invoke a menu command.

DELETEMENUITEM

Deletes a menu item.

Syntax

Description

Use the DELETEMENUITEM command to delete a single item from a menu. The item will be gone; to access it, you will have to redefine it with the APPENDMENUITEM command or exit and restart Logo. The input to DELETEMENUITEM is the command ID of the menu item which you can find with the FINDMENUID command.

Logo still understands command IDs of deleted menu items, however, so you can remove the a menu item and still execute the command associated with that item. Use FINDMENUID to retrieve the command number for a menu item, and COMMAND to invoke a menu command.

FINDMENUID

Finds the ID of a menu item.

Syntax

Description

The FINDMENUID command searches Logo for the given menu item label. If it finds the menu item, it returns the command ID for that particular menu item. This number may be used to invoke a Logo menu command from within a procedure.

If it cannot find the menu item, FINDMENUID outputs the value 0.

Example

FINDMENUID “|Apps| Result: LOGO.APPS