
I’m attempting to write some coding for labelling Function keys (F1-F20); naturally enough, the functions of the Function keys change, so the labelling needs to as well. Presently I have 20 “field” controls designated “F1lbl” to “F20lbl”. The intention is that each time I call up a new card, I post the text for the fields into a one-dimensional array called gLabelName; ‘X’ indicates that a Function key is unassigned.
The second part of the code sets up a loop (1-20) [myCount] and examines the contents of gLabelName. I’m using the concatenation function to create each of the field names in sequence, e.g. F5lbl. If the entry is “X”, the code should hide the field altogether, otherwise the code should set the text property of the field F[myCount]lbl to the corresponding string in the array, e.g. gLabelName[myCount]. In case it’s of relevance, the field controls are part of a control group associated with the stack.
I wonder whether part of the problem maybe to do with the fact that the field name (e.g. F5lbl, held in myInstance) isn’t enclosed in double quotes “ ” , but I can’t see anyway of concatenating a string with quotes. Current code is as follows:
global gLabelName
On preOpen Card
-- set up label array
put "Front TI,Fwd Left,Rear Left,X,X,Dismounted Exit,Fwd Right,Rear Right,Rear TI,X,All IR Off,X,Up,Alerts,X,Happy Days,X,Ack,Labels,X" into gLabelName
split gLabelName by comma
-- display labels/hide unused fields
repeat with myCount = 1 to 20
put "F" & myCount & "lbl" into myInstance
if gLabelName[myCount] is "X" then
set the visible of field myInstance to false
else set text of field myInstance to gLabelName[myCount]
set the visible of field myInstance to true
end repeat
End preOpenCard