\write \getvariable and expansion
Hi, Can someone explain what should be the correct order of expansion here. I want to enter the date entered as a variable to a file. \setvariables [test] [date={d=11,m=11,y=2006}] \starttext The date entered was \expanded{\date[\getvariable{test}{date}]}. \immediate\openout \scratchwrite test-001 \immediate\write \scratchwrite {The date entered was} % None of these work. % \immediate\write \scratchwrite {\expanded{\date[\getvariable{test}{date}]}} % \expanded{\immediate\write \scratchwrite \date[\getvariable{test}{date}]}} \immediate\closeout\scratchwrite \stoptext Thanks, Aditya
Aditya Mahajan wrote:
Hi,
Can someone explain what should be the correct order of expansion here. I want to enter the date entered as a variable to a file.
\setvariables [test] [date={d=11,m=11,y=2006}]
\starttext
The date entered was \expanded{\date[\getvariable{test}{date}]}.
\immediate\openout \scratchwrite test-001 \immediate\write \scratchwrite {The date entered was} % None of these work.
The best you can get is: \immediate\write\scratchwrite{\noexpand\date[\getvariable{test}{date}]} (The variable is expanded, but \date is not) Greetings, Taco
On Sun, 19 Nov 2006, Taco Hoekwater wrote:
Aditya Mahajan wrote:
Hi,
Can someone explain what should be the correct order of expansion here. I want to enter the date entered as a variable to a file.
\setvariables [test] [date={d=11,m=11,y=2006}]
\starttext
The date entered was \expanded{\date[\getvariable{test}{date}]}.
\immediate\openout \scratchwrite test-001 \immediate\write \scratchwrite {The date entered was} % None of these work.
The best you can get is:
\immediate\write\scratchwrite{\noexpand\date[\getvariable{test}{date}]}
(The variable is expanded, but \date is not)
Thanks for the hint. Fortunately, I just needed the date in the format [year,/,mm,/,dd], so I can do something like \expanded{\setvariables[test:date][\getvariable{test}{date}]} \immediate\openout \scratchwrite test-001 \immediate\write \scratchwrite {The date entered was} \immediate\write \scratchwrite {\getvariable{test:date}{y}/\getvariable{test:date}{m}/\getvariable{test:date}{d}} \closeout\scratchwrite Aditya
participants (2)
-
Aditya Mahajan
-
Taco Hoekwater