![](https://secure.gravatar.com/avatar/cedc4d83943006afe3994fb0a0455f82.jpg?s=120&d=mm&r=g)
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/
![](https://secure.gravatar.com/avatar/cedc4d83943006afe3994fb0a0455f82.jpg?s=120&d=mm&r=g)
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/
![](https://secure.gravatar.com/avatar/386a116d129cdc597f2bb6210bbaff7a.jpg?s=120&d=mm&r=g)
On Sun, Sep 20, 2009 at 9:46 PM, Peter Münster
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
![](https://secure.gravatar.com/avatar/cedc4d83943006afe3994fb0a0455f82.jpg?s=120&d=mm&r=g)
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/
![](https://secure.gravatar.com/avatar/386a116d129cdc597f2bb6210bbaff7a.jpg?s=120&d=mm&r=g)
On Mon, Sep 21, 2009 at 7:39 AM, Peter Münster
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
![](https://secure.gravatar.com/avatar/cedc4d83943006afe3994fb0a0455f82.jpg?s=120&d=mm&r=g)
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/
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
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 -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/cedc4d83943006afe3994fb0a0455f82.jpg?s=120&d=mm&r=g)
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/
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
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 -----------------------------------------------------------------
participants (3)
-
Hans Hagen
-
luigi scarso
-
Peter Münster