ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Jaroslav Hajtmar <hajtmar@gyza.cz>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Expansion of TeX macros inside the Lua function
Date: Sun, 01 Aug 2010 18:00:02 +0200	[thread overview]
Message-ID: <4C559A02.5030408@gyza.cz> (raw)
In-Reply-To: <4C558DE8.7070600@wxs.nl>

Thanx very much to Hans.
I see that you understood what I meant. I expected something like this 
probably will not do.
I'll try to experiment according to your advice.

You ask why do I need? It is hard for me to explain in English why I 
need it.
Only shortly:
I prepared a series of Lua functions, that accesses data from a CSV file 
in very general level.
In fact I can in Luacycle print in ConTeXt (but in LuaLaTeX or LuaPlain 
too) any reports, forms, mail merge letters, etc.
The user creates a report (using data of row of the CSV table). The user 
can in report use TeX macros, that are automaticaly creating during 
browsing of the CSV file. Macro names are derived from Excel table 
columns (\ cA, \ cB, \ cC, ...) or are created under the header (first 
line) CSV table.

I had it working quite well, but I am trying now output from my 
applications to use as an input to the database module of Mojca Miklavec.
The problem is that output of my application appears in the one macro 
(printmacro \printacion or maybe better \lineaction because it contains 
the row data of the CSV table). Unfortunately, I have a macro in 
unexpanded form (as one token), because it constantly changes according 
to the contents of the current row of CSV table, but Mojca module 
requires several values separated by separators.

I hope at least someone can understand my bad English ... Sorry Taco :-) 
...

Thank you all for your patience with amateurs such as myself. I have 
great admiration for you all and I am privileged to be helping me.

Thanks Jaroslav





Dne 1.8.2010 17:08, Hans Hagen napsal(a):
> On 1-8-2010 11:45, Jaroslav Hajtmar wrote:
>
>> \ctxlua{pars('\printaction')}
>>
>> \blank[big]
>>
>> Example 3)
>>
>> The third example of my most interesting. Function parameter in 
>> example is
>> a TeX macro \backslash printaction which not expanded, respectively
>> expanded
>> only when I printing it to TeX. Parameter of function is still string
>> "\backslash printaction" in which it is futile to look for a comma
>> separator.
>> Comma not be found, although the content of macro face that is so. Is
>> there a
>> possibility for this case, as in some way to save to Lua variable
>> content of
>> macro (of course expanded)?
>>
>> \ctxlua{pars('\\printaction')}
>
> currently the tex parsing and expansion code is not available in 
> luatex (future versions might provide some introspection or expansion 
> code, but it's a hairy topic)
>
> Anyhow, given that \printaction is defined you can use the token 
> library to see what's in there (you then can sort of reconstruct the 
> content).
>
> Another approach is a two-step:
>
> function step_1(str) -- str = \whatever
>    tex.print("\ctxlua{step_2('",str,"')}")
> end
>
> It all depends on what you want to do. Why do you want to look into 
> \whatever?
>
> 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
___________________________________________________________________________________


      reply	other threads:[~2010-08-01 16:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-01  9:45 Jaroslav Hajtmar
2010-08-01 15:08 ` Hans Hagen
2010-08-01 16:00   ` Jaroslav Hajtmar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C559A02.5030408@gyza.cz \
    --to=hajtmar@gyza.cz \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).