[pstricks] Defining an option similar to 'dash'

Christoph Bersch usenet at bersch.net
Mon May 26 21:35:32 CEST 2008

Hi,

I am trying to define an option which is similar to 'dash' in pstricks.tex:

\documentclass{article}
\usepackage{pstricks, pst-xkey}
\makeatletter
%
% a dummy option
\define at key[psset]{}{newoption}{\edef\psk at newoption{#1}}%
%
\define at key[psset]{}{lens}{%
\pst at expandafter\psset@@lens{#1} {0} {0} %
{\pst at missing} {\pst at missing} {}\@nil
}%
\def\psset@@lens#1 #2 #3 #4 #5\@nil{%
\psset{linewidth=#1,%
linewidth=#2,%
linewidth=#3,%
linewidth=#4
%    newoption=#4 % <- using this does not give the correct error
}%
}%
\makeatother
\begin{document}
\psset{lens=1 2 3 4}
\psset{lens=1 2 3}
\psset{lens=1 2}
\psset{lens=1}
\end{document}

This way it works and gives me the correct error message

! Missing number or dimension. 0 substituted.
\@pstrickserr ... immediate help.}\errmessage {#1}
\endgroup
l.25 \psset{lens=1}

However, when I use 'newoption' instead of the 'linewidth' in the last
assignment, it results in an

! Undefined control sequence.
\@pstrickserr #1#2->\begingroup \newlinechar \

\edef \pst at tempc
{#2}\expan...
l.25 \psset{lens=1}

I suppose it has to do something with the \pssetlength which is used
when setting 'linewidth' compared to the \edef in the 'newoption'.
What do I have to change in order to get the correct error message using
the 'newoption=#4' in \psset@@lens?

Thank you,
Christoph

`