ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* \write \getvariable and expansion
@ 2006-11-18  2:47 Aditya Mahajan
  2006-11-19  9:39 ` Taco Hoekwater
  0 siblings, 1 reply; 3+ messages in thread
From: Aditya Mahajan @ 2006-11-18  2:47 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: \write \getvariable and expansion
  2006-11-18  2:47 \write \getvariable and expansion Aditya Mahajan
@ 2006-11-19  9:39 ` Taco Hoekwater
  2006-11-19 17:44   ` Aditya Mahajan
  0 siblings, 1 reply; 3+ messages in thread
From: Taco Hoekwater @ 2006-11-19  9:39 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: \write \getvariable and expansion
  2006-11-19  9:39 ` Taco Hoekwater
@ 2006-11-19 17:44   ` Aditya Mahajan
  0 siblings, 0 replies; 3+ messages in thread
From: Aditya Mahajan @ 2006-11-19 17:44 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-19 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-18  2:47 \write \getvariable and expansion Aditya Mahajan
2006-11-19  9:39 ` Taco Hoekwater
2006-11-19 17:44   ` Aditya Mahajan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).