# How to separately access the abscissa and ordinate of the current point?

Consider the following code.

\documentclass[pstricks,border=12pt]{standalone}
\SpecialCoor

\begin{document}
\begin{pspicture}[showgrid](-5,-5)(5,5)
\pscustom
{
\psline(1,0)
\rlineto(0,1)
%\translate(!!CP.x 0) % does not work!
}
\end{pspicture}
\end{document}


I want to separately access the abscissa and ordinate of the current point, how to do so?

CP is actually a postcript macro of two elements x y. You can access them using pop and exch pop to access them separately. However the values are not in the same coordinate system as the pstricks coordinates (eg. (1,2)) so some conversions are necessary. Here it goes

\documentclass[pstricks,border=12pt]{standalone}
\SpecialCoor

\begin{document}
\makeatletter
\begin{pspicture}[showgrid](-5,-5)(5,5)
\pscustom
{
\psline(1,0)
\rlineto(1,1)
\rlineto(!!CP pop -2 \pst@number\psyunit mul) %CP.x = 2 --> \rlineto(2,-2)
\rlineto(!!CP exch pop -1 \pst@number\psyunit mul) %CP.y = -1 --> \rlineto(-1,-1)
}
\end{pspicture}
\end{document}


And the result is:

• \rlineto(! CP \tx@UserCoor pop -2 ) makes life easier ... – user2478 Jan 21 '14 at 21:43