Array problem

Ken Ray kray at sonsothunder.com
Sun Jul 7 13:24:01 EDT 2002


Yves,

I assumed that the cPoints array was already filled with data inside the
same handler before it entered my code. If you have an array like:

cPoints["Ken"] = 5
cPoints["Yves"] = 7

and then go into the code, "e" will contain 7 or 5 depending on which loop
it goes through. The keys(cPoints) will return:

Ken
Yves

So you see, when you run it through my code:

put "" into myList
put 1 into elementNum
repeat for each element e in cPoints
  if e >= 5 then
    put line elementNum of keys(cPoints) & cr after myList
  end if
  add 1 to elementNum
end repeat

The first time through the loop, "e" will be 5, and will put line 1 of
keys(cPoints) ("Ken") & cr after myList.
The second time through the loop, "e" will b 7, and will put line 2 of
keys(cPoints) ("Yves") & cr after myList.

Also, I don't know how "the customProperties" will work; I think you meant
"customKeys". The problem is that the customKeys brings back the name of the
keys themselves given an object descriptor; that is, in my example, it would
return "Ken" and "Yves" in a return-delimited list. If you then try to get
the keys of "Ken" or "Yves", you should get nothing coming back.

I hope I'm being clear. My code above only retrieves the names ("Ken",
"Yves") and not their scores to do that, amend it as follows:

put "" into myList
put 1 into elementNum
repeat for each element e in cPoints
  if e >= 5 then
    put line elementNum of keys(cPoints) & "," & e & cr after myList
  end if
  add 1 to elementNum
end repeat

Hope this helps,

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



----- Original Message -----
From: "Yves Coppé" <yvescoppe at skynet.be>
To: <use-revolution at lists.runrev.com>
Sent: Sunday, July 07, 2002 10:04 AM
Subject: Re: Array problem


> >Yves,
> >
> >As long as cPoints only has student data (i.e. every element in cPoints
is
> >what you'll be checking), you can do this:
> >
> >put "" into myList
> >put 1 into elementNum
> >repeat for each element e in cPoints
> >   if e >= 5 then
> >     put line elementNum of keys(cPoints) & cr after myList
> >   end if
> >   add 1 to elementNum
> >end repeat
> >
> >Hope this helps,
>
>
> I find something :
>
> if I begin the code with
>
> put the short name of this stack into MYstackName
> put the customProperties["cPoints"] of stack MYstackName into myTxt
> put "" into myList
> put 1 into elementNum
> repeat for each element e in myTxt
> ...
> ...
> ...
>
> then I get the list...BUT
> it is ONLY the list of the students who have " 5 but not the points they
have
>
> I'd like something like
>
> sudentname,points
>
> Then I add the line
>
> put comma&the cPoints[line elementNum of keys(myTxt)] after myList
>
> Is it correct to do so ?
>
> thanks.
> --
> Greetings.
>
> Yves COPPE
>
> Email : yvescoppe at skynet.be
> _______________________________________________
> 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