I think that you are using the #Define mechanism incorrectly.
Your code example has a single custom function named, "countvalue". This is the contents of this CF:
setctrsv 1, value
[/font][/color]
You have defined value using the #Define as the following:
value DM[1]=5
[/font][/color]
The #Define mechanism is a simple text substitution. TBASIC will replace the text string "value" with "DM[1]=5"
So your CF after the text substitution would look like this:
setctrsv 1, DM[1]=5
[/font][/color]
The statement "DM[1]=5" is a relational statement that tests for DM[1] being equal to 5. This relational statement will evaluate to numeric 1 if DM[1] is equal to 5 or a numeric 0 if it is not. So your CF will assign either a 1 or a 0 to the SV (Set value) of COUNTER #1 depending on the value of DM[1].
I am betting that this is not what you intended.
I suspect that you wanted to assign the value of DM[1] to the SV of the counter. If so, you need to change the #define to look more like this:
value DM[1]
[/font][/color]
I would, also, suggest that you use the COUNTER's name rather than its number, so I'd change your custom function to look like this:
setctrsv pos, value
[/font][/color]
After TBASIC subsitiutes the text, "DM[1]" for "value" your CF will look like this before it is complied by TBASIC:
setctrsv pos, DM[1]
[/font][/color]
However, even with these changes, I don't see that your program would do anything useful.
What are you trying to accomplish? If you can answer this question, I could point you in a more useful direction.
Regards,
Gary D*ckinson