change label name

Ken Ray kray at sonsothunder.com
Sat Feb 19 10:39:16 CST 2005


On 2/19/05 3:38 AM, "Bob Hartley" <rev at armbase.com> wrote:

Bob,

Glad you got it to work... but I'd suggest a couple of minor
changes/optimizations to your final code.

> on mouseUp
>    global tFileName
>    copy field "LabelName" of stack "Armbase" to card 1 of stack tFileName
>    set the text of field LabelName of stack tFileName to field LabelNewName
> of stack "Armbase"
>    set the name of field LabelName of stack tFileName to field LabelNewName
> of stack "Armbase"
> end mouseUp

When you copy an object (or create a new one using "create"), the long id of
the new object is put into "it" so you don't need to refer to the name with
long identifiers. So the code could also be:

on mouseUp
  global tFileName  -- BTW, why do you need to global this?
  put field "LabelNewName" of stack "Armbase" into tText
  copy field "LabelName" of stack "Armbase" to card 1 of stack tFileName
  set the text of it to tText
  set the name of it to tText
end mouseUp

Also, you should always (IMHO) put quotes around the names of objects. Rev
is very forgiving, but it makes it easier to read and reduces potential
problems if object names are quoted.

Just FYI,


Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com
  




More information about the use-livecode mailing list