Array

Ken Ray kray at sonsothunder.com
Sun May 5 11:15:01 EDT 2002


ArrayYves,

To know how many lines are stored in the custom propery you can reference the keys() function and get a line count, as in 

  put the number of lines of keys(cName) into numKeys

Assuming you have two keys per "index" (one is "student" and one is "prof"), you would divide 'numKeys' by 2, and then add 1 for the next index number:

  put (numKeys/2)+1 into nextIndexNum

Then, set your array to the next element:

  set the cName[student,nextIndexNum] of <object> to "Peter"

Note that variables can be used inside the array definition (nextIndexNum), but if you mistype it, it will use the string as part of the array. For example:

  put 2 into Fred
  set the cName[student,Fred] of this stack to "Ken"

'Fred' will be recognized as a variable and will be resolved to '2', which will set the cName[student,2] of this stack. However, if I do this:

  put 2 into Fred
  set the cName[student,Fredd] of this stack to "Ken"  -- Mistyped 'Fred'

'Fredd' will not be recognized as a variable and will therefore not be resolved and will be used directly, setting the cName[student,Fredd] of this stack.

Hope this helps,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/


----- Original Message ----- 
  From: yves COPPE 
  To: use-revolution at lists.runrev.com 
  Sent: Sunday, May 05, 2002 10:04 AM
  Subject: Array


  Hello,


  A few weeks ago, I posted a message without answer. So I come again :





  I have a custom Property Set which contains an array.
  the name of thz set is "cName"
  the keys content :
  student,1
  prof,1
  Student,2
  prof,2


  each line gives a name :

  example :
  student,1  ===> John
  prof,1     ===> Tom

  I'd like to add some data on the existing custom set
  so I start with a new handler
  I have to call the custom property, know how much lines are stored in the custom and add one line
  for example :
  Peter = student,3

  How to proceed ?

  thanks.
-- 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.runrev.com/pipermail/use-livecode/attachments/20020505/2d7b1114/attachment.html>


More information about the use-livecode mailing list