Array

David Vaughan drvaughan55 at mac.com
Sun May 5 17:56:01 EDT 2002


On Monday, May 6, 2002, at 06:51 , Ken Ray wrote:

> Yves,
>
> I was assuming that you were having an equal number based on the 
> example you
> submitted.
>
> If there are going to be unequal divisions, I would recommend storing 
> your
> index value in another custom property (like 'cName[index]') and then
> increment that with each "record". So instead of this:
>
>   put the number of lines of keys(cName) into numKeys
>   put (numKeys/2)+1 into nextIndexNum
>   set the cName[student,nextIndexNum] of <object> to "Peter"
>
> You'd do this:
>
>   put the cName[index] of <object> +1 into nextIndexNum
>   set the sName[student,nextIndexNum] of <object> to "Peter"
>   set the cName[index] of <object> to nextIndexNum

Yves

I do not know enough about your application to be sure this will work 
for you but have you considered reversing the index and content? 
Provided the names were unique, you could enter
set the cname["Peter"] of <object> to "student"
That is, you address by name rather than by Prof/student with the 
content being their title.

This way you do not need to know which is the next index for an entry 
but you are still able to recover the title for any student or in a loop 
the list or count of Professors or students.

I thought this was one of the features of content-addressable arrays.

regards
David
>
> Just my $0.02,
>
> Ken Ray
> Sons of Thunder Software
> Email: kray at sonsothunder.com
> Web Site: http://www.sonsothunder.com/
>
>
> ----- Original Message -----
> From: "yves COPPE" <yvescoppe at skynet.be>
> To: <use-revolution at lists.runrev.com>
> Sent: Sunday, May 05, 2002 11:34 AM
> Subject: Re: Array
>
>
>>> Yves,
>>>
>>> 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"
>>>
>>
>>
>> This assumes the number of entries in student and prof are equal
>> If I have 4 entries for student and 1 for prof and I don't know how
>> much entries because this is variable ?
>> How to proceed ?
>> --
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list