From: Jaroslav Hajtmar <hajtmar@gyza.cz>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Modules, namespaces, Luacode etc..
Date: Thu, 30 Sep 2010 20:40:29 +0200 [thread overview]
Message-ID: <4CA4D99D.4080005@gyza.cz> (raw)
Hello my wise masters of the Force and teachers of Jedi...
It seems that my first module (SCANCSV of scancsv.lua library of CTM in
Brejlov) work without any visible errors (without
documentation and with a junkyard yet), but I'm not sure whether is there a
hidden problem or future collisions. Therefore I have a few of questions
for
modules namespaces, luacode namespaces etc. I want to ask how relates a
namespace ConTeXt module with
namespace of Lua code, which is listed within this module and others
questions.
1. Is the namespace of Lua code independent of the namespace module?
2. If are ConTeXt macros defined in the module, are automatically in its
namespace?
3. Can both namespaces (module and Luacode) somehow connected?
4. What happens when I have two macros with the same name in two
different modules?
5. Can I call the macros of the same names in different namespaces
(diferent modules)?
6. Can I read about somewhere more?
7. I enclose below a minimal example of the module (I do not know why
there are some things) to comment or write yours comments and
suggestions, etc.
I'd like to start with something simpler, but this is the reality of our
Empire....
Thanks everyone for the advice or recommendations for the study.
Greetings
Jarda Hajtmar
My minimal example ..
% ************************** BEGIN MODULE
******************************************
%D \module
%D [ file=t-moduleexample,
%D version=2010.09.27,
%D title=\CONTEXT\ User Module,
%D subtitle=Module example,
%D author=Author Name,
%D date=\currentdate,
%D copyright=Copyright,
%D email=mailaddress@domain.com,
%D license=Public Domain]
%D \section{Title}
%D This is modul is intended for ...
%D The following option are availabe:
%D
%S B
%S Everything onwards is
%S skipped and does not
%S appear in the PDF.
%S E
\writestatus{loading}{ConTeXt User Module / Module example}
\unprotect
\startinterface all
\setinterfacevariable {moduleexample} {moduleexample}
\stopinterface
\definenamespace
[moduleexample]
[type=module,
comment=Module example,
version=1,
name=moduleexample,
style=yes,
command=yes,
setup=list,
parent=moduleexample]
\startluacode
thirddata = thirddata or { }
thirddata.moduleexample = {
gVar1='xxxx', -- comment
gVar2='yyyyy', -- comment
-- etc...
}
function thirddata.moduleexample.myfirstfunction(parameter)
local locvar=parameter
tex.print("Input parameter : "..locvar)
thirddata.moduleexample.gVar1=locvar
return locvar
end
function thirddata.moduleexample.mysecondfunction()
tex.print("Output parameter: "..thirddata.moduleexample.gVar1)
end
\stopluacode
\def\myfirstmodulemacro#1{\ctxlua{thirddata.moduleexample.myfirstfunction("#1")}}
\def\mysecondmodulemacro{\ctxlua{thirddata.moduleexample.mysecondfunction()}}
\protect \endinput
% ************************** END MODULE
******************************************
% ************************** BEGIN USING MODULE
******************************************
\usemodule[t-moduleexample]
\starttext
\myfirstmodulemacro{Hello World!}
\mysecondmodulemacro
\stoptext
% ************************** END USING MODULE
******************************************
___________________________________________________________________________________
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
___________________________________________________________________________________
next reply other threads:[~2010-09-30 18:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-30 18:40 Jaroslav Hajtmar [this message]
2010-09-30 18:53 ` Wolfgang Schuster
2010-10-01 7:51 ` Jaroslav Hajtmar
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=4CA4D99D.4080005@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).