ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* setting variable on cmd-line
@ 2009-09-18 13:31 Peter Münster
  2009-09-20 19:46 ` Peter Münster
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Münster @ 2009-09-18 13:31 UTC (permalink / raw)
  To: ConTeXt list

Hello,

I've a little feature request:
It would be nice, to have a command line option like "--setvalue x=y" or
similar for the "context" command to define a variable for the job.

Modes are already very nice, but often I need just one value for
conditional compiling a document instead of many binary switches.

Perhaps the "context --arguments" option is what I'm looking for, but I
didn't find how to use it.

Another option would be, to make the name of the result-file
("context --result=...") available, for example as "\resultname".

Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: setting variable on cmd-line
  2009-09-18 13:31 setting variable on cmd-line Peter Münster
@ 2009-09-20 19:46 ` Peter Münster
  2009-09-20 21:24   ` luigi scarso
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Münster @ 2009-09-20 19:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Fri, 18 Sep 2009, Peter Münster wrote:

> I've a little feature request:
> It would be nice, to have a command line option like "--setvalue x=y" or
> similar for the "context" command to define a variable for the job.
> 
> Modes are already very nice, but often I need just one value for
> conditional compiling a document instead of many binary switches.
> 
> Perhaps the "context --arguments" option is what I'm looking for, but I
> didn't find how to use it.

Hello,

After reading a bit in mtx-context.lua, I've found out how to use
--arguments:

test-file:

\starttext
Value of myVar: \ctxlua{tex.print(document.arguments["arguments=myVar"])}
\stoptext

cmd-line:

context --arguments=myVar=myValue test

But this syntax is very strange!

This would be much nicer:

Value of myVar: \getvariable{environment}{myVar}


Perhaps there is just a bug in the evaluation of environment.arguments?
That means, instead of using the first equal sign (=) for generating the
key/value pair, the last one is used.


> Another option would be, to make the name of the result-file
> ("context --result=...") available, for example as "\resultname".

Is this the right way to go: \systemparameter{file} ?

Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: setting variable on cmd-line
  2009-09-20 19:46 ` Peter Münster
@ 2009-09-20 21:24   ` luigi scarso
  2009-09-21  5:39     ` Peter Münster
  0 siblings, 1 reply; 9+ messages in thread
From: luigi scarso @ 2009-09-20 21:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Sun, Sep 20, 2009 at 9:46 PM, Peter Münster <pmlists@free.fr> wrote:
> On Fri, 18 Sep 2009, Peter Münster wrote:
>
>> I've a little feature request:
>> It would be nice, to have a command line option like "--setvalue x=y" or
>> similar for the "context" command to define a variable for the job.
>>
>> Modes are already very nice, but often I need just one value for
>> conditional compiling a document instead of many binary switches.
>>
>> Perhaps the "context --arguments" option is what I'm looking for, but I
>> didn't find how to use it.
>
> Hello,
>
> After reading a bit in mtx-context.lua, I've found out how to use
> --arguments:
>
> test-file:
>
> \starttext
> Value of myVar: \ctxlua{tex.print(document.arguments["arguments=myVar"])}
> \stoptext
>
> cmd-line:
>
> context --arguments=myVar=myValue test
>
> But this syntax is very strange!
Does
 context --arguments="myVar=myValue" test
work too ?
-- 
luigi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: setting variable on cmd-line
  2009-09-20 21:24   ` luigi scarso
@ 2009-09-21  5:39     ` Peter Münster
  2009-09-21  5:52       ` luigi scarso
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Münster @ 2009-09-21  5:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Sun, 20 Sep 2009, luigi scarso wrote:

> > test-file:
> >
> > \starttext
> > Value of myVar: \ctxlua{tex.print(document.arguments["arguments=myVar"])}
> > \stoptext
> >
> > cmd-line:
> >
> > context --arguments=myVar=myValue test
> >
> > But this syntax is very strange!
> Does
>  context --arguments="myVar=myValue" test
> work too ?

Yes, I'm using bash, so --arguments="myVar=myValue" is the same as
--arguments=myVar=myValue

That means, context does not see the quotes.

But I've also tried this: context --arguments=\"myVar=myValue\" test
Error:
MTXrun | unknown script 'context --arguments="myVar=myValue.lua' or 'mtx-context --arguments="myVar=myValue.lua'

Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: setting variable on cmd-line
  2009-09-21  5:39     ` Peter Münster
@ 2009-09-21  5:52       ` luigi scarso
  2009-09-21  6:16         ` Peter Münster
  0 siblings, 1 reply; 9+ messages in thread
