Hi,
I'm currently working on a script that parses out function keys in a string of text. I've got this code which works, but was just looking for ideas on how to improve it :)
I would have liked to use regex, but I would need to do variable substitution for the command key text which I don't think is possible. By regex variable substitution I mean something like :
/\s(substitute cmdKeys[aa] here??)\-/
^^ the "\-" at the end is for the "-" character. Not sure if thats corrent though.
An example of the format of the string that i would be parsing is
"F3-Menu F8-Projection F12-Backup F21-Functions"
var str = FIELDS("footer").getValue();
var footer_len = str.length;
var ii = 0;
var cmdKeys = new Array("F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12","F13","F14","F15","F16","F17","F18","F19","F20","F21","F22","F23","F24");
var label = '';
var cmdKeys_len = cmdKeys.length;
for( var aa = 0; aa < cmdKeys_len; aa = aa + 1){
var found = 0;
var key = cmdKeys[aa];
var index = str.search(key);
if( (index >= 0) && (str.charAt(index + key.length) == '-') )
found = 1;
if( found ){
var ch = '';
var jj = index;
while( ' ' != ch ){
ch = str.charAt(jj);
label = label + ch;
jj = jj + 1;
}
//get a reference to the button and make it visible
var F = FIELDS(cmdKeys[aa]);
F.setProperty("visible", true);
F.refresh();
}
}
Thanks!