|
dntc Newbie
Joined: 20 Jul 2002 Posts: 4 Location: China
|
Posted: Sun Sep 29, 2002 11:30 am
help with a function |
countlist
Syntax: %countlist(list)
count the number of times each item appears in a string list and return a database record with the items as key properties, and the count of each item as the value of the key
my english is poor,and can't understand the meaning.
Can you give me an example? |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sun Sep 29, 2002 3:19 pm |
Sure can. Lets say you have the following stringlist:
#VAR colors {red|blue|red|green|yellow|blue|orange|green|red|blue|orange}
Now, if you do:
#VAR count {%countlist(@colors)}
#SHOWDB @count
You will see:
red: 3
blue: 3
green: 2
yellow: 1
orange: 2
What %countlist did was return a record variable (basically a stringlist, but each item is a key-value pair) where the keys are the items in the strnglist, without repeating each more than one, and the values are the number of times the item appears in the stringlist.
Note: While testing, %countlist appeared to be giving incorrect results. In theory, it should work as described above.
Kjata |
|
|
|
dntc Newbie
Joined: 20 Jul 2002 Posts: 4 Location: China
|
Posted: Mon Sep 30, 2002 10:16 am |
I see,thank you!
|
|
|
|
|
|
|
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
|
|