is among - problem

Steve Laming steve.laming at ntlworld.com
Fri Nov 21 18:10:33 EST 2003


Hi Thomas

I don't yet know revolution well enough to check your coding quickly, but 
it does seem a little long winded.

Perhaps you could try something along these lines.

found=false
sort field "myList"
repeat with x = 1 to the number of lines in field "myList"
         If char 1 of line x of mylist is among the items of "123" and char 
2 of line x of mylist is among the items of "123" and char 3 of line x of 
mylist is among the items of "123" then
                 If found then
                         delete line x of field "myList"
                         beep
                 else found = true
end repeat

the found flag should make sure that the first occurence is left intact.

I'm sorry if any of the syntax is incorrect as I am new to revolution, but 
I am fairly certain that the logic will achieve your goal.

Regards

Steve





At 09:47 21/11/03 -0500, you wrote:
>Hello to all of you wonderful REV developers..  :-)
>
>I have a problem where I have a field filled with 3 single digit numbers 
>per line (210 lines). I wanted to find and delete any lines that had ALL 
>of the same numbers in it but in any order - so 123 and 213 and 321 and 
>312 would be duplicates and I would delete all but the first one.
>
>The only thing I could think of was to convert the list to items with 
>commas between them and use the "is among" command.
>I think I did it right but each time I try this I get different results 
>from the following script. They are close but different.
>
>I thought I would go with use one line to check all of the other lines and 
>if a total match is found then delete that line. But looking through the 
>list that is left over after this runs I still find a bunch of 
>"duplicates" - 1,3,2 and later on a 3,1,2 which should be deleted.
>
>Any ideas what I did wrong??? Or where my square peg thinking got me into 
>trouble???
>
>Mouse handler with two fields: myList has the list of random numbers
>and myCount which holds the final count. I am trying to find an answer for 
>my daughters Math problem and this is the last part of it.
>
>   sort field "myList"
>   put the number of lines of field "myList" &cr after field "myCount"
>   repeat with x = 1 to the number of lines in field "myList"
>     put char 1 of line x of field "myList" & "," into myTemp
>     put  char 2 of line x of field "myList" & "," after myTemp
>     put  char 3 of line x of field "myList" after myTemp
>     put myTemp into line x of field "myList"
>   end repeat
>   repeat with x = 1 to the number of lines in field "myList"
>     repeat with y = 1 to (the number of lines in field "myList" - 1)
>       put y + 1 into y
>       put item 1 of line y of field "myList" into H
>       put item 2 of line y of field "myList" into I
>       put item 3 of line y of field "myList" into G
>       put line x of field "myList" into J
>
>       if H is among the items of J then
>         if I is among the items of J then
>           if G is among the items of J then
>             delete line y + 1 of field "myList"
>             beep
>           end if
>         end if
>       end if
>     end repeat
>
>
>Advanced Media Group
>Thomas J McGrath III    ð 2003 ð        3mcgrath at adelphia.net
>220 Drake Road, Bethel Park, PA 15102
>
>
>_______________________________________________
>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