3.0 Field numbering messed up

Jim Ault JimAultWins at yahoo.com
Tue Oct 7 21:17:55 EDT 2008


On 10/7/08 5:16 PM, "Joe Lewis Wilkins" <pepetoo at cox.net> wrote:

> Attention:
> 
> I'm doing some math on a form. Carefully, I thought, I numbered the
> various flds so that I could refer to them in sequence or, at least,
> know what their names are by their positions without having to
> constantly check them out. However, when it came time to refer to them
> I was a bit mistaken. It seems that a field fld "1" does not return
> the value that is in that field; it returns the value that is in a
> totally different field, but the one that is "1" by layering. It was
> the first field I created. It does the same with fld "2"; refers to
> the second field I created and one that is "2" by layering; not by
> name. To me this is a bug. Correct?
> 
> I can diddle around and make this work, but I shouldn't have to. When
> I refer to an object by its name I should get the contents of that
> object.
> 
Referring to objects using numbers as labels is a risky practice since Rev
will resolve numbers to mean the position in the order of fields, buttons,
other objects.
 (1 to the number of fields, regardless of layer number, but in the layer
'order').
--------- Reset the names of all the fields
on setNameOfFields
  repeat with x = 1 to the number of fields
    put word 1 of the short name of field x into NM
    if NM is a number then  --  only touches number-style fields
       set the name of field x to NM & " F"
    end if
  end repeat
end setNameOfFields

-------- now you can reset the layering according to your naming system
on setLayerNumOfFields
  repeat with x = 1 to the number of fields
    put word 1 of the short name of field x into NM
    if NM is a number then  --  only touches number-style fields
      put field ( NM & " F") into item 1 of newLine
      put the short name of field ( NM & " F")  into item 2 of newLine
      put the layer of field ( NM & " F")  into item 3 of newLine
      set the layer of field ( NM & " F") to nm
      put the layer of field ( NM & " F")  into item 4 of newLine
      put cr & newLine after output
    end if
  end repeat
  put the seconds into line 1 of output
  put output  ----  this lets you see a list of the results of relayering
end setLayerNumOfFields

I believe this was the same rule as in Hypercard.

Hope this helps

Jim Ault
Las Vegas





More information about the use-livecode mailing list