I couldn't resist testing it and here's what I came up with.

I created a field "myfield" loaded with test numbers and a Go button with this script:

On MouseUp
put false into found
put "1,2,3" into search$
-- sort field "myList"
repeat with x = the number of lines in field "myList" down to 1
If char 1 of line x of field "mylist" is among the items of search$ and char 2 of line x of field "mylist" is among the items of search$ and char 3 of line x of field "mylist" is among the items of search$ then
If found then
delete line x of field "myList"
beep
else
put true into found
end if
end if
end repeat


end MouseUp


Points to note:


If you don't care which matching item you keep, then you don't need to sort the list.

If you want to keep the lowest (value) one, sort descending, if you want to keep the highest one, sort ascending as the search has to start at the last item to stop the integrity of the search being destroyed by deletions.

Steve




At 23:35 21/11/03 +0000, you wrote:
I'll attempt to correct my own syntax errors:

put false into found
search$="1,2,3"
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 search$ and char 2 of line x of mylist is among the items of search$ and char 3 of line x of mylist is among the items of search$ then
If found then
delete line x of field "myList"
beep
else
put true into found


              end if
        end if
end repeat


At 23:10 21/11/03 +0000, you wrote:
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 ð [EMAIL PROTECTED] 220 Drake Road, Bethel Park, PA 15102


_______________________________________________ use-revolution mailing list [EMAIL PROTECTED] http://lists.runrev.com/mailman/listinfo/use-revolution


_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to