Easy quick hypertalk coding question

Graham Samuel livfoss at mac.com
Mon Apr 14 17:39:41 EDT 2008


William

Is fld "index" just one field containing all the numbers you want to  
sort? If so, what is the item delimiter - is it comma or return or  
something else?

If it's comma, the function

max(fld "myIndexField")

will tell you the largest number in the field. If the delimiter isn't  
comma, you may have to fix it so it is (using 'replace' for example).

To get rid of duplicates and make a list of those numbers duplicated,  
you can do something like this (in a button in this example, but of  
course it could be a function) - still assuming comma is the delimiter.

on mouseUp
     local myLastItemRead, myResultTemp,myListOfDuplicates
     put empty into myLastItemRead
     put empty into myListOfDuplicates
     put empty into MyResultTemp
     set the itemdel to comma
     sort items of fld "myIndexField" ascending numeric
     repeat for each item myIndex in fld "myIndexField"
         if myIndex <> myLastItemRead then -- this is not a duplicate
             put myIndex into myLastItemRead
             put myIndex&"," after myResultTemp
         else
             if myIndex <> last item of myListOfDuplicates then
                 put myIndex&"," after myListOfDuplicates
             end if
         end if
     end repeat
     delete last char of myResultTemp -- a spare comma
     if myListOfDuplicates is not empty then delete last char of  
myListOfDuplicates -- another spare comma
     put "Items duplicated:"&&myListOfDuplicates
     put myResultTemp into fld "myIndexField"
end mouseUp

However I don't understand how your index field (which just seems  
from what I understand to be a set of numbers) is associated with the  
"thousands of cards" which you mention, so I may well have missed the  
point of the exercise.

Nevertheless HTH

Graham

On Mon, 14 Apr 2008 09:40:14 -0400, "william humphrey"  
<shoreagent at gmail.com> wrote:
>
> Can someone help me with a function?
>
> If sort all cards by fld "index" doesn't work and fld "index" has a  
> bunch of
> numbers in it which aren't in order and skip some values how do I
> 1. Find out what is the highest value in fld "index"?
> 2. Find out a list of any numbers that are duplicates?
>
> I'm afraid that I do to much work of this sort in Excel and I can't  
> think of
> a way to do this without dumping all the values to memory and  
> working on
> them there.




More information about the use-livecode mailing list