Jump to content



Photo

Count Repeating Numbers In A List


  • Please log in to reply
3 replies to this topic

#1 Qurius

Qurius

    Newbie

  • Members
  • Pip
  • 8 posts
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Professional Edition

Posted 15 September 2015 - 12:46 AM

Hello -

 

Hoping someone can help me with this...I've pulled data from a column in a table and added it to a list. The data is just repeating numbers that are either 1,2 or 3. I need to get a total count of each of those numbers to put in variables i.e. 3 one's, 4 two's etc.

 

I've tried every way I can think of and not good with regex so if anyone has a simple way to do this I'd appreciate it.

 

Thanks 



#2 the_way

the_way

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 559 posts
  • OS:Windows 8
  • Total Memory:3Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 15 September 2015 - 05:58 AM

loop while, list count, and then an if statement that increments each time the variable matches


2VHxTj5.png


#3 Qurius

Qurius

    Newbie

  • Members
  • Pip
  • 8 posts
  • OS:Windows 7
  • Total Memory:8Gb
  • Framework:v3.5 & v4.0
  • License:Professional Edition

Posted 15 September 2015 - 11:35 AM

Thanks for the help...I'll see if I can make that work.



#4 deliter

deliter

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 613 posts
  • OS:Windows 8
  • Total Memory:More Than 9Gb
  • Framework:v4.0
  • License:Developer Edition

Posted 15 September 2015 - 07:13 PM

there is probably a better way to do this,as was a lot of new list functions added recently,havn't learned them yet,change the %myList to your list name on the add list to table as column

define $DuplicatesCount(#Duplicate) {
    add list to table as column(&Results,1,1,%myList)
    set(#counter,0,"Local")
    loop while($comparison($plugin function("TableCommands.dll", "$table search", &Results, #Duplicate, "Row Index"),">","-1")) {
        set table cell(&Results,$plugin function("TableCommands.dll", "$table search", &Results, #Duplicate, "Row Index"),1,"")
        increment(#counter)
    }
    clear table(&Results)
    return(#counter)
}






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users