Hi,
When the name of an object on a card is changed, could that name change be "automatically applied" to every instance where that object has been used in all scripts within all stacks of the currently open program?
It would appear that the "find and replace" option of the edit menu could do this, but not "automatically" at the time the name of an object is being changed. By linking the name change to be made to the specific object involved, there would be no need to "search" all text, labels, etc.
I'm not aware of any "down side" to this approach -- please let me know of some obvious reason to avoid doing this. ( or perhaps it could be made an "option" by the user )
Thanks for the consideration.
universally changing the name of an object
Moderator: Klaus
Hi Ken,
If you change the label of an object instead of its name, there is no need to change anything in the scripts.
There is the Find & Replace utility in the Edit menu. This should allow you to find all instances of a string in all scripts.
Of course, it is possible to write a script that changes all instances of the name of a particular object, but I don't think this is a good idea, especially for larger projects that use more than 1 stackfile.
Best,
Mark
If you change the label of an object instead of its name, there is no need to change anything in the scripts.
There is the Find & Replace utility in the Edit menu. This should allow you to find all instances of a string in all scripts.
Of course, it is possible to write a script that changes all instances of the name of a particular object, but I don't think this is a good idea, especially for larger projects that use more than 1 stackfile.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Livecode Opensource Backer
Re: universally changing the name of an object
The problem is that there is no reliable way to do this. Imagine the following scenario: Two objects can bear the same name. If you copy and paste an object, for instance, the copied object will have the same name as the original one. What would you expect to happen if the name of the second object, the copied one got changed?
What is unique to each object is it's id. You can gain the advantages you are after by referring, in your script to 'field id 1200' rather than 'field "myField"'. You are then free to change the object name as often as you want without impacting on your code.
Using ids of course doesn't make for easy to read code. This can be addressed by using the following each time you need the object
(use a meaningful name in place of myField, otherwise, this defeats the purpose)
What is unique to each object is it's id. You can gain the advantages you are after by referring, in your script to 'field id 1200' rather than 'field "myField"'. You are then free to change the object name as often as you want without impacting on your code.
Using ids of course doesn't make for easy to read code. This can be addressed by using the following each time you need the object
Code: Select all
put the short name of field id 1200 into myField
put the width of field myField (no quotes here, you refer to a variable)
....
put the name of field id 1200 into myField
put the width of myField (my Field includes both object type and object name)
....
put the long id of field id 1200 into myField
put the width of myField (my field holds a full reference to the object, that includes the object type)
Last edited by marielle on Sun Apr 29, 2007 10:53 pm, edited 1 time in total.