how to adress the object name and not the number?
Eric Chatonet
eric.chatonet at sosmartsoftware.com
Fri Apr 20 03:40:17 EDT 2007
Hi Bill,
As Jim said: using a space char is a personal programming choice, and
certainly not a bad one ;-)
As for me, I prefer to name any object with a single word
("LastBackupDate5" for instance) and *always* quoted even if XTalks
don't make it compulsory in this case.
And to retrieve the right suffix, instead of using last word, I just
use char x to -1:
char 5 to -1 of "Last1" = 1
char 5 to -1 of "Last1000" = 1000
No problem with the number of chars of the suffix ;-)
Le 20 avr. 07 à 02:13, Bill Marriott a écrit :
> The recommendation to name objects starting with a letter and then
> a number is simply a "must" because as others have pointed out
> there can be ambiguity when referencing objects named with simply a
> number. Two additions to the excellent ideas:
>
> 1) Remember that the object number always refers to its layer.
> Lower-numbers are below higher-numbered ones.
>
> 2) I have found it very helpful to insert a space before the prefix
> and the number when naming objects sequentially -- e.g.: "Cell 1"
> rather than "Cell1" -- because then it's a lot easier to find out
> what number you've given that object using Rev's "word" chunk later
> on.
>
> For example, suppose you've created an array of fields this way:
>
> put "Qty,Part Number,Description,Unit Price,Extended Price" into
> theHeaders
> repeat for each item columnName in theHeaders
> repeat with i = 1 to 20
> put columnName && i into thisCell -- the && concatenates with
> a space between
> create fld thisCell
> set the rect of fld thisCell to \
> startLefts[columnName],rowHeight * (i-1),startLefts
> [columnName]+colWidths[columnName],rowHeight * i
> set the lockText of fld thisCell to true
> end repeat
> end repeat
>
> (Leaving out setup of the arrays) Then, when someone clicks on one
> of the cells, you can hilight the entire row very simply with this
> script in the group:
>
> on mouseup
> put the last word of the short name of the target into theLine
> repeat for each item columnName in theHeaders
> put columnName && theLine into thisCell
> set the backgroundColor of fld thisCell to yellow
> end repeat
> end mouseup
>
> or, less verbosely,
>
> on mouseup
> repeat for each item c in theHeaders
> set fillBack of fld (c && last word of short name of target) to
> yellow
> end repeat
> end mouseup
>
> By using "the last word" you've gotten the number of the
> corresponding elements painlessly.
Best regards from Paris,
Eric Chatonet.
----------------------------------------------------------------
http://www.sosmartsoftware.com/
eric.chatonet at sosmartsoftware.com/
----------------------------------------------------------------
More information about the use-livecode
mailing list