1

In my code it's need for me generate variables from sequences. For example, I have variable \g__test_bool. For an empty sequence it should be the same. For sequence with a_ item it should be \g__test_a_bool, for sequence with a_,b_ items it should be \g__test_a_b_bool, etc. But when I try to do this, I get an error:

! Undefined control sequence.
<argument> \g__
\documentclass{article}
\ExplSyntaxOn
\seq_new:N\g__vars_seq
\bool_gset_true:N\g__test_bool
\bool_if:NTF\g__\seq_use:Nn\g__vars_seq{}test_bool{}{}
\ExplSyntaxOff
\begin{document}

\end{document}

1 Answer 1

2

Since you are building the control sequence name from a string of characters, you need to use the c variant, \bool_if:cTF, otherwise the control sequence is \g__, which does not exist.

\documentclass{article}
\ExplSyntaxOn
\seq_new:N \g__kozlovskiy_vars_seq
\bool_gset_true:N \g__kozlovskiy_test_bool

\bool_if:cTF
  { g__kozlovskiy_ \seq_use:Nn \g__kozlovskiy_vars_seq { } test_bool }
  { \typeout{TRUE} }
  { \typeout{FALSE} }

\ExplSyntaxOff
\begin{document}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .