Terrapin Resources

Terrapin Logo 4 has been discontinued! Our new Terrapin Logo version is much more powerful and modern; we strongly recommend that you update to our latest release of the Logo programming language.

Menu Commands

This section explains the command that you can use to modify the menu of Terrapin Logo. Note that these commands will not be available in future versions of Terrapin Logo.

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.

Example

A new menu “Other” appears on the menu bar

APPENDMENU “|Other|

APPENDMENUCOMMAND

Appends a new menu item.

Syntax

Description

The APPENDMENUCOMMAND command appends a new menu item to an existing menu which may then be selected by the user. Its first input is the name of the menu where the item is to be appended to, and the second input is the name of the item to be appended. Both inputs are case sensitive. The third input is a list of Logo commands that are executed when the menu item is selected. If the menu item name begins with a dash (-) character, a separator line is added to the menu and the command list is ignored. The output is the command number that Logo assigns to the new menu item.

Example

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

APPENDMENUCOMMAND “File “|Choose Me| [PRINT “Chosen!]

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 item has its own ID number. Whenever a menu item is selected, this ID is transmitted to Logo, and Logo performs the command 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 ONCOMMAND command to define a list of Logo commands which should be executed whenever a menu command ID is selected.

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 number.

Syntax

COMMAND number

Description

COMMAND executes the menu item associated with its input. The number 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 activate Logo procedures stored with the ONCOMMAND command. Use the FINDMENUID command to find a menu item number.

Example

A new window pops up

COMMAND 32766

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 numbers, 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 number 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 number of the menu item which you can find with the FINDMENUID command.

Logo still understands command numbers 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 and menu item name. If it finds the menu item, it returns the command number for that particular menu item. This number may be used to invoke a Logo menu command from within a procedure.

Example

FINDMENUID “FILE “QUIT Result: 32759

ONCOMMAND

Defines the commands that execute when a menu item is selected.

Syntax

Description

ONCOMMAND defines a Logo run list that is executed whenever a menu command with the given ID number has been selected. Use the APPENDMENU and APPENDMENUITEM commands to define new menus and menu items; the, Logo procedures and run lists may be appended to those menu items with the help of this command.

ONCOMMAND can also be used to redefine the meaning of built-in Logo menu items. Use the ONCOMMAND command with the empty list as run list to remove any Logo commands defined with ONCOMMAND.

The FINDMENUID command may be used to find out the ID number of existing menu items.

Example

The following command causes Logo to print “No new windows!” when the user selects the File⇒New Graphics Window menu command

ONCOMMAND 32766 [PRINT “|No new Windows!|]