Stupid one - how do you rename a control?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Stupid one - how do you rename a control?
In the property inspector, there is a NAME category.
When I clone a block, I want to change the name - so rectDrum would be cloned and renamed to rectDrum2, etc.
How is this done. Is this a bad idea? Eventually, I am going to want to mix all the blocks of all the drags into a two track wave file. I am sure it is better to put everything into an array. Someone helped me out with that, I just have to understand how to apply it. Arrays are so different in Live Code. I just don't get them yet.
Mike
When I clone a block, I want to change the name - so rectDrum would be cloned and renamed to rectDrum2, etc.
How is this done. Is this a bad idea? Eventually, I am going to want to mix all the blocks of all the drags into a two track wave file. I am sure it is better to put everything into an array. Someone helped me out with that, I just have to understand how to apply it. Arrays are so different in Live Code. I just don't get them yet.
Mike
Re: Stupid one - how do you rename a control?
Take a look at the name property.
Re: Stupid one - how do you rename a control?
grrr. I know. I tried.
set name of rect "rectDrum" to rect "rectDrum2"
does not work.
What is the proper syntax?
Mike
set name of rect "rectDrum" to rect "rectDrum2"
does not work.
What is the proper syntax?
Mike
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: Stupid one - how do you rename a control?
You know, I was gonna send you back to the documentation again, but I just looked and the examples there aren't really that straightforward. The crux of the matter is that you have to set the name to a string. Giving an object reference isn't enough. So in your example you'd want
set name of rect "rectDrum" to "rectDrum2"
but given what you're trying to accomplish you will probably want to end up with something more like
or
or even
set name of rect "rectDrum" to "rectDrum2"
but given what you're trying to accomplish you will probably want to end up with something more like
Code: Select all
clone rect "rectDrum"
set the name of it to "rectDrum2"
Code: Select all
clone rect "rectDrum"
set the name of it to "rectDrum" & tDrumNumber
Code: Select all
put "rectDrum" into tRectangleToBeCloned
clone rect tRectangleToBeCloned
set the name of it to (the name of tRectangleToBeCloned) & tDrumNumber
Re: Stupid one - how do you rename a control?
I assume I have to global tDrumNumber
and then add one to it each time?
Thank you for your help. Yes, the examples in the dictionary and guide don't help.
Mike
and then add one to it each time?
Thank you for your help. Yes, the examples in the dictionary and guide don't help.
Mike
-
- VIP Livecode Opensource Backer
- Posts: 4016
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Stupid one - how do you rename a control?
Hi Mike,
did you try:
instead of
Kind regards
Bernd
did you try:
Code: Select all
set name of grc "rectDrum" to "rectDrum2"
rect is not an object, it is a property or a tool.set name of rect "rectDrum" to rect "rectDrum2"
Kind regards
Bernd
Re: Stupid one - how do you rename a control?
I get an error:
on mouseDown
add 1 to tDrumNumber
put "rectDrum" into tRectangleToBeCloned
clone rect tRectangleToBeCloned
set the name of it to (the name of tRectangleToBeCloned) & tDrumNumber
end mouseDown
in the line: put "rectDrum" into tRectangleToBeCloned
The name of the rectangle is "rectDrum"
What is wrong?
Mike
on mouseDown
add 1 to tDrumNumber
put "rectDrum" into tRectangleToBeCloned
clone rect tRectangleToBeCloned
set the name of it to (the name of tRectangleToBeCloned) & tDrumNumber
end mouseDown
in the line: put "rectDrum" into tRectangleToBeCloned
The name of the rectangle is "rectDrum"
What is wrong?
Mike
Re: Stupid one - how do you rename a control?
grc does not work and this code below does not work:
on mouseDown
add 1 to tDrumNumber
put "rectDrum" into tRectangleToBeCloned
clone tRectangleToBeCloned
set the name of it to (the name of tRectangleToBeCloned) & tDrumNumber
end mouseDown
How do I make it work - seems very logical to me. This Live Code syntax is so tough to get a hold of after programming other languages.
Mike
on mouseDown
add 1 to tDrumNumber
put "rectDrum" into tRectangleToBeCloned
clone tRectangleToBeCloned
set the name of it to (the name of tRectangleToBeCloned) & tDrumNumber
end mouseDown
How do I make it work - seems very logical to me. This Live Code syntax is so tough to get a hold of after programming other languages.
Mike
-
- VIP Livecode Opensource Backer
- Posts: 4016
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Stupid one - how do you rename a control?
Hi Mike,
could you try:
instead of
Bernd
could you try:
Code: Select all
clone graphic tRectangleToBeCloned
kind regardsclone rect tRectangleToBeCloned
Bernd
Re: Stupid one - how do you rename a control?
And the winner is . . .
on mouseDown
add 1 to tDrumNumber
put "rectDrum" into tRectangleToBeCloned
clone graphic tRectangleToBeCloned
--set the name of it to (the name of tRectangleToBeCloned) & tDrumNumber
set name of it to "rectDrum" & tDrumNumber
end mouseDown
That works.
Mike
on mouseDown
add 1 to tDrumNumber
put "rectDrum" into tRectangleToBeCloned
clone graphic tRectangleToBeCloned
--set the name of it to (the name of tRectangleToBeCloned) & tDrumNumber
set name of it to "rectDrum" & tDrumNumber
end mouseDown
That works.
Mike