Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following code:

\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn

\cs_new:Nn \__test_current_choice_against_version: { I'm working }

\seq_new:N \g__user_defined_choice_seq
\NewDocumentCommand{\choices}{ O{;} m }{
    \texttt{#2}\par
    \seq_set_split:Nnn \g__user_defined_choice_seq  #1  #2
    \seq_show:N \g__user_defined_choice_seq
}

\ExplSyntaxOff
\begin{document}

Choosing \choices{x;y;z;w}

\end{document}

and it doesn't seem to be doing at all what I expect.

First the \seq_show:N is creating an error and the document does not produce output. The error is:

The sequence \g__user_defined_choice_seq contains the items (without outer
braces):
>  {x}.
<recently read> }

l.17 Choosing \choices{x;y;z;w}

?

Secondly and the reason I was trying \seq_show:N...... was because my argument is not getting split. I'm expecting that \g__user_defined_choice_seq should have four elements and not just one.

Edit

I've also tried using \seq_gset_split thinking that that might be the problem with how the argument is getting split, but that doesn't seem to make a difference.

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

You're missing braces around #1 and #2:

\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn

\seq_new:N \l__user_defined_choice_seq
\NewDocumentCommand{\choices}{ O{;} m }
 {
  \texttt{#2}\par
  \seq_set_split:Nnn \l__user_defined_choice_seq { #1 } { #2 }
  \seq_show:N \l__user_defined_choice_seq
 }

\ExplSyntaxOff
\begin{document}

Choosing \choices{x;y;z;w}

\end{document}

n type arguments should always be in braces, while N arguments shouldn't (and should consist of only one token).

Also you're mixing "local" and "global". Variables with the g_ prefix should always be acted upon globally. So either use

\seq_gset_split:Nnn

or use a local variables.

share|improve this answer
    
On to the next question then. –  A.Ellett Jan 21 '13 at 23:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.