Page 1 of 1
set traversal on 10 fields at once?
Posted: Sat Dec 27, 2014 6:14 pm
by jalz
Hi Guys,
I've got a number of fields that I've set as readonly. I've figured out the code to make them 'focusable' so a user can change the data on my data entry screen. the issue is I have about 10 fields and instead of copying and pasting the set the traversalOn true for each field, is there a shorthand way I can provide a delimited list of fields I want the traversalOn to be and wrap it in a much shorted command?
Thanks as always
Jalz
Re: set traversal on 10 fields at once?
Posted: Sat Dec 27, 2014 7:47 pm
by Dixie
If it was to be for consecutively numbered fields then this might do..
Code: Select all
on mouseUp
repeat with count = 1 to 10
set the traversalOn of fld count to true
end repeat
end mouseUp
If it was to set the traversalOn for different numbered or named fields then this might work for you
Code: Select all
on mouseUp
put 1,3,5,7,9 into theList
repeat with count = 1 to the number of items of theList
set the traversalOn of fld (item count of theList) to true
end repeat
end mouseUp
Re: set traversal on 10 fields at once?
Posted: Sat Dec 27, 2014 8:20 pm
by dunbarx
Hi.
If the fields of interest are not ordered numerically, for whatever reason, I like to assign an identifier that sets them apart. Something like naming them "L1", "L2", "L3", etc. Now it does not matter how many fields you have, or how many of the ones of interest there are, or how they are ordered, or whether you add or subtract to the count of either the good ones or the bad ones:
So you can:
Code: Select all
on mouseUp
repeat with y = 1 to the number of flds
if char 1 of the short name of fld y = "L" then set the traversalOn of fld y to "true"
end repeat
end mouseUp
Craig
Re: set traversal on 10 fields at once?
Posted: Sun Dec 28, 2014 10:52 pm
by jalz
awesome, thanks guys
Re: set traversal on 10 fields at once?
Posted: Sun Dec 28, 2014 11:08 pm
by SparkOut
Another way (which is basically the same as Dixie's but directly uses the field name, which can be forced to resolve by enclosing in brackets):
Code: Select all
put "abc,def,ghi,jkl,mno,pqr,stu,vwx,yza" into tList -- list of field names here
repeat for each item tField in tList
set the traversalOn of field (tField) to true
end repeat
You can errortrap with a check "if there is a field (tField) then..." as well if need be