ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Working with variables in Lua(TeX)
@ 2010-03-19 11:02 Jaroslav Hajtmar
  2010-03-19 13:57 ` Taco Hoekwater
  2010-03-19 15:24 ` Peter Münster
  0 siblings, 2 replies; 3+ messages in thread
From: Jaroslav Hajtmar @ 2010-03-19 11:02 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 486 bytes --]

Hello,
I am sorry, I am novice in this maillist and in Lua(TeX) too. I dont 
know if my problem isn't off topic.
My inquiry is here: Is it make possible with variables in Lua(TeX) do 
for similar "hara-kiri" like in Perl or PHP by this example?:

$a="b";
$$a="456";
print $b; # result 456

$varname="counter";
$varindex=1;
${"$varname$varindex"}=123;
print $counter1; # result 123

Is any alternative of this examples in Lua what should be  using in LuaTex??

thanks  Jaroslav Hajtmar


[-- Attachment #1.2: Type: text/html, Size: 870 bytes --]

[-- Attachment #2: Type: text/plain, Size: 486 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] 3+ messages in thread

* Re: Working with variables in Lua(TeX)
  2010-03-19 11:02 Working with variables in Lua(TeX) Jaroslav Hajtmar
@ 2010-03-19 13:57 ` Taco Hoekwater
  2010-03-19 15:24 ` Peter Münster
  1 sibling, 0 replies; 3+ messages in thread
From: Taco Hoekwater @ 2010-03-19 13:57 UTC (permalink / raw)
  To: hajtmar, mailing list for ConTeXt users

Jaroslav Hajtmar wrote:
> Hello,
> I am sorry, I am novice in this maillist and in Lua(TeX) too. I dont 
> know if my problem isn't off topic.
> My inquiry is here: Is it make possible with variables in Lua(TeX) do 
> for similar "hara-kiri" like in Perl or PHP by this example?:
> 
> $a="b";
> $$a="456";
> print $b; # result 456

There is no symbol dereferencing in lua. This is a good thing(tm),
in my opinion. If you want trickery like this, you have to resort
to loadstring (which is the lua equivalent of eval)

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] 3+ messages in thread

* Re: Working with variables in Lua(TeX)
  2010-03-19 11:02 Working with variables in Lua(TeX) Jaroslav Hajtmar
  2010-03-19 13:57 ` Taco Hoekwater
@ 2010-03-19 15:24 ` Peter Münster
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Münster @ 2010-03-19 15:24 UTC (permalink / raw)
  To: hajtmar, mailing list for ConTeXt users

On Fri, Mar 19 2010, Jaroslav Hajtmar wrote:

> $a="b";
> $$a="456";
> print $b; # result 456

No problem with tables:

testtab = {}
testtab.a = "b"
testtab[testtab.a] = 456
print(testtab.b)   -- result 456

Documentation about lua is here: http://www.lua.org/

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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

end of thread, other threads:[~2010-03-19 15:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-19 11:02 Working with variables in Lua(TeX) Jaroslav Hajtmar
2010-03-19 13:57 ` Taco Hoekwater
2010-03-19 15:24 ` Peter Münster

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