• Welcome to Vice City Multiplayer.
 

Counting

Started by Tamas, November 19, 2008, 03:58:25 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tamas

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.

Mex

#1
try this

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:
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