From: luigi scarso @ 2009-09-21  5:52 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, Sep 21, 2009 at 7:39 AM, Peter Münster <pmlists@free.fr> wrote:
> On Sun, 20 Sep 2009, luigi scarso wrote:
>
>> > test-file:
>> >
>> > \starttext
>> > Value of myVar: \ctxlua{tex.print(document.arguments["arguments=myVar"])}
>> > \stoptext
>> >
>> > cmd-line:
>> >
>> > context --arguments=myVar=myValue test
>> >
>> > But this syntax is very strange!
>> Does
>>  context --arguments="myVar=myValue" test
>> work too ?
>
> Yes, I'm using bash, so --arguments="myVar=myValue" is the same as
> --arguments=myVar=myValue
>
> That means, context does not see the quotes.
OK, in this way  syntax looks less strange
-- 
luigi
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: setting variable on cmd-line
  2009-09-21  5:52       ` luigi scarso
@ 2009-09-21  6:16         ` Peter Münster
  2009-09-21  8:05           ` Hans Hagen
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Münster @ 2009-09-21  6:16 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, 21 Sep 2009, luigi scarso wrote:

> >> > test-file:
> >> >
> >> > \starttext
> >> > Value of myVar: \ctxlua{tex.print(document.arguments["arguments=myVar"])}
> >> > \stoptext
> >> >
> >> > cmd-line:
> >> >
> >> > context --arguments=myVar=myValue test
> >> >
> >> > But this syntax is very strange!
> >> Does
> >>  context --arguments="myVar=myValue" test
> >> work too ?
> >
> > Yes, I'm using bash, so --arguments="myVar=myValue" is the same as
> > --arguments=myVar=myValue
> >
> > That means, context does not see the quotes.
> OK, in this way  syntax looks less strange

It's not the syntax of the cmd-line that looks strange, it's the syntax how
to get the value of the variable:
\ctxlua{tex.print(document.arguments["arguments=myVar"])}

I'm quite sure, that this is not Hans' intention.

As I've written yesterday, I suppose, that the following syntax is wanted:
\getvariable{environment}{myVar}  but this does not work...

Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: setting variable on cmd-line
  2009-09-21  6:16         ` Peter Münster
@ 2009-09-21  8:05           ` Hans Hagen
  2009-09-21 19:43             ` Peter Münster
  0 siblings, 1 reply; 9+ messages in thread
From: Hans Hagen @ 2009-09-21  8:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Peter Münster wrote:
> On Mon, 21 Sep 2009, luigi scarso wrote:
> 
>>>>> test-file:
>>>>>
>>>>> \starttext
>>>>> Value of myVar: \ctxlua{tex.print(document.arguments["arguments=myVar"])}
>>>>> \stoptext
>>>>>
>>>>> cmd-line:
>>>>>
>>>>> context --arguments=myVar=myValue test
>>>>>
>>>>> But this syntax is very strange!
>>>> Does
>>>>  context --arguments="myVar=myValue" test
>>>> work too ?
>>> Yes, I'm using bash, so --arguments="myVar=myValue" is the same as
>>> --arguments=myVar=myValue
>>>
>>> That means, context does not see the quotes.
>> OK, in this way  syntax looks less strange
> 
> It's not the syntax of the cmd-line that looks strange, it's the syntax how
> to get the value of the variable:
> \ctxlua{tex.print(document.arguments["arguments=myVar"])}
> 
> I'm quite sure, that this is not Hans' intention.
> 
> As I've written yesterday, I suppose, that the following syntax is wanted:
> \getvariable{environment}{myVar}  but this does not work...
> 

how does it look with:

local flag, value = argument:match("^%-+(.-)=(.-)$")

.+ -> .-


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: setting variable on cmd-line
  2009-09-21  8:05           ` Hans Hagen
@ 2009-09-21 19:43             ` Peter Münster
  2009-09-21 20:23               ` Hans Hagen
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Münster @ 2009-09-21 19:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Mon, 21 Sep 2009, Hans Hagen wrote:

> > As I've written yesterday, I suppose, that the following syntax is wanted:
> > \getvariable{environment}{myVar}  but this does not work...
> 
> how does it look with:
> 
> local flag, value = argument:match("^%-+(.-)=(.-)$")
> 
> .+ -> .-

I've changed the line in mtxrun.lua and now it works fine, thanks Hans!

There is another occurrence of this line in luatools.lua (line 3426),
perhaps it should be changed there too?

Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: setting variable on cmd-line
  2009-09-21 19:43             ` Peter Münster
@ 2009-09-21 20:23               ` Hans Hagen
  0 siblings, 0 replies; 9+ messages in thread
From: Hans Hagen @ 2009-09-21 20:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Peter Münster wrote:
> On Mon, 21 Sep 2009, Hans Hagen wrote:
> 
>>> As I've written yesterday, I suppose, that the following syntax is wanted:
>>> \getvariable{environment}{myVar}  but this does not work...
>> how does it look with:
>>
>> local flag, value = argument:match("^%-+(.-)=(.-)$")
>>
>> .+ -> .-
> 
> I've changed the line in mtxrun.lua and now it works fine, thanks Hans!
> 
> There is another occurrence of this line in luatools.lua (line 3426),
> perhaps it should be changed there too?

will happen automatically with the next beta


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2009-09-21 20:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-18 13:31 setting variable on cmd-line Peter Münster
2009-09-20 19:46 ` Peter Münster
2009-09-20 21:24   ` luigi scarso
2009-09-21  5:39     ` Peter Münster
2009-09-21  5:52       ` luigi scarso
2009-09-21  6:16         ` Peter Münster
2009-09-21  8:05           ` Hans Hagen
2009-09-21 19:43             ` Peter Münster
2009-09-21 20:23               ` Hans Hagen

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).