# postscript code in psplot fails

the following code snippet doesn't work as expected

\documentclass{article}

\usepackage{pstricks,pst-plot}

\pagestyle{empty}
\thispagestyle{empty}

\begin{document}

\begin{pspicture}(10,10)

\psplot{0}{10}{%
5 x le { x } if
}

\end{pspicture}

\end{document}


Especially with regard to the PostScript-code

 5 x le { x } if


Simple postscripts without conditional executions or loops work fine. I have the sense that i might have to escape the curly braces, but escaping them with a slash doesn't work either.

Maybe someone of you experts can me help to solve my little problem!?

Let the wisdom be with you and best regards

-

You don't have to escape the braces, they are correctly passed to the DVI file. However, psplot expects the function to leave a value on the operand stack for each x. The expression

5 x le { x } if


doesn't create any value if the condition evaluates to false. Thus, you should replace it with some kind of ifelse construct instead, e.g. something like

5 x le {x} {0} ifelse

-
Thanks a lot for your fast reply! You solved my problem... –  user1146332 May 1 '12 at 17:35