* calling a function with complex parameters
@ 2008-12-07 22:34 Michail Vidiassov
2008-12-08 8:37 ` Taco Hoekwater
0 siblings, 1 reply; 2+ messages in thread
From: Michail Vidiassov @ 2008-12-07 22:34 UTC (permalink / raw)
To: mailing list for ConTeXt users
Dear All,
I need to fill a lua table with data, and some values may be tables.
How to supply that data from ConTeXt?
The most straightforward way is to make user fill a string with lua code
of table initiaiser and then use "loadstring".
In this case the syntax is laconic, but resilence in case of errors is zero.
The other way is to have the user to call series of functions, building
the complex structure from ground up by making basic stuctures and adding
them to final structure one by one. In this case the passed parameters can
be scrutinized for correctness, but multiple calls like "addsmthtosmth",
"setsmthinsmth" will make the result uneasy to read, to say nothing of
writing.
What is considered kosher in ConTeXt?
Where can I found examples?
Sincerely, Michail
PS. data that has to be passed to function will look like (example is not lua):
--------------
name = "3D surface";
toolbar = TRUE; // display 3D toolbar
tree = TRUE; // display model tree
views = (
{
name = "DefaultView"; // first view (default)
projection = {
perspective = TRUE; // Perspective projection
aac = 2.5; // View angle
};
camera = { // Camera position, see movie15 manual for explaination
coo = [ 0, 0, 0 ]; // Center of orbit - where the camera are pointed to
c2c = [ 0, 0, 1 ]; // vector from coo directed to camera
rot = [40, 0,60 ]; // rotatations of vector from coo directed to camera around Ox, Oy, Oz
roo = 50; // distance from coo to camera
roll = 0; // camera rotation angle
};
bg = [ 1.0, 1.0, 1.0 ]; // Background color
lights = "CAD"; // Lighting scheme
nodes = ( ( "xlabel", 1.0, TRUE ), ( "ylabel", 1.0, TRUE ), ("Small box", 1.0, TRUE) );
},
{
name = "CrossView"; // view with a crossection
projection = {
perspective = TRUE; // Perspective projection
aac = 2.5; // View angle
};
camera = { // Camera position, see movie15 manual for explaination
coo = [ 0, 0, 0 ]; // Center of orbit - where the camera are pointed to
c2c = [-1,-1, 0 ]; // vector from coo directed to camera
roo = 50; // distance from coo to camera
roll = 0; // camera rotation angle
crossection = {
point = [ 0, 0, 0 ];
normal = [ -1, -1, -1 ];
intersection = TRUE;
transparent = FALSE;
};
bg = [ 1.0, 1.0, 1.0 ]; // Background color
lights = "CAD"; // Lighting scheme
nodes = ( ( "xlabel", 1.0, TRUE ), ( "ylabel", 1.0, TRUE ), ("Small box", 1.0, TRUE) );
}
}
--------------
___________________________________________________________________________________
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 : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: calling a function with complex parameters
2008-12-07 22:34 calling a function with complex parameters Michail Vidiassov
@ 2008-12-08 8:37 ` Taco Hoekwater
0 siblings, 0 replies; 2+ messages in thread
From: Taco Hoekwater @ 2008-12-08 8:37 UTC (permalink / raw)
To: mailing list for ConTeXt users
Michail Vidiassov wrote:
> Dear All,
>
> I need to fill a lua table with data, and some values may be tables.
> How to supply that data from ConTeXt?
> The most straightforward way is to make user fill a string with lua code
> of table initiaiser and then use "loadstring".
That is probably what I would do. But if that was too error-prone,
I would most likely write a small syntax of my own and parse it
with lpeg or use an xml-based format.
Personally, I find api-based data interfaces clumsy and at least as
error prone as syntax-based ones.
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 : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-12-08 8:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-07 22:34 calling a function with complex parameters Michail Vidiassov
2008-12-08 8:37 ` Taco Hoekwater
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).