forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Find number of double occurences in a list

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code
View previous topic :: View next topic  
Author Message
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Tue Sep 14, 2004 2:40 pm    Post subject: Find number of double occurences in a list Reply with quote

Hey guys,

Skit asked me if I could write a script that was able to count the number of double occurences of a list item in a list... I though I could share the script as well Wink

Code:

#
# 2004 Vic D'Elfant
#--------------------------------------------------------

     option decimalsep, ","

     list create, 1
     list create, 2
     list create, 3
     
     list loadtext, 1,
"Window1
"Window2
"Window4
"Window4a
"Window1
"Window1
"Window5
"Window4a

     # List 1: list with double items
     # List 2: temporary list
     # List 3: will contain <item list 1>|<number of matches> after running the code below
     
     list seek, 1, 0
     list assign, 2, 1
     
     
     while @ok()
         %%Search_Item = @item(1)
         %%Match_Count = 0
   
         list seek, 2, 0
         while @both(@match(2, %%Search_Item), @ok())
             if @equal(%%Search_Item, @item(2))
                 %%Match_Count = @succ(%%Match_Count)
             end
             
             if @unequal(@count(2), @succ(@index(2)))
                 list seek, 2, @succ(@index(2))
             else
                 error -1
             end
         wend
         
         %%Causes_Double =
         
         if @not(@zero(@count(3)))
             list seek, 3, 0
             
             while @both(@ok(), @not(%%Causes_Double))
                parse "%%Window_Name", @item(3)
                if @equal(%%Window_Name, %%Search_Item)
                   %%Causes_Double = 1
                end
               
                if @unequal(@count(3), @succ(@index(3)))
                     list seek, 3, @succ(@index(3))
                 else
                     error -1
                 end
             wend
         end
         
         if @not(%%Causes_Double)
             list add, 3, %%Search_Item|%%Match_Count
         end
         
         if @unequal(@count(1), @succ(@index(1)))
             list seek, 1, @succ(@index(1))
         else
             error -1
         end
     wend
     
     info @text(3)


Vic

_________________
phpBB Development Team
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Thu Sep 16, 2004 8:23 pm    Post subject: Reply with quote

Cool Thumbs Up
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Thu Sep 16, 2004 8:25 pm    Post subject: Reply with quote

Thanks Very Happy

Vic

_________________
phpBB Development Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 5 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group