Commas (MPI)
From Tapestries MUCK
Line 1: | Line 1: | ||
[[Category:MPI functions]] | [[Category:MPI functions]] | ||
- | + | =commas= | |
<mpi>{commas:list} | <mpi>{commas:list} | ||
{commas:list,lastsep} | {commas:list,lastsep} |
Revision as of 08:01, 30 March 2007
commas
{commas:list} {commas:list,lastsep} {commas:list,lastsep,var,expr}
Takes a list and returns a plain english comma delimited string with the items in it. For example,
{commas:{mklist:Tom,Dick,Harry}}will return:
"Tom, Dick and Harry"
If you specify the lastsep argument, you can replace the "and" with something else, such as "or" to get a result like "a, b or c". Note: You need to be careful to include spaces around the "or" or else you might get a result like "a, borc". Example:
{commas:{mklist:a,b,c}, or }
If the var and expr arguments are passed, then for every item in the list, it will set the value of the given variable name (which it will declare) to the item, then evaluate expr, and use the result in the string it outputs. Example:
{commas:{contents:here},\, or ,v,{name:{&v}}}
will return the name of every object in the room in a comma separated list, using ", or " as the final conjunction ie: "Tom, Can of SPAM, Dick, or Harry."