Hard code or portable code

Dar Scott dsc at swcp.com
Wed Mar 3 02:03:55 EST 2004


On Tuesday, March 2, 2004, at 08:21 PM, hershrev wrote:

> is there a way to imitate hard code with some kind of container ?

Here are a couple of ideas:

1.  Use a list of names--

Create a list in a manner much like this:

repeat with x = 1 to the number of fields
    put (the name of field x) & LF after myVar
end repeat

Use it much like this (say to sum):

put 0 into fieldSum
repeat for each line f in myVar
   add field f to fieldSum
end repeat

OR

2.  Add a numerical subscript to fields of a particular type--

Say some fields are named "count 1", "count 2" and so on.

Create the count like this:

put 0 into numberOfCountFields
repeat with x = 1 to the number of fields
   if the name of field x starts with "count " then
     add 1 to numberOfCountFields
   end if
end repeat

(Or you can just type it into a custom property and use that, if the 
number is fixed.)

Use it like this:

put 0 into fieldSum
repeat with x = 1 to numberOfCountFields
   add field ("count" & x) to fieldSum
end repeat

3.
Or some other variation or combination...

Dar Scott







More information about the use-livecode mailing list