On Mon January 26 2009 8:14:11 am Wolfgang Schuster wrote:
Hi Bart,
Is there a way to pass in my own defined parameters to such a function?
I would like to be able to do something similar to the following:
\startCenteredText[myownparm="This is a test"] \startlines My own parm is: \myownparm \stoplines \stopCenteredText
Not with framedtext but you define your environment with a optional argument.
ConTeXt has the command \definestartstop but it did not help in your case, something like LaTeXs \newenvironment, I wrote a simple version below.
\unprotect
\def\????ev{@@@@ev}
\def\environmentparameter#1% {\csname\????ev\currentenvironment#1\endcsname}
\def\defineenvironment {\dodoubleempty\dodefineenvironment}
\def\dodefineenvironment[#1][#2]% {\getparameters [\????ev#1] [\c!before=, \c!after=, #2]% \setvalue{\e!start#1}{\dodoubleempty\dostartenvironment[#1]}% \setvalue{\e!stop #1}{\dostopenvironment}}
\def\setupenvironment {\dodoubleargument\dosetupenvironment}
\def\dosetupenvironment[#1][#2]% {\getparameters[\????ev#1][#2]}
\def\dostartenvironment[#1][#2]% {\bgroup \edef\currentenvironment{#1}% \ifsecondargument \setupenvironment[\currentenvironment][#2]% \fi \environmentparameter\c!before}
\def\dostopenvironment {\environmentparameter\c!after \egroup}
\protect
\defineframedtext [CenteredTextFrame] [width=fit, location=middle]
\defineenvironment [CenteredText] [before=\startCenteredTextFrame\startlines, after=\stoplines\stopCenteredTextFrame]
\starttext
\startCenteredText[text={This is a test}] My own parm is: \environmentparameter{text} \stopCenteredText
\stoptext
Thanks Wolfgang for the insight. Bart