Author Topic: Counting  (Read 2938 times)

0 Members and 1 Guest are viewing this topic.

Offline Tamas

  • Made Man
  • ***
  • Posts: 127
    • View Profile
    • http://www.tamasnet.eu/
Counting
« on: November 19, 2008, 06:58:25 pm »
Somebody knows how can i count a specific name value inside the ini file?
For example if the ini file containes 200 names and i want to count only the xy* name, than return the total value of that names.

Offline Mex

  • Wiseguy
  • **
  • Posts: 63
    • View Profile
Re: Counting
« Reply #1 on: November 21, 2008, 01:38:37 am »
try this

Code: [Select]
var %a = 1, %b = $ini(filename.ini,section,0), %c = 0
while (%a <= %b) {
  if (xy* iswm $ini(filename.ini,section,%a)) { !inc %c }
  !inc %a
}
!echo -a total items in section that match xy*: %c

[edit]
the above code is for if the ini layout is like:
[section]
xy1=value
xy2=value
xy3=value
etc

if your ini layout is like:
[section]
item=xy1
item2=xy2
item3=xy3

then try this:
Code: [Select]
var %a = 1, %b = $ini(filename.ini,section,0), %c, %d = 0
while (%a <= %b) {
  %c = $ini(filename.ini,section,%a)
  if (xy* iswm $readini(filename.ini,n,section,%c)) { !inc %d }
  !inc %a
}
!echo -a total values in section that match xy*: %d
« Last Edit: November 21, 2008, 05:12:19 pm by Mex »