I don't want to use the following
\begingroup
\edef\next{\endgroup
\noexpand\const{Xp}{\X(tp)}
\noexpand\const{Yp}{\Y(tp)}
\noexpand\const{Xf}{\X(tf)}
\noexpand\const{Yf}{\Y(tf)}
}\next
and
\begingroup
\edef\next{\endgroup
\noexpand\psparametricplot[algebraic,plotpoints=100]{0}{\tf}{\X(t)|\Y(t)}}\next
because they seem to be cryptic.
Instead I want to create a new environment as follows,
\newenvironment{DelayExpansion}
{\begingroup
\edef\next\bgroup\endgroup\ignorespaces}
{\egroup\next\ignorespacesafterend}
but unfortunately it produces compilation errors that you can see by yourself.
If the errors can be fixed, the environment will be used as follows,
\DelayExpansion
\noexpand\const{Xp}{\X(tp)}
\noexpand\const{Yp}{\Y(tp)}
\noexpand\const{Xf}{\X(tf)}
\noexpand\const{Yf}{\Y(tf)}
\endDelayExpansion
and
\DelayExpansion
\noexpand\psparametricplot[algebraic,plotpoints=100]{0}{\tf}{\X(t)|\Y(t)}}
\endDelayExpansion
Or without specifying the \noexpand
as follows.
\DelayExpansion
\const{Xp}{\X(tp)}
\const{Yp}{\Y(tp)}
\const{Xf}{\X(tf)}
\const{Yf}{\Y(tf)}
\endDelayExpansion
and
\DelayExpansion
\psparametricplot[algebraic,plotpoints=100]{0}{\tf}{\X(t)|\Y(t)}}
\endDelayExpansion
The MWE for the real scenario is given as follows.
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\addtopsstyle{gridstyle}{gridlabels=0,griddots=0,subgriddiv=5,gridwidth=0.4pt,subgridwidth=0.2pt}
\usepackage[nomessages]{fp}
\newcommand\const[3][3]{%
\expandafter\FPeval\csname#2\endcsname{round(#3:#1)}%
\pstVerb{/#2 \csname#2\endcsname\space def}%
}
\const{Vox}{2}
\const{Xo}{1}
\const{Voy}{4}
\const{Yo}{10}
\const{g}{10}
\def\X(#1){Xo+Vox*#1}
\def\Y(#1){Yo+Voy*#1-0.5*g*#1^2}
\const{tp}{Voy/g}
\const{toffset}{0.5}
\const{tf}{2*tp+toffset}
%\newenvironment{DelayExpansion}
%{\begingroup
%\edef\next\bgroup\endgroup\ignorespaces}
%{\egroup\next\ignorespacesafterend}
%
%\DelayExpansion
%\noexpand\const{Xp}{\X(tp)}
%\noexpand\const{Yp}{\Y(tp)}
%\noexpand\const{Xf}{\X(tf)}
%\noexpand\const{Yf}{\Y(tf)}
%\endDelayExpansion
\begingroup
\edef\next{\endgroup
\noexpand\const{Xp}{\X(tp)}
\noexpand\const{Yp}{\Y(tp)}
\noexpand\const{Xf}{\X(tf)}
\noexpand\const{Yf}{\Y(tf)}
}\next
\begin{document}
\begin{pspicture}[showgrid](0,\Yp)(\Xf,\Yf)
\psframe[fillstyle=vlines,fillcolor=gray](0,\Yf)(\Xo,\Yo)
\psparametricplot[algebraic,plotpoints=100]{0}{\tf}{\X(t)|\Y(t)}
\end{pspicture}
\end{document}
How to create a "delay expansion" environment?
The latest update:
I have tried the solution given by Ryan, but it still produces some errors (please try it by yourself to see the error messages).
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\usepackage[nomessages]{fp}
% cannot be simplified unless I must break my real scenario
\newcommand\const[3][3]{%
\expandafter\FPeval\csname#2\endcsname{round(#3:#1)}%
\pstVerb{/#2 \csname#2\endcsname\space def}%
}
\const{Xo}{1}
\const{Yo}{10}
\const{tp}{0.4}
\const{tf}{2*tp+1.5}
\def\X(#1){Xo+2*#1}
\def\Y(#1){Yo+4*#1-0.5*5*#1^2}
% try this for comparison first
%\begingroup
%\edef\next{\endgroup
%\noexpand\const{Yp}{\Y(tp)}
%}\next
% Ryan's suggestin
\usepackage{environ}
\NewEnviron{DelayExpansion}{%
\begingroup
\edef\next{\endgroup\BODY}%
\next%
}
% Ryan's suggestion
\begin{DelayExpansion}
\noexpand\const{Yp}{\Y(tp)}
\end{DelayExpansion}
\begin{document}
\begin{pspicture}(0,6)(6,\Yp)
\psparametricplot[algebraic,plotpoints=100]{0}{\tf}{\X(t)|\Y(t)}
\end{pspicture}
\end{document}
I will offer 4 bounties of 500 each to a single accepted answer. Does it sound excited?