When a particular session is opened, add a menu with custom functionality to assist or extend the functionality of the host application. The functionality of the custom menu items can be anything supported by or called from the script. Menu modification is just one of several ways the GUI may be customized, see the bottom of this example for suggested extensions.
A menu block is written in the script to redefine the DynaComm session menu, including a custom menu and any default ones that should still be available. Definition of the custom menu also includes each menu item and what they do when selected. For example, the custom menu could add an item to search the screen(s) for a user-entered part number, grab data from screen regions and store to a local file, or retrieve and pass data to an Excel spreadsheet to be graphed immediately. In this example, the custom menu items call script subroutines to provide these functions, but the implementation of the routines themselves is left for future development.
Relevant Commands and Functions:
MENU — Beginning of Menu block which defines menu
MENU END — Ends Menu block which defines menu
MENU CANCEL — Cancels script-defined menu, restores default menu bar
(MENU) POPUP — Adds a new menu to the menu bar
(MENU) ITEM — Adds a menu item to a popup menu
(MENU) SEPARATOR — Adds a menu item separator to a popup menu
SHOW — Display each script command as it is executed.
MENU UPDATE — Updates previously defined menu or menu option
(MENU) INSERT POPUP, (MENU) DELETE POPUP — Inserts/Removes menu from menu bar
(MENU) INSERT ITEM, (MENU) DELETE ITEM — Inserts/Removes a menu item from a popup menu
TITLE — Assign a title to be displayed in DynaComm title bar
SET WINDOWTITLE — Displays title in active child window title bar
SET POINTER — Changes the shape of the mouse pointer
SET SOUND — Controls whether warning bells from host are enabled
SET CURSOR — Changes display of cursor
WINDOW ARRANGE — Tiles open child windows
WINDOW HIDE — Hides window
WINDOW MAXIMIZE — Maximizes specified window
WINDOW MINIMIZE — Minimizes specified window
WINDOW MOVE — Moves and resizes specified window
WINDOW RESTORE — Restores application window to previous state
WINDOW STACK — Stacks open windows in cascade fashion
WINDOW UNHIDE — Displays application window and child windows
A Brief Example
POPUP "&File" SYSTEM 1
ITEM "&Query" PERFORM QueryRoutine
ITEM "Screen &Capture" PERFORM ScreenCapture
ITEM "&Plot Data" PERFORM PlotData
POPUP "&Help" SYSTEM 8
DISPLAY "QueryRoutine executed...menu changes cancelled"
DISPLAY "ScreenCapture executed...menu changes cancelled"
DISPLAY "PlotData executed...menu changes cancelled"
For DCSeries, the menu bar is different for session windows, script windows, memo windows, and the main application window. In this example, we want to modify the session menu bar. Thus, this script should be run when a session window is active. An easy way to do this is to have this script listed as the Startup Script in Session:Properties, General tab.
In this example, the menus are defined as the default menu bar for Session windows, with the omission of the Script menu and with the addition of a Custom menu between Tools and Window. Each of the three routines called by the Custom menu items displays an indication that the routine was performed, cancels the Menu modifications, and causes the script to cancel. Cancelling the script also cancels the menu modifications.
- When the session using the custom menu is closed, the script can remove the custom menu which is no longer necessary.
- The title of the session window, and/or the main application can be modified via Script commands.
- The mouse pointer icon can be changed to an hourglass while waiting for the host to respond, or to indicate the script is processing. The keyboard can also be locked within DynaComm to prevent user input.
- The cursor appearance can be toggled between available shapes.
- The session window can be maximized, minimized, stacked, cascaded, dynamically sized, hidden, shown or moved via Script. For example, some host applications may be optimized for a particular session window size. This may also be useful for applications involving multiple coordinated sessions. For example, entering a host monitor application may spawn a secondary session for more detailed output, initially sized smaller and placed below the primary session.