rename field on insertion
Klaus Major
klaus at major-k.de
Mon Jul 12 13:40:05 EDT 2004
Hi Bob,
> Hi All.
>
> I have a Textfield (TxA1) on a card in one stack (a template stack)
> and I have a button on this card that inserts it into a card in
> another stack "working stack". If I click on the button again it
> inserts a Textfield again. OK it is supposed to do this.
>
> However, "both" the textfields are called TxA1. I want to name the
> first field TxA1, but I want the second textfield to be called TxA2
> and if there was a third click then the third field to be TxA3.
>
> So the button click on stack template would have to read textfields in
> the working stack and if they exist, determine the largest number
> after TxA in the name and insert a textfield with TxA? +1
>
> Any ideas on how this can be done?
Hmmm, quick and dirty guess ;-)
Use a customproperty "curnum" = "current number" in your button and
"initialize" it
on openstack or opencard or whenever to 1 AND keep the original name of
your template field:
(If you are not used to customproperties: a global var will do, too :-)
...
set the curnum of btn "xyz" to 1
...
Now script this in this namely button:
on mouseup
put the curnum of me into freddy
set the short name of fld "template field" to ("TxA" & freddy)
copy fld ("TxA" & freddy) to stack ...
set the the short name of fld (TxA" & freddy) to "template field"
## Give it the original name, so we dont have to keep book of the
new names
## of the field, too ;-)
set the curnum of me to (freddy + 1)
## Raise counter, ready for the next field...
end mouseup
Not tested, but should work!
(Famous last words ;-)
> Beyond me.
>
> Cheers
> Bob
Hope that helps...
Regards
Klaus Major
klaus at major-k.de
http://www.major-k.de
More information about the use-livecode
mailing list