how to adress the object name and not the number?

Jim Ault JimAultWins at yahoo.com
Thu Apr 19 22:37:22 EDT 2007


Using a space char is a personal programming choice, and certainly not a bad
one.  My preference is to use a "0" as a pad character, especially for date
strings, object names, file names, and folder names.

Thus I use the less convenient form of

  put columnName & ( char -2 to -1 of ("0"& i) ) into thisCell

by not using spaces in field names, you do not have to use quotes, such as

put 451 into fld cellValue01  vs fld "cellValue 1"
put 23 into fld cellValue02    vs fld "cellValue 2"
put 254 into fld cellValue99   vs fld "cellValue 99"

again, personal preference.

---------- start copy here
put the short date into temp
convert temp to dateitems
get (char -2 to -1 of item 1 of temp)
get it & (char -2 to -1 of ("0"&item 2 of temp))
get it & (char -2 to -1 of ("0"&item 3 of temp))
put it into msg  
------------ stop copy here
Paste these lines into the multiline message box and hit the enterkey.
--> 070419
caution:  the msgbox does not like
put fld dataToWrite01 into url ("file:"& it &"invoices.txt")
--> defaultFoler/070419invoices.txt

I also have the habit of double-clicking to hilight the field name to copy
and paste, therefore spaces would be less desirable for me.

One of the good things about Rev is that you can develop more of a coding
style that makes sense to you and just go for it.


Jim Ault
Las Vegas

On 4/19/07 5:13 PM, "Bill Marriott" <wjm at wjm.org> wrote:

> 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.
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list