ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Some very simple cld - loading a module
@ 2023-08-18 15:30 Hamid,Idris
  2023-08-18 16:56 ` [NTG-context] " Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: Hamid,Idris @ 2023-08-18 15:30 UTC (permalink / raw)
  To: ntg-context


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

Dear gang,

The following, simple MWE gives an undefined control sequence error:

=======
% \usemodule[translate]
% \enableinputtranslation
\startluacode
    -- context.usemodule({translate})
    context.usemodule{translate}
    context.enableinputtranslation()
    context.darkgreen()
\stopluacode

\startTEXpage[offset=1em]

\translateinput[Hermes][Idris]

Hermes

\disableinputtranslation

Hermes

\stopTEXpage
=======
tex error       > tex error on line 14 in file ./test-luacode.tex: Undefined control sequence

<line 3.12>
    \translateinput
    [Hermes][Idris]
=======

The reason for the error is that the module is not being loaded. Toggling back to context syntax, of course, works.

Reference: ConTeXt Lua Documents by Hans Hagen, page 22. The following analogous code works:

\startluacode
context.startchapter{first}
\stopluacode

So how do we properly load the module from within a luacode environment?

Thank you in advance.

Best wishes
Idris

--
Professor Idris Samawi Hamid
Department of Philosophy
Colorado State University
Fort Collins, CO 80523

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

[-- Attachment #2: Type: text/plain, Size: 495 bytes --]

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Some very simple cld - loading a module
  2023-08-18 15:30 [NTG-context] Some very simple cld - loading a module Hamid,Idris
@ 2023-08-18 16:56 ` Wolfgang Schuster
  2023-08-18 20:32   ` Hamid,Idris
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2023-08-18 16:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Hamid,Idris

Hamid,Idris schrieb am 18.08.2023 um 17:30:
> Dear gang,
>
> The following, simple MWE gives an undefined control sequence error:
>
> =======
> % \usemodule[translate]
> % \enableinputtranslation
> \startluacode
>     -- context.usemodule({translate})
>     context.usemodule{translate}

context.usemodule({ "first" })

or

context.usemodule{ "first" }

>     context.enableinputtranslation()
>     context.darkgreen()
> \stopluacode
>
> \startTEXpage[offset=1em]
>
> \translateinput[Hermes][Idris]
>
> Hermes
>
> \disableinputtranslation
>
> Hermes
>
> \stopTEXpage
> =======
> tex error       > tex error on line 14 in file ./test-luacode.tex: 
> Undefined control sequence
>
> <line 3.12>
>     \translateinput
>     [Hermes][Idris]
> =======
>
> The reason for the error is that the module is not being loaded. 
> Toggling back to context syntax, of course, works.
>
> Reference: ConTeXt Lua Documents by Hans Hagen, page 22. The following 
> analogous code works:
>
> \startluacode
> context.startchapter{first}
> \stopluacode

It doesn't work or at least it does not what you expect, the examples in 
the manual pass strings ( "..." )
wherever text is expected while you pass a lua variable to the commands. 
Passing variables only work
when the variable itself refers to a string, e.g.

translate = "translate"

Wolfgang

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Some very simple cld - loading a module
  2023-08-18 16:56 ` [NTG-context] " Wolfgang Schuster
@ 2023-08-18 20:32   ` Hamid,Idris
  0 siblings, 0 replies; 3+ messages in thread
From: Hamid,Idris @ 2023-08-18 20:32 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Wolfgang Schuster


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

Wolfgang: Many thanks for the fix and for the detailed explanation, which was very helpful!

Best wishes
Idris

--
Professor Idris Samawi Hamid
Department of Philosophy
Colorado State University
Fort Collins, CO 80523
On Aug 18, 2023, 10:56 AM -0600, Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>, wrote:
** Caution: EXTERNAL Sender **

Hamid,Idris schrieb am 18.08.2023 um 17:30:
Dear gang,

The following, simple MWE gives an undefined control sequence error:

=======
% \usemodule[translate]
% \enableinputtranslation
\startluacode
-- context.usemodule({translate})
context.usemodule{translate}

context.usemodule({ "first" })

or

context.usemodule{ "first" }

context.enableinputtranslation()
context.darkgreen()
\stopluacode

\startTEXpage[offset=1em]

\translateinput[Hermes][Idris]

Hermes

\disableinputtranslation

Hermes

\stopTEXpage
=======
tex error > tex error on line 14 in file ./test-luacode.tex:
Undefined control sequence

<line 3.12>
\translateinput
[Hermes][Idris]
=======

The reason for the error is that the module is not being loaded.
Toggling back to context syntax, of course, works.

Reference: ConTeXt Lua Documents by Hans Hagen, page 22. The following
analogous code works:

\startluacode
context.startchapter{first}
\stopluacode

It doesn't work or at least it does not what you expect, the examples in
the manual pass strings ( "..." )
wherever text is expected while you pass a lua variable to the commands.
Passing variables only work
when the variable itself refers to a string, e.g.

translate = "translate"

Wolfgang


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

[-- Attachment #2: Type: text/plain, Size: 495 bytes --]

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2023-08-18 20:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-18 15:30 [NTG-context] Some very simple cld - loading a module Hamid,Idris
2023-08-18 16:56 ` [NTG-context] " Wolfgang Schuster
2023-08-18 20:32   ` Hamid,Idris

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