* Using lua to define a macro with one optional parameter in brackets
@ 2015-07-08 9:05 Jaroslav Hajtmar
2015-07-08 10:07 ` Taco Hoekwater
0 siblings, 1 reply; 17+ messages in thread
From: Jaroslav Hajtmar @ 2015-07-08 9:05 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hello ConTeXist.
Within the one very complex problem I need to solve the following case.
I want using lua code to define a macro with one optional parameter in
brackets. I tried it using commands context.setgvalue, or find something
on the wiki
(http://wiki.contextgarden.net/System_Macros/Definitions_and_Assignments),
but each time I broke a tooth on it.
Can you, please, someone advise how something can be it done? Suffice
some reference to solve a similar problem.
Thanks Jaroslav Hajtmar
Here is my minimal example:
\starttext
\def\lastname{\dosingleempty\dolastname}
\def\dolastname[#1]{\iffirstargument #1\else nothing\fi}
\lastname
\lastname[Smith]
% Not working
% \ctxlua{
% context([[\def\firstname{\dosingleempty\dofirstname}]])
% context([[\def\dofirstname[#1]{\iffirstargument #1\else {nothing}\fi}]])
% }
%
% \firstname
%
% \firstname['Peter']
\stoptext
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-08 9:05 Using lua to define a macro with one optional parameter in brackets Jaroslav Hajtmar
@ 2015-07-08 10:07 ` Taco Hoekwater
2015-07-08 10:40 ` Jaroslav Hajtmar
2015-07-08 11:04 ` Jaroslav Hajtmar
0 siblings, 2 replies; 17+ messages in thread
From: Taco Hoekwater @ 2015-07-08 10:07 UTC (permalink / raw)
To: hajtmar, mailing list for ConTeXt users
> On 08 Jul 2015, at 11:05, Jaroslav Hajtmar <hajtmar@gyza.cz> wrote:
>
> Hello ConTeXist.
>
> Within the one very complex problem I need to solve the following case. I want using lua code to define a macro with one optional parameter in brackets.
Simplest solution I know is this:
\startluacode
interfaces.definecommand ('dolastname', {
arguments = { { "option", "string" } },
macro = function (opt_1)
if #opt_1>0 then context(opt_1) else context('nothing') end
end
})
interfaces.definecommand ('lastname', {
macro = function ()
context.dosingleempty()
context.dolastname()
end
})
\stopluacode
Best wishes,
Taco
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-08 10:07 ` Taco Hoekwater
@ 2015-07-08 10:40 ` Jaroslav Hajtmar
2015-07-08 11:04 ` Jaroslav Hajtmar
1 sibling, 0 replies; 17+ messages in thread
From: Jaroslav Hajtmar @ 2015-07-08 10:40 UTC (permalink / raw)
To: mailing list for ConTeXt users
Thanks Taco,
your solution helped me ... Based on initial tests, it seems that it
works correctly. I'll know more after thorough testing.
Once again, thank you many times.
Sincerely Jaroslav Hajtmar
Dne 8. 7. 2015 v 12:07 Taco Hoekwater napsal(a):
>> On 08 Jul 2015, at 11:05, Jaroslav Hajtmar <hajtmar@gyza.cz> wrote:
>>
>> Hello ConTeXist.
>>
>> Within the one very complex problem I need to solve the following case. I want using lua code to define a macro with one optional parameter in brackets.
> Simplest solution I know is this:
>
> \startluacode
> interfaces.definecommand ('dolastname', {
> arguments = { { "option", "string" } },
> macro = function (opt_1)
> if #opt_1>0 then context(opt_1) else context('nothing') end
> end
> })
> interfaces.definecommand ('lastname', {
> macro = function ()
> context.dosingleempty()
> context.dolastname()
> end
> })
> \stopluacode
>
> Best wishes,
> Taco
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-08 10:07 ` Taco Hoekwater
2015-07-08 10:40 ` Jaroslav Hajtmar
@ 2015-07-08 11:04 ` Jaroslav Hajtmar
2015-07-08 11:28 ` Taco Hoekwater
1 sibling, 1 reply; 17+ messages in thread
From: Jaroslav Hajtmar @ 2015-07-08 11:04 UTC (permalink / raw)
To: Taco Hoekwater, mailing list for ConTeXt users
Hi Taco.
full deployment is unfortunately not working.
Unfortunately I need to cycle create different macros whose names are
variable. At this moment I can not deal with this:
--- context.doxlsname() --- ?????
Thanx Jaroslav Hajtmar
here is another minimal example:
\starttext
\def\linepointer{5}
\def\csvcell[#1,#2]{cell #1,#2}
\directlua{
xlsname='A'
interfaces.definecommand ('do'..xlsname, {
arguments = { { "option", "string" } },
macro = function (opt_1)
if #opt_1>0 then
context('\\csvcell["'..xlsname..'",'..opt_1..']') else
context('\\csvcell["'..xlsname..'",\\linepointer]') end
end
})
interfaces.definecommand (xlsname, {
macro = function ()
context.dosingleempty()
--- context.doxlsname() --- ?????
end
})
}
\csvcell['Firstname',\linepointer]
\A
\A[5]
\stoptext
Dne 8. 7. 2015 v 12:07 Taco Hoekwater napsal(a):
> \startluacode
> interfaces.definecommand ('dolastname', {
> arguments = { { "option", "string" } },
> macro = function (opt_1)
> if #opt_1>0 then context(opt_1) else context('nothing') end
> end
> })
> interfaces.definecommand ('lastname', {
> macro = function ()
> context.dosingleempty()
> context.dolastname()
> end
> })
> \stopluacode
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-08 11:04 ` Jaroslav Hajtmar
@ 2015-07-08 11:28 ` Taco Hoekwater
2015-07-08 11:58 ` Jaroslav Hajtmar
0 siblings, 1 reply; 17+ messages in thread
From: Taco Hoekwater @ 2015-07-08 11:28 UTC (permalink / raw)
To: hajtmar; +Cc: mailing list for ConTeXt users
> On 08 Jul 2015, at 13:04, Jaroslav Hajtmar <hajtmar@gyza.cz> wrote:
>
> Hi Taco.
> full deployment is unfortunately not working.
>
> Unfortunately I need to cycle create different macros whose names are variable. At this moment I can not deal with this:
>
> --- context.doxlsname() --- ?????
context[‘do’..xlsname]()
> Thanx Jaroslav Hajtmar
>
> here is another minimal example:
>
>
>
> \starttext
>
>
> \def\linepointer{5}
>
> \def\csvcell[#1,#2]{cell #1,#2}
>
>
> \directlua{
> xlsname='A'
> interfaces.definecommand ('do'..xlsname, {
> arguments = { { "option", "string" } },
> macro = function (opt_1)
> if #opt_1>0 then context('\\csvcell["'..xlsname..'",'..opt_1..']') else context('\\csvcell["'..xlsname..'",\\linepointer]') end
> end
> })
> interfaces.definecommand (xlsname, {
> macro = function ()
> context.dosingleempty()
> --- context.doxlsname() --- ?????
> end
> })
> }
>
>
> \csvcell['Firstname',\linepointer]
>
>
> \A
>
> \A[5]
>
>
>
>
> \stoptext
>
>
>
> Dne 8. 7. 2015 v 12:07 Taco Hoekwater napsal(a):
>> \startluacode
>> interfaces.definecommand ('dolastname', {
>> arguments = { { "option", "string" } },
>> macro = function (opt_1)
>> if #opt_1>0 then context(opt_1) else context('nothing') end
>> end
>> })
>> interfaces.definecommand ('lastname', {
>> macro = function ()
>> context.dosingleempty()
>> context.dolastname()
>> end
>> })
>> \stopluacode
>
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-08 11:28 ` Taco Hoekwater
@ 2015-07-08 11:58 ` Jaroslav Hajtmar
2015-07-08 12:11 ` Taco Hoekwater
0 siblings, 1 reply; 17+ messages in thread
From: Jaroslav Hajtmar @ 2015-07-08 11:58 UTC (permalink / raw)
To: Taco Hoekwater; +Cc: mailing list for ConTeXt users
Thanx Taco for reply.
the minimal example see bellow not crashed, but \A macro is not created.
I don't Know in what could still be a problem. Example I am even more
minimalize
Thanx Jaroslav
\starttext
\directlua{
xlsname='A'
interfaces.definecommand ('do'..xlsname, {
arguments = { { "option", "string" } },
macro = function (opt_1)
if #opt_1>0 then context(opt_1) else context('nothing') end
end
})
interfaces.definecommand (xlsname, {
macro = function ()
context.dosingleempty()
context['do'..xlsname]()
end
})
}
% \A[5]
%
%
% \A
\stoptext
Dne 8. 7. 2015 v 13:28 Taco Hoekwater napsal(a):
>> On 08 Jul 2015, at 13:04, Jaroslav Hajtmar <hajtmar@gyza.cz> wrote:
>>
>> Hi Taco.
>> full deployment is unfortunately not working.
>>
>> Unfortunately I need to cycle create different macros whose names are variable. At this moment I can not deal with this:
>>
>> --- context.doxlsname() --- ?????
> context[‘do’..xlsname]()
>
>
>> Thanx Jaroslav Hajtmar
>>
>> here is another minimal example:
>>
>>
>>
>> \starttext
>>
>>
>> \def\linepointer{5}
>>
>> \def\csvcell[#1,#2]{cell #1,#2}
>>
>>
>> \directlua{
>> xlsname='A'
>> interfaces.definecommand ('do'..xlsname, {
>> arguments = { { "option", "string" } },
>> macro = function (opt_1)
>> if #opt_1>0 then context('\\csvcell["'..xlsname..'",'..opt_1..']') else context('\\csvcell["'..xlsname..'",\\linepointer]') end
>> end
>> })
>> interfaces.definecommand (xlsname, {
>> macro = function ()
>> context.dosingleempty()
>> --- context.doxlsname() --- ?????
>> end
>> })
>> }
>>
>>
>> \csvcell['Firstname',\linepointer]
>>
>>
>> \A
>>
>> \A[5]
>>
>>
>>
>>
>> \stoptext
>>
>>
>>
>> Dne 8. 7. 2015 v 12:07 Taco Hoekwater napsal(a):
>>> \startluacode
>>> interfaces.definecommand ('dolastname', {
>>> arguments = { { "option", "string" } },
>>> macro = function (opt_1)
>>> if #opt_1>0 then context(opt_1) else context('nothing') end
>>> end
>>> })
>>> interfaces.definecommand ('lastname', {
>>> macro = function ()
>>> context.dosingleempty()
>>> context.dolastname()
>>> end
>>> })
>>> \stopluacode
>
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-08 11:58 ` Jaroslav Hajtmar
@ 2015-07-08 12:11 ` Taco Hoekwater
2015-07-08 14:11 ` Jaroslav Hajtmar
0 siblings, 1 reply; 17+ messages in thread
From: Taco Hoekwater @ 2015-07-08 12:11 UTC (permalink / raw)
To: hajtmar; +Cc: mailing list for ConTeXt users
[-- Attachment #1: Type: text/plain, Size: 370 bytes --]
> On 08 Jul 2015, at 13:58, Jaroslav Hajtmar <hajtmar@gyza.cz> wrote:
>
> Thanx Taco for reply.
>
> the minimal example see bellow not crashed, but \A macro is not created.
> I don't Know in what could still be a problem. Example I am even more minimalize
It works for me after changing \directlua {} to \startluacode … \stopluacode
Best wishes,
Taco
[-- Attachment #2: cld-def-test.tex --]
[-- Type: application/octet-stream, Size: 405 bytes --]
\starttext
\startluacode
xlsname='A'
interfaces.definecommand ('do'..xlsname, {
arguments = { { "option", "string" } },
macro = function (opt_1)
if #opt_1>0 then context(opt_1) else context('nothing') end
end
})
interfaces.definecommand (xlsname, {
macro = function ()
context.dosingleempty()
context['do'..xlsname]()
end
})
\stopluacode
\A[5]
\A
\stoptext
[-- Attachment #3: Type: text/plain, Size: 2 bytes --]
[-- Attachment #4: Type: text/plain, Size: 485 bytes --]
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-08 12:11 ` Taco Hoekwater
@ 2015-07-08 14:11 ` Jaroslav Hajtmar
2015-07-08 18:54 ` Hans Hagen
0 siblings, 1 reply; 17+ messages in thread
From: Jaroslav Hajtmar @ 2015-07-08 14:11 UTC (permalink / raw)
To: Taco Hoekwater; +Cc: mailing list for ConTeXt users
Thanks Taco very much.
At this point, it really works in simple situations, but in the event
that this solution will incorporate into the existing system, then I
have big problems with expansion (values are not updated in macros). I
need more solutions using something like context.setgvalue, or at least
according to the following example. If they could incorporate the
remaining two definitions
ie
\def\simpleA {content when parameter is missing}
\def\complexA[#1]{parameter #1}
into luacode (probably encounter a problem with #), so it might work.
Can not think of anyone, how it could be done differently?
Thanks Jaroslav Hajtmar
Here is minimal example:
\ctxlua{
xlsname='A'
content='content when parameter is missing'
context([[\definecomplexorsimple\]]..xlsname)
%context([[\def\simple]]..xlsname..[[{]]..content..[[}]])
%context([[\def\complex]]..xlsname..'[#1]'..[[{Neco: #1}]])
}
\def\simpleA {content when parameter is missing}
\def\complexA[#1]{parameter #1}
\type{\A}: \A
\type{\A[5]}: \A[5]
\stoptext
Dne 8. 7. 2015 v 14:11 Taco Hoekwater napsal(a):
>> On 08 Jul 2015, at 13:58, Jaroslav Hajtmar <hajtmar@gyza.cz> wrote:
>>
>> Thanx Taco for reply.
>>
>> the minimal example see bellow not crashed, but \A macro is not created.
>> I don't Know in what could still be a problem. Example I am even more minimalize
> It works for me after changing \directlua {} to \startluacode … \stopluacode
>
> Best wishes,
> Taco
>
>
>
>
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-08 14:11 ` Jaroslav Hajtmar
@ 2015-07-08 18:54 ` Hans Hagen
2015-07-09 5:22 ` Jaroslav Hajtmar
0 siblings, 1 reply; 17+ messages in thread
From: Hans Hagen @ 2015-07-08 18:54 UTC (permalink / raw)
To: ntg-context
On 7/8/2015 4:11 PM, Jaroslav Hajtmar wrote:
> Thanks Taco very much.
>
> At this point, it really works in simple situations, but in the event
> that this solution will incorporate into the existing system, then I
> have big problems with expansion (values are not updated in macros). I
> need more solutions using something like context.setgvalue, or at least
> according to the following example. If they could incorporate the
> remaining two definitions
> ie
> \def\simpleA {content when parameter is missing}
> \def\complexA[#1]{parameter #1}
>
> into luacode (probably encounter a problem with #), so it might work.
> Can not think of anyone, how it could be done differently?
> Thanks Jaroslav Hajtmar
>
> Here is minimal example:
>
> \ctxlua{
> xlsname='A'
> content='content when parameter is missing'
> context([[\definecomplexorsimple\]]..xlsname)
> %context([[\def\simple]]..xlsname..[[{]]..content..[[}]])
> %context([[\def\complex]]..xlsname..'[#1]'..[[{Neco: #1}]])
> }
>
> \def\simpleA {content when parameter is missing}
> \def\complexA[#1]{parameter #1}
why don't you define these commands at the tex level
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-08 18:54 ` Hans Hagen
@ 2015-07-09 5:22 ` Jaroslav Hajtmar
2015-07-09 7:25 ` Taco Hoekwater
2015-07-09 9:07 ` Hans Hagen
0 siblings, 2 replies; 17+ messages in thread
From: Jaroslav Hajtmar @ 2015-07-09 5:22 UTC (permalink / raw)
To: ntg-context
Hi Hans.
Only for explanation of my (maybe) crazy request:
I can not at this level TeX macros to create, because it creates
automatically after opening the CSV file. Although I tried to start
creating something with \ csname \ endcsname etc. but my experiments
with this method were never successful. In addition with TeX probably I
can not work as well as with Lua (for things which in this case I need
ie. at low level). Given that I have a CSV file loaded in global
variables and header information at my disposal, I Lua everything you
need me to do what I need. The problem is that the macros created in Lua
I sometimes do not work as well when I create TeX (during the cycle will
automatically fall short values). I have a particularly bad experience
in this regard with the construction, he sent Taco.
Simplified version of "interfaces.definecommand" construction does not
in my way of processing the results of what I expected.
Module which at the moment I work (in collaboration with Pablo
Rodriguez) at the moment is very complex and extensive, and already it
slowly begin to lose myself :-), so I try to get any information from
the conference.
Thank you and also to other counselors too at the conference for their
cooperation in solve my problems.
Jaroslav Hajtmar
Dne 8. 7. 2015 v 20:54 Hans Hagen napsal(a):
> On 7/8/2015 4:11 PM, Jaroslav Hajtmar wrote:
>> Thanks Taco very much.
>>
>> At this point, it really works in simple situations, but in the event
>> that this solution will incorporate into the existing system, then I
>> have big problems with expansion (values are not updated in macros). I
>> need more solutions using something like context.setgvalue, or at least
>> according to the following example. If they could incorporate the
>> remaining two definitions
>> ie
>> \def\simpleA {content when parameter is missing}
>> \def\complexA[#1]{parameter #1}
>>
>> into luacode (probably encounter a problem with #), so it might work.
>> Can not think of anyone, how it could be done differently?
>> Thanks Jaroslav Hajtmar
>>
>> Here is minimal example:
>>
>> \ctxlua{
>> xlsname='A'
>> content='content when parameter is missing'
>> context([[\definecomplexorsimple\]]..xlsname)
>> %context([[\def\simple]]..xlsname..[[{]]..content..[[}]])
>> %context([[\def\complex]]..xlsname..'[#1]'..[[{Neco: #1}]])
>> }
>>
>> \def\simpleA {content when parameter is missing}
>> \def\complexA[#1]{parameter #1}
>
> why don't you define these commands at the tex level
>
> Hans
>
> -----------------------------------------------------------------
> Hans Hagen | PRAGMA ADE
> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | voip: 087 875 68 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 : http://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-09 5:22 ` Jaroslav Hajtmar
@ 2015-07-09 7:25 ` Taco Hoekwater
2015-07-09 9:07 ` Hans Hagen
1 sibling, 0 replies; 17+ messages in thread
From: Taco Hoekwater @ 2015-07-09 7:25 UTC (permalink / raw)
To: hajtmar, mailing list for ConTeXt users
Hi,
> On 09 Jul 2015, at 07:22, Jaroslav Hajtmar <hajtmar@gyza.cz> wrote:
>
> The problem is that the macros created in Lua I sometimes do not work as well when I create TeX (during the cycle will automatically fall short values). I have a particularly bad experience in this regard with the construction, he sent Taco.
>
> Simplified version of "interfaces.definecommand" construction does not in my way of processing the results of what I expected.
Perhaps interfaces.definecommand could be extended with a way to do global definitions?
Best wishes,
Taco
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-09 5:22 ` Jaroslav Hajtmar
2015-07-09 7:25 ` Taco Hoekwater
@ 2015-07-09 9:07 ` Hans Hagen
2015-07-09 15:05 ` Jaroslav Hajtmar
1 sibling, 1 reply; 17+ messages in thread
From: Hans Hagen @ 2015-07-09 9:07 UTC (permalink / raw)
To: ntg-context
On 7/9/2015 7:22 AM, Jaroslav Hajtmar wrote:
> Hi Hans.
> Only for explanation of my (maybe) crazy request:
> I can not at this level TeX macros to create, because it creates
> automatically after opening the CSV file. Although I tried to start
> creating something with \ csname \ endcsname etc. but my experiments
> with this method were never successful. In addition with TeX probably I
> can not work as well as with Lua (for things which in this case I need
> ie. at low level). Given that I have a CSV file loaded in global
> variables and header information at my disposal, I Lua everything you
> need me to do what I need. The problem is that the macros created in Lua
> I sometimes do not work as well when I create TeX (during the cycle will
> automatically fall short values). I have a particularly bad experience
> in this regard with the construction, he sent Taco.
>
> Simplified version of "interfaces.definecommand" construction does not
> in my way of processing the results of what I expected.
interfaces.setmacro("name","value")
> Module which at the moment I work (in collaboration with Pablo
> Rodriguez) at the moment is very complex and extensive, and already it
> slowly begin to lose myself :-), so I try to get any information from
> the conference.
> Thank you and also to other counselors too at the conference for their
> cooperation in solve my problems.
>
> Jaroslav Hajtmar
>
>
>
>
> Dne 8. 7. 2015 v 20:54 Hans Hagen napsal(a):
>> On 7/8/2015 4:11 PM, Jaroslav Hajtmar wrote:
>>> Thanks Taco very much.
>>>
>>> At this point, it really works in simple situations, but in the event
>>> that this solution will incorporate into the existing system, then I
>>> have big problems with expansion (values are not updated in macros). I
>>> need more solutions using something like context.setgvalue, or at least
>>> according to the following example. If they could incorporate the
>>> remaining two definitions
>>> ie
>>> \def\simpleA {content when parameter is missing}
>>> \def\complexA[#1]{parameter #1}
>>>
>>> into luacode (probably encounter a problem with #), so it might work.
>>> Can not think of anyone, how it could be done differently?
>>> Thanks Jaroslav Hajtmar
>>>
>>> Here is minimal example:
>>>
>>> \ctxlua{
>>> xlsname='A'
>>> content='content when parameter is missing'
>>> context([[\definecomplexorsimple\]]..xlsname)
>>> %context([[\def\simple]]..xlsname..[[{]]..content..[[}]])
>>> %context([[\def\complex]]..xlsname..'[#1]'..[[{Neco: #1}]])
>>> }
>>>
>>> \def\simpleA {content when parameter is missing}
>>> \def\complexA[#1]{parameter #1}
>>
>> why don't you define these commands at the tex level
>>
>> Hans
>>
>> -----------------------------------------------------------------
>> Hans Hagen | PRAGMA ADE
>> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>> tel: 038 477 53 69 | voip: 087 875 68 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 : http://foundry.supelec.fr/projects/contextrev/
>> wiki : http://contextgarden.net
>> ___________________________________________________________________________________
>>
>
> ___________________________________________________________________________________
>
> 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 : http://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___________________________________________________________________________________
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-09 9:07 ` Hans Hagen
@ 2015-07-09 15:05 ` Jaroslav Hajtmar
2015-07-09 15:24 ` Hans Hagen
0 siblings, 1 reply; 17+ messages in thread
From: Jaroslav Hajtmar @ 2015-07-09 15:05 UTC (permalink / raw)
To: ntg-context
Thanx to Hans and Taco too,
ad Taco) ala Perhaps interfaces.definecommand could be extended with a
way to do global definitions?
Indeed it seems to me. Changes in lua code does not affect the results
in ConTeXt.
ad Hans) interfaces.setmacro("name","value")
Thanx, II tried to use it, but somehow I can not realize what I wanted.
Not available somewhere a minimal example? I tried to scan codes in the
folder with the installation of ConTeXt, but I never encountered a
working example of where you could bounce.
Thanks Jaroslav Hajtmar
Dne 9. 7. 2015 v 11:07 Hans Hagen napsal(a):
> On 7/9/2015 7:22 AM, Jaroslav Hajtmar wrote:
>> Hi Hans.
>> Only for explanation of my (maybe) crazy request:
>> I can not at this level TeX macros to create, because it creates
>> automatically after opening the CSV file. Although I tried to start
>> creating something with \ csname \ endcsname etc. but my experiments
>> with this method were never successful. In addition with TeX probably I
>> can not work as well as with Lua (for things which in this case I need
>> ie. at low level). Given that I have a CSV file loaded in global
>> variables and header information at my disposal, I Lua everything you
>> need me to do what I need. The problem is that the macros created in Lua
>> I sometimes do not work as well when I create TeX (during the cycle will
>> automatically fall short values). I have a particularly bad experience
>> in this regard with the construction, he sent Taco.
>>
>> Simplified version of "interfaces.definecommand" construction does not
>> in my way of processing the results of what I expected.
>
> interfaces.setmacro("name","value")
>
>> Module which at the moment I work (in collaboration with Pablo
>> Rodriguez) at the moment is very complex and extensive, and already it
>> slowly begin to lose myself :-), so I try to get any information from
>> the conference.
>> Thank you and also to other counselors too at the conference for their
>> cooperation in solve my problems.
>>
>> Jaroslav Hajtmar
>>
>>
>>
>>
>> Dne 8. 7. 2015 v 20:54 Hans Hagen napsal(a):
>>> On 7/8/2015 4:11 PM, Jaroslav Hajtmar wrote:
>>>> Thanks Taco very much.
>>>>
>>>> At this point, it really works in simple situations, but in the event
>>>> that this solution will incorporate into the existing system, then I
>>>> have big problems with expansion (values are not updated in macros). I
>>>> need more solutions using something like context.setgvalue, or at
>>>> least
>>>> according to the following example. If they could incorporate the
>>>> remaining two definitions
>>>> ie
>>>> \def\simpleA {content when parameter is missing}
>>>> \def\complexA[#1]{parameter #1}
>>>>
>>>> into luacode (probably encounter a problem with #), so it might work.
>>>> Can not think of anyone, how it could be done differently?
>>>> Thanks Jaroslav Hajtmar
>>>>
>>>> Here is minimal example:
>>>>
>>>> \ctxlua{
>>>> xlsname='A'
>>>> content='content when parameter is missing'
>>>> context([[\definecomplexorsimple\]]..xlsname)
>>>> %context([[\def\simple]]..xlsname..[[{]]..content..[[}]])
>>>> %context([[\def\complex]]..xlsname..'[#1]'..[[{Neco: #1}]])
>>>> }
>>>>
>>>> \def\simpleA {content when parameter is missing}
>>>> \def\complexA[#1]{parameter #1}
>>>
>>> why don't you define these commands at the tex level
>>>
>>> Hans
>>>
>>> -----------------------------------------------------------------
>>> Hans Hagen | PRAGMA ADE
>>> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>>> tel: 038 477 53 69 | voip: 087 875 68 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 : http://foundry.supelec.fr/projects/contextrev/
>>> wiki : http://contextgarden.net
>>> ___________________________________________________________________________________
>>>
>>>
>>
>> ___________________________________________________________________________________
>>
>>
>> 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 : http://foundry.supelec.fr/projects/contextrev/
>> wiki : http://contextgarden.net
>> ___________________________________________________________________________________
>>
>
>
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-09 15:05 ` Jaroslav Hajtmar
@ 2015-07-09 15:24 ` Hans Hagen
2015-07-10 20:40 ` Jaroslav Hajtmar
0 siblings, 1 reply; 17+ messages in thread
From: Hans Hagen @ 2015-07-09 15:24 UTC (permalink / raw)
To: ntg-context
On 7/9/2015 5:05 PM, Jaroslav Hajtmar wrote:
> Thanx to Hans and Taco too,
>
> ad Taco) ala Perhaps interfaces.definecommand could be extended with a
> way to do global definitions?
> Indeed it seems to me. Changes in lua code does not affect the results
> in ConTeXt.
>
> ad Hans) interfaces.setmacro("name","value")
>
> Thanx, II tried to use it, but somehow I can not realize what I wanted.
> Not available somewhere a minimal example? I tried to scan codes in the
> folder with the installation of ConTeXt, but I never encountered a
> working example of where you could bounce.
> Thanks Jaroslav Hajtmar
\starttext
\startluacode
interfaces.setmacro("foo","bar")
\stopluacode
\foo
\start
\startluacode
interfaces.setmacro("foo","foo","global")
\stopluacode
\stop
\foo
\stoptext
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-09 15:24 ` Hans Hagen
@ 2015-07-10 20:40 ` Jaroslav Hajtmar
0 siblings, 0 replies; 17+ messages in thread
From: Jaroslav Hajtmar @ 2015-07-10 20:40 UTC (permalink / raw)
To: ntg-context
Thanks Hans.
At this moment, it works fine. For me it is quite essential novelty and
it is very much handy for me.
It seems that works only in the standalone version because version in
TeXlive 2014 version it tells an error message (but does not matter on
it). I want to even ask how you can write a macro with one or more
parameters?
Now the parameter in square brackets displayed together with the
contents of the macro. You can do this at all? It would get any minimal
example?
Thanks again for your support.
Jaroslav Hajtmar
Dne 9. 7. 2015 v 17:24 Hans Hagen napsal(a):
> On 7/9/2015 5:05 PM, Jaroslav Hajtmar wrote:
>> Thanx to Hans and Taco too,
>>
>> ad Taco) ala Perhaps interfaces.definecommand could be extended with a
>> way to do global definitions?
>> Indeed it seems to me. Changes in lua code does not affect the results
>> in ConTeXt.
>>
>> ad Hans) interfaces.setmacro("name","value")
>>
>> Thanx, II tried to use it, but somehow I can not realize what I wanted.
>> Not available somewhere a minimal example? I tried to scan codes in the
>> folder with the installation of ConTeXt, but I never encountered a
>> working example of where you could bounce.
>> Thanks Jaroslav Hajtmar
>
> \starttext
>
> \startluacode
> interfaces.setmacro("foo","bar")
> \stopluacode
>
> \foo
>
> \start
> \startluacode
> interfaces.setmacro("foo","foo","global")
> \stopluacode
> \stop
>
> \foo
>
> \stoptext
>
> -----------------------------------------------------------------
> Hans Hagen | PRAGMA ADE
> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | voip: 087 875 68 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 : http://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
2015-07-13 13:04 Jaroslav Hajtmar
@ 2015-07-13 14:14 ` Hans Hagen
0 siblings, 0 replies; 17+ messages in thread
From: Hans Hagen @ 2015-07-13 14:14 UTC (permalink / raw)
To: ntg-context
On 7/13/2015 3:04 PM, Jaroslav Hajtmar wrote:
> Thanks Hans.
> At this moment, it works fine. For me it is quite essential novelty and
> it is very much handy for me.
> It seems that works only in the standalone version because version in
> TeXlive 2014 version it tells an error message (but does not matter on
> it). I want to even ask how you can write a macro with one or more
> parameters?
> Now the parameter in square brackets displayed together with the
> contents of the macro. You can do this at all? It would get any minimal
> example?
i would not do that in lua but in tex and load a module with those macros
much less hassle
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Using lua to define a macro with one optional parameter in brackets
@ 2015-07-13 13:04 Jaroslav Hajtmar
2015-07-13 14:14 ` Hans Hagen
0 siblings, 1 reply; 17+ messages in thread
From: Jaroslav Hajtmar @ 2015-07-13 13:04 UTC (permalink / raw)
To: mailing list for ConTeXt users
Thanks Hans.
At this moment, it works fine. For me it is quite essential novelty and
it is very much handy for me.
It seems that works only in the standalone version because version in
TeXlive 2014 version it tells an error message (but does not matter on
it). I want to even ask how you can write a macro with one or more
parameters?
Now the parameter in square brackets displayed together with the
contents of the macro. You can do this at all? It would get any minimal
example?
Thanks again for your support.
Jaroslav Hajtmar
Dne 9. 7. 2015 v 17:24 Hans Hagen napsal(a):
> On 7/9/2015 5:05 PM, Jaroslav Hajtmar wrote:
>> Thanx to Hans and Taco too,
>>
>> ad Taco) ala Perhaps interfaces.definecommand could be extended with a
>> way to do global definitions?
>> Indeed it seems to me. Changes in lua code does not affect the results
>> in ConTeXt.
>>
>> ad Hans) interfaces.setmacro("name","value")
>>
>> Thanx, II tried to use it, but somehow I can not realize what I wanted.
>> Not available somewhere a minimal example? I tried to scan codes in the
>> folder with the installation of ConTeXt, but I never encountered a
>> working example of where you could bounce.
>> Thanks Jaroslav Hajtmar
>
> \starttext
>
> \startluacode
> interfaces.setmacro("foo","bar")
> \stopluacode
>
> \foo
>
> \start
> \startluacode
> interfaces.setmacro("foo","foo","global")
> \stopluacode
> \stop
>
> \foo
>
> \stoptext
>
> -----------------------------------------------------------------
> Hans Hagen | PRAGMA ADE
> Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
> tel: 038 477 53 69 | voip: 087 875 68 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 : http://foundry.supelec.fr/projects/contextrev/
> wiki : http://contextgarden.net
> ___________________________________________________________________________________
>
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
___________________________________________________________________________________
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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2015-07-13 14:14 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-08 9:05 Using lua to define a macro with one optional parameter in brackets Jaroslav Hajtmar
2015-07-08 10:07 ` Taco Hoekwater
2015-07-08 10:40 ` Jaroslav Hajtmar
2015-07-08 11:04 ` Jaroslav Hajtmar
2015-07-08 11:28 ` Taco Hoekwater
2015-07-08 11:58 ` Jaroslav Hajtmar
2015-07-08 12:11 ` Taco Hoekwater
2015-07-08 14:11 ` Jaroslav Hajtmar
2015-07-08 18:54 ` Hans Hagen
2015-07-09 5:22 ` Jaroslav Hajtmar
2015-07-09 7:25 ` Taco Hoekwater
2015-07-09 9:07 ` Hans Hagen
2015-07-09 15:05 ` Jaroslav Hajtmar
2015-07-09 15:24 ` Hans Hagen
2015-07-10 20:40 ` Jaroslav Hajtmar
2015-07-13 13:04 Jaroslav Hajtmar
2015-07-13 14:14 ` 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).