I can identify a field in a group by its order inside the group:
Code: Select all
put "this" into fld 3 of group "test" of group "main"
This
Code: Select all
put the number of fld ID myID of group "test" of group "main"
Thanks
Paul
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Code: Select all
put "this" into fld 3 of group "test" of group "main"
Code: Select all
put the number of fld ID myID of group "test" of group "main"
Code: Select all
on mouseUp
repeat with y = 1 to the number of flds
put y * 10 into fld ("f" & y)
end repeat
end mouseUp
Oh now come on here! If we could have stuck up a repeat loop, this could have been answered probably in my post!
...and just for the record, I completely agree with Jean-Marc and Craig, name the fields sensibly and use a loop, it really is the easiest fastest way to get there.paulclaude wrote: ↑Wed May 22, 2019 10:11 amhow can I get its order number (3 in my example) in that group (directly, without a repeat loop scripting)?
If it is a locked field, you can also look for the target or last target.number
Type: function
Syntax:
the number of [card|cd|background|bkgnd|bg] {objectType | parts | controls}
If that is what you got out of what I posted last, I completely failed in my explanation.paulclaude wrote: ↑Thu May 23, 2019 12:13 pmMy only doubt was whether a Livecode direct function existed (with the right parameters) to know this number: it does not exist, I take note of it.
Hi Bogs,maybe my explanation is misspelled (sorry for my elementary English).bogs wrote: ↑Thu May 23, 2019 1:02 pmIf that is what you got out of what I posted last, I completely failed in my explanation.paulclaude wrote: ↑Thu May 23, 2019 12:13 pmMy only doubt was whether a Livecode direct function existed (with the right parameters) to know this number: it does not exist, I take note of it.
Code: Select all
put the number of fld ID 6890 of group "B" of group "A"...
Code: Select all
put the layer of fld ID 6890 of group "B" of group "A"...
Code: Select all
on mouseup
repeat with y = 1 to the number of flds in grp "grp2"
if the id of fld y of grp "grp2" = targetID then answer y
end repeat
end mouseup
Yes, this is the loop "workaround" (that I've previously mentioned) that I actually use, Craig.dunbarx wrote: ↑Thu May 23, 2019 5:04 pmHi.
This?
If I have a group ("grp2") of fields that are within another group ("grp1") of fields, and I want the ID of the field in grp "grp2" that has the ID "targetID":I get the number of the field I want. LC does the heavy lifting, since it only looks in the group you specify. More directly, you can simply get the second field in that group.Code: Select all
on mouseup repeat with y = 1 to the number of flds in grp "grp2" if the id of fld y of grp "grp2" = targetID then answer y end repeat end mouseup
Am I missing it?
Craig