Page 1 of 1
the num of controls <> the num of last control
Posted: Wed Oct 22, 2014 2:02 pm
by jmburnod
Hi All,
I discover the num of controls <> the num of last control.
I presume the num of last control doesn't count the controls in groups.
I'm right ?
Best regards
Re: the num of controls <> the num of last control
Posted: Wed Oct 22, 2014 3:22 pm
by Klaus
No, "controls" will also list objects in groups!
Just made a little test here, created some objects and grouped some other objects.
Then I added this script to a button:
Code: Select all
on mouseUp
put the num of controls into tNum
repeat with i = 1 to tNum
put i & TAB & the name of control i & CR after neu
end repeat
put neu
end mouseUp
And got this in the message box, which is correct:
1 button "tb1"
2 button "tb2"
3 field "Field1"
4 group id 1016
5 field "Field"
6 button "Button"
7 scrollbar "Progress Scrollbar"
Controls 5 to 7 are part of grp 4.
However:
put the num of last control -> give me 1 (one!)?
But:
put the layer of last control -> gives me 7, which is correct.
Make you own conclusions!
Best
Klaus
Re: the num of controls <> the num of last control
Posted: Wed Oct 22, 2014 11:14 pm
by jmburnod
Hi Klaus,
OK. I understand better except:
put the num of last control -> give me 1 (one!)?
I remain reserved about conclusions

but I noted that the layer is a trick
Thanks again
Jean-Marc
Re: the num of controls <> the num of last control
Posted: Thu Oct 23, 2014 12:31 am
by [-hh]
Hi,
as far as I understand, the "layer" is in back to front order (highest is "top"). That's close to clear, sometimes it is clearer for me to use the synonym "partNumber" instead of "layer".
The "number of" is more 'difficult' for me, has sometimes inconsistencies.
Presumably "the num of last control" is always one (if there are controls) or zero (if there are no controls), because "the last control" is one object or zero objects.
In your example, the num of control 2 will also be 1 (because it is one control).
The syntax control 2 to 5 is not accepted, if so, their num would be 4.
In the context of controls:
I would need a tutorial about the numbering of images within the larger set of controls (I learned: images are also controls *IF* they are on the same card).
Is here the syntax, I occasionally use to be safe, "image 2 of this cd" or "the num of images of this cd" an *obligatory* one?
Re: the num of controls <> the num of last control
Posted: Thu Oct 23, 2014 3:40 am
by dunbarx
Layers and numbers are interconnected. The best way to see how they work is to place four controls all overlapping each other but with each having a portion of itself visible at all times. It is best if there are, say, two buttons and two fields, because then the numbers can be seen to track the types of controls, even as the layers change, and also change the numbers in turn.
Name the controls "b1,b2,f1 and f2" (buttons and fields get b's and f's)
put this in the card script:
Code: Select all
on mouseUp
set the layer of btn "b1" to random(4)
repeat with y = 1 to the number of controls
put the name of control y && "(#" & the number of control y && ", Layer" && the layer of control y & ")" into line y of temp
end repeat
put return & return & "Last =" && the name of last control && "(, #" & the number of last control && ", Layer" && the layer of last control & ")" after temp
put temp
end mouseUp
The numbers of the controls track their layers, but the types of controls keep their own little worlds.
Craig
Re: the num of controls <> the num of last control
Posted: Thu Oct 23, 2014 7:58 am
by SparkOut
There is a distinction here between num as a reference to the control (based on its layer) and num as a count, surely?
The num of the last control will be one because there is only one of it. You're asking for the count, not the "number assigned as its order in the collection of controls". (Which, because it is a collection of one, is one anyway.)
Am I missing the point?
Re: the num of controls <> the num of last control
Posted: Thu Oct 23, 2014 10:51 am
by [-hh]
SparkOut, we are wrong with the interpretation as "the count" of a set. Look into the dictionary entry of the property 'number': "The number of a control is a control's layer on card".
But the dictionary is also wrong here because an important thing is NOT mentioned:
The number of a control is always the partNumber(Layer) *within its object type*.
So in Jean-Marc's first example
= the num of last control is one because there is only one scrollbar.
= If he deletes the scrollbar then the num of last control is three, because there are three buttons.
= If he deletes the last button then the num of last control is two because there are two fields.
So in this context, if last control is for example a button:
the num of last control = the layer(partNumber) of last button
= the number (as count) of buttons
whereas the number of controls = the layer of the last control (over *all* controls).
This is hard for a beginner ...
Re: the num of controls <> the num of last control
Posted: Thu Oct 23, 2014 3:02 pm
by dunbarx
Right, Hermann.
It is what I meant, though probably I said it badly:
The numbers of the controls track their layers, but the types of controls keep their own little worlds.
Only practicing with a set of controls will make this clear. The distinction between layers and numbers is consistent, and can be used to advantage. But you are correct in saying it takes a little work to master.
Craig
Re: the num of controls <> the num of last control
Posted: Thu Oct 23, 2014 3:17 pm
by jmburnod
Thank at all,
And sorry for the hard point for beginners
That is now clear for me.
Jean-Marc
Re: the num of controls <> the num of last control
Posted: Thu Oct 23, 2014 5:56 pm
by [-hh]
Bonjour Jean-Marc,
what a thread you opened here, in the beginners subforum:
The 'posters' made in sum over 11000 posts. I am the only real beginner here. Presumably one has to reach a certain number of posts to be able to see and have ready to hand the little worlds of Craig ...
Hermann