I just want to draw a dot if the condition is satisfied and otherwise cancel the drawing of the single dot. The following code is the simplified version of my real scenario. Please don't suggest other methods because the part I want to learn is to abort drawing.
The code below is intended to draw a dot for each point on the x-axis whenever its abscissa is an even number. More precisely, there is no dot for odd abscissa.
\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{multido}
\SpecialCoor
\begin{document}
\begin{pspicture}[showgrid](-5,-5)(5,5)
\multido{\i=-5+1}{11}{\qdisk(!\i\space 2 mod 0 eq {\i\space 0} {<don't draw a dot and continue the loop>} ifelse){2pt}}
\end{pspicture}
\end{document}
Is it possible to exit from the PostScript expression and abort the drawing just for certain dots that do not match the condition?
Edit
I want to get a solution that is useful not only for qdisk but also other graphic macros including the starred version.
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{multido}
\SpecialCoor
\begin{document}
% Herbert's method
\begin{pspicture}[showgrid](10,4)
\multido{\i=1+1}{9}
{
\pscircle*(!\i\space dup 2 mod 0 ne {/SD {pop pop pop} def} if 1){5pt}
\pscircle(!\i\space dup 2 mod 0 ne {/SD {pop pop pop} def} if 3){5pt}
}
\end{pspicture}
% modified Herbert's method
\begin{pspicture}[showgrid](10,4)
\multido{\i=1+1}{9}
{
\pscircle*(!\i\space dup 2 mod 0 ne {/SD {} def} if 1){5pt}
\pscircle(!\i\space dup 2 mod 0 ne {/SD {} def} if 3){5pt}
}
\end{pspicture}
% modified AlexG's method
\begin{pspicture}[showgrid](10,4)
\multido{\i=1+1}{9}
{
\pscircle*(!\i\space dup 2 mod 0 ne {mark Rand Rand /SD {cleartomark} def} if 1){5pt}
\pscircle(!\i\space dup 2 mod 0 ne {mark Rand Rand /SD {cleartomark} def} if 3){5pt}
}
\end{pspicture}
% my attempt with other macros
\begin{pspicture}[showgrid](10,4)
\multido{\i=1+1}{9}
{
% compilable but result in a wrong output
\psframe
(!\i\space dup 2 mod 0 ne {/SD {pop pop pop} def} if .2 sub 2.8)
(!\i\space dup 2 mod 0 ne {/SD {pop pop pop} def} if .2 add 3.2)
%--------------------------------------------------------------------------------
% does not compile with GhostScript
%\psframe
%(!\i\space dup 2 mod 0 ne {mark Rand Rand /SD {cleartomark} def} if .2 sub 2.8)
%(!\i\space dup 2 mod 0 ne {mark Rand Rand /SD {cleartomark} def} if .2 add 3.2)
}
\end{pspicture}
\end{document}
Outputs in the same order.




\qdisk, or not draw the entire drawing at all (and fail the process completely)? – Werner Jan 23 '14 at 05:43pstricks. That way you can condition on even/odd and draw something/not. – Werner Jan 23 '14 at 07:05