SHARED.apply5250FunctionKeyPatterns
This example JavaScript function is designed to look for Fn=xxxxxx patterns on specified screen lines. Copy and paste the attached functions into your SHARED script object, file UF_SY420_RTS.JS.
// Apply Fn=xxxxxx function key patterns to buttons and function keys enabled on the current RAMP-TS screen
apply5250FunctionKeyPatterns : function(iLowRow,iHighRow,aForceEnable,aForceDisable)
{
if (GLOBAL_oAXESInterface == null) return; // No AXES interface
if (GLOBAL_oCurrentTSform == null) return; // No current AXES form
if (oGLOBAL_CurrentFORM == null) return; // No RAMP-TS definition for the form
TRACE("SHARED.applyFunctionKeyPatterns started");
if (iHighRow == null) iHighRow = iLowRow; // default is same as low row
var allkeys = "";
var typeOUTPUT = GLOBAL_oAXESInterface.Element.TYPE_OUTPUT;
var oForm = oGLOBAL_CurrentFORM;
// Disable all function keys and buttons to start with.
// Note that the function keys (oForm.vFKERTS) and the buttons (oForm.vFKEVLF) are BOTH disabled here
TRACE("SHARED.applyFunctionKeyPatterns is disabling all function keys and all buttons");
for (var i = 0; i < oForm.vFKEVLF.length; i++) { if (oForm.vFKEVLF.charAt(i) != "0") oForm.vFKEVLF = InsertString(oForm.vFKEVLF,"0",i); }
for (var i = 0; i < oForm.vFKERTS.length; i++) { if (oForm.vFKERTS.charAt(i) != "0") oForm.vFKERTS = InsertString(oForm.vFKERTS,"0",i); }
// Strip all output fields on the specified lines to create a long string of function keys strings
for (var iRow = iLowRow; iRow <= iHighRow; iRow++)
{
var aAElement = GLOBAL_oCurrentTSform.getElementsByRow(iRow);
for (var i = 0; i < aAElement.length; i++)
{
var oAXESElement = aAElement[i];
if (oAXESElement.type == typeOUTPUT) { allkeys += " " + oAXESElement.getValue(); }
}
}
// This RegExp looks for strings of the form F1=XXXX (where "F" can be F, PF, FP, CF
// or Cmd) XXXX can be a string of any length terminating at more than one space,
// the end of the line or another instance of "F1=" (thats the ?= look ahead group).
// All groups are forgotten (that's the ?:) except the function number and the XXXX text.
var reFKey = /\b(?:F|PF|FP|CF|Cmd)(\d+)[=-](.*?)(?=(?:\b(?:F|PF|FP|CF|Cmd)\d+[=-])|\s{2,}|$)/gi;
var fkeyMatch = reFKey.exec(allkeys);
while (fkeyMatch != null)
{
var key = "F" + TRIM_RIGHT(fkeyMatch[1]);
// Note that the function key and the button are both being enabled here
SETKEYENABLED(GLOBAL_oCurrentTSform.symbolicName,key,true,true);
fkeyMatch = reFKey.exec(allkeys);
}
// Enable any forced buttons. Note that the function key and the button are BOTH enabled
if (aForceEnable != null)
{
TRACE("SHARED.applyFunctionKeyPatterns is forcing the enablement of specified keys/buttons");
for (var i = 0; i < aForceEnable.length; i++) { SETKEYENABLED(GLOBAL_oCurrentTSform.symbolicName,aForceEnable[i],true,true); }
}
// Disable any forced buttons. Note that the function key and the button are BOTH disabled
if (aForceDisable != null)
{
TRACE("SHARED.applyFunctionKeyPatterns is forcing the disablement of specified keys/buttons");
for (var i = 0; i < aForceDisable.length; i++) { SETKEYENABLED(GLOBAL_oCurrentTSform.symbolicName,aForceDisable[i],false,false); }
}
// Finished
TRACE("SHARED.applyFunctionKeyPatterns ended");
}, // <--- Note the comma