I use mdx's lists a lot, and anytime i want to fill some row i must obey the rule of adding $chr(9) after each value and also, if the value is a number, prefix it with 4 zeros if it's the first in the line and 3 zeros if its anywhere else. Unless i keep up with that rule, numbers and percentages won't show up in the list or appear weird. So i gotta use a line like:

did -a $dname <ID> $+(0 0 0 0 %cd,$chr(9),%nm,$chr(9),%sr,$chr(9),0 0 0 %ls,$chr(9),%tx) if %cd and %ls are number s


did -a $dname <ID> $+(0 0 0 %cd,$chr(9),%nm,$chr(9),%sr,$chr(9),%ls,$chr(9),%tx) if %cd amd %ls are strings

What i want to do is to make an alias that creates this whole line automatically, so i would only have to parse the variables, like:

did -a $dname <ID> $maketok(44,%cd,%nm,%sr,%ct,%tx)

which would save me a lot of typing and time and looks better.

I'm trying out this:

maketok {
  var %t = 1,%newtok
  while (%t <= $numtok($2-,$1)) {
    if (%t == 1) { %newtok = $addtok(%newtok,$iif($left($gettok($2-,%t,$1),1) isnum,0 0 0 0 $gettok($2-,%t,$1),0 0 0 $gettok($2-,%t,$1)),9) }
    else { %newtok = $addtok(%newtok,$iif($left($gettok($2-,%t,$1),1) isnum,0 0 0 $gettok($2-,%t,$1),$gettok($2-,%t,$1)),9) }
    inc %t
  return %newtok

The alias should do few things:
- Use $1 as a solid character for separating the rest of input into tokens
- Count the number of tokens in $2- with $1 as the separator
- Make %newtok, a new tokenized line with $chr(9) as a separator
- Add 0 0 0 0 to the first token if it's a number or starts with a number and 0 0 0 if it's a string
- Add 0 0 0 to any other token if it's a number and nothing if it's a string
- Return the %newtok as a line that can directly be added to an mdx list

As you guessed, it doesn't work good.
The are several problems i can't figure a solution for:
- The alias does not put $chr(9) between tokens, instead i always get a space
- If one of the values contains a comma (eg if %sr is an address: 9, London str.) the alias sees one more token
- It doesn't always add the 3 zeros in front of values starting with number (eg a date)