GET_MENU_OPTION_NUMBER Function

RAMP-NL

GET_MENU_OPTION_NUMBER Function


Searches the label fields on the current form looking for a menu option by name. If the menu option can be found an attempt is made to deduce an associated menu option number.    

This function is useful in applications where the menu option number associated with an activity varies because it allows a text string that identifies the menu option in words to be dynamically converted to the associated menu option number.

This function uses a cache keyed by screen name/search text to optimize repeatedly performing the same operation.

The cache logic assumes that a menu option number on any given 5250 screen will not change within a signed-on session.

Syntax

GET_MENU_OPTION_NUMBER(sSearchText, bCaseInsensitive, bTryPrecdeingField)

 

Parameters

sSearchText 

String. Required. The menu option search string. 

bCaseInsensitive

Boolean (true/false). Optional. Default is true. Indicates that the search should be case insensitive.

vTryPreceding

Boolean (true/false). Optional. Default is true. Indicates that when a label contains the search text, but a menu number cannot be deduced from it, that the preceding label field should be used as an alternate source for the menu number. This option accommodates menus where the menu option number and the menu text are in separate but adjacent label fields.   

Return Value

String. The associated menu option number or an empty string if no menu option could be deduced.

 

Example

This code causes the message "Menu option number returned was 2" to be displayed:

/* Locate the menu option number of Office Tasks on the I5/OS Main menu */

var strMenuNumber = GET_MENU_OPTION_NUMBER("office tasks");

alert("Menu option number returned was " + strMenuNumber);

 

This code causes the message "Menu option number returned was 11" to be displayed:

/* Locate the menu option number of Client Access/400 tasks on the I5/OS Main menu */

var strMenuNumber = GET_MENU_OPTION_NUMBER("client acc");

alert("Menu option number returned was " + strMenuNumber);