Topic on Extension talk:Arrays

#arrayprint: Default delimiter?

4
Nakohdo (talkcontribs)

Hi,

I'm using a combination of #arraydefine, #arraysort and #arrayprint to print a sorted list of page titles. I had to change the delimiter for #arraydefine and #arraysort from the default comma to a semicolon because some page titles contain commas. However, now I get semicolons in the output. I suspect that #arrayprint doesn't recognize them as delimiter. Could that be the case? Or am I missing something? Any pointers welcome.

TIA

Frank

Dinoguy1000 (talkcontribs)

You also need to specify the delimiter in #arrayprint: {{ #arraydefine: @array | this; is; an; array | ; }}{{ #arrayprint: @array | ; | ... }}.

On a semirelated note, for dealing with page titles, I'd recommend using some delimiter that you know can't appear in page titles; my usual go-to is an asterisk (with some care you might be able to use non-parenthesis brackets, though I've never tried (and yes, I realize that asterisks can appear in page titles, but in practice this is so rare that, unless your wiki has some specialized scope making it likely to happen, you can generally safely ignore the possibility)).

Henryfunk (talkcontribs)

Good advice re choice of delimiter. Just to clarify: Nakohodo wanted to get rid of the semi-colons. To do so he should use {{ #arrayprint: @array || ... }}.

Nakohdo (talkcontribs)

Many thanks for your quick reply and the pointer. The culprit was actually another semicolon I had added somewhere else in the template code. Using an asterisk makes the code more readable and should indeed be safer with page titles.

Speaking of SMW code readability, I've created a syntax highlighting scheme for Notepad++ to make life easier: https://github.com/nakohdo/NPP.SemanticMediaWiki

Reply to "#arrayprint: Default delimiter?"