ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Re: Making a template, defining a macro
@ 2008-07-31 13:59 Demián Gutierrez
  0 siblings, 0 replies; 3+ messages in thread
From: Demián Gutierrez @ 2008-07-31 13:59 UTC (permalink / raw)
  To: ntg-context

Thanks a million! Works perfect :-)

Wolfgang Schuster wrote:
> On Thu, Jul 31, 2008 at 1:18 AM, Demián Gutierrez  
> <dmi@minotauro.com.ve> wrote:
>> Hi,
>>
>> I have to prepare a template to typeset a document that will have a
>> lot of tables of similar kinds repeated across the document. I want to
>> put that tables in some kind of templates, so I can use those
>> templates over and over. So the idea is to hide to the authors all the
>> format details behind the template allowing them to focus on the data
>> that has to be filled in those tables (which is the important thing).
>>
>> So, I would like to define some macros, that allows me to do something like:
>>
>> \starttableX
>>   \startSomeField
>>   Some Field Value...
>>   \stopSomeField
>>
>>   \startOtherField
>>   Other Field Value...
>>   \stopOtherField
>> \stoptableX
>>
>> And the result, should be a table like this:
>>
>> | Some Field Label:  | Some Field Value...  |
>> | Other Field Label: | Other Field Value... |
>>
>> That way I define a template for each table type I'll have in the document.
>>
>> I'm not having trouble with the tables, but with the macro definition,
>> this is my approximation of what I want (which does not work):
>>
>> \startsetups crudmain
>>   \long\def\startguiname #1  
>> \stopguiname{\setvariables[crudmain][guiname=#1]}
>>   \long\def\startclassname #1
>> \stopclassname{\setvariables[crudmain][classname=#1]}
>>
>> GUI Name: \getvariable{crudmain}{guiname}
>> Class Name: \getvariable{crudmain}{classname}
>> \stopsetups
>>
>> \definestartstop[crudmain][commands=\setups{crudmain}]
>>
>> \startcrudmain
>>   \startguiname
>>   Some name here...
>>   \stopguiname
>>   \startclassname
>>   Other name here...
>>   \stopclassname
>> \stopcrudmain
>>
>> At this point I'm getting this error:
>>
>> ! Use of \startguiname doesn't match its definition.
>>
>> I want the \long\def\startguiname inside the \startsetups /
>> \stopsetups to be sure that it will only be called inside the
>> \startcrudmain / \stopcrudmain (Cause other tables of different types
>> may have fields with the same name). But even considering the previous
>> point, if I move the \long\def\startguiname outside the \startsetups /
>> \stopsetups definition it does not works, because the
>> \getvariable{crudmain}{guiname} just returns blank.
>>
>> So is it possible to do what I want or something similar? What would
>> be a good way to do it? Any advice on the code I've already written?
>> This is really getting me crazy, cause context is not like any other
>> programming language I'm used to use ;-)
>
> \def\startcrudmain
>   {\bgroup
>    \def\startguiname##1\stopguiname
>      {\setvalue{crudmain:guiname}{##1}}%
>    \def\startclassname##1\stopclassname
>      {\setvalue{crudmain:classname}{##1}}}
>
> \def\stopcrudmain
>   {\bTABLE[frame=off]%
>    \bTR
>      \bTD GUI Name: \eTD
>      \bTD \getvalue{crudmain:guiname} \eTD
>    \eTR
>    \bTR
>      \bTD Class Name: \eTD
>      \bTD \getvalue{crudmain:classname} \eTD
>    \eTR
>    \eTABLE
>    \egroup}
>
> \starttext
>
> \startcrudmain
>   \startguiname
>   Some name here...
>   \stopguiname
>   \startclassname
>   Other name here...
>   \stopclassname
> \stopcrudmain
>
> \stoptext
>
> Wolfgang
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>
>


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

* Re: Making a template, defining a macro
  2008-07-30 23:18 Demián Gutierrez
@ 2008-07-31  6:37 ` Wolfgang Schuster
  0 siblings, 0 replies; 3+ messages in thread
From: Wolfgang Schuster @ 2008-07-31  6:37 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Thu, Jul 31, 2008 at 1:18 AM, Demián Gutierrez <dmi@minotauro.com.ve> wrote:
> Hi,
>
> I have to prepare a template to typeset a document that will have a
> lot of tables of similar kinds repeated across the document. I want to
> put that tables in some kind of templates, so I can use those
> templates over and over. So the idea is to hide to the authors all the
> format details behind the template allowing them to focus on the data
> that has to be filled in those tables (which is the important thing).
>
> So, I would like to define some macros, that allows me to do something like:
>
> \starttableX
>   \startSomeField
>   Some Field Value...
>   \stopSomeField
>
>   \startOtherField
>   Other Field Value...
>   \stopOtherField
> \stoptableX
>
> And the result, should be a table like this:
>
> | Some Field Label:  | Some Field Value...  |
> | Other Field Label: | Other Field Value... |
>
> That way I define a template for each table type I'll have in the document.
>
> I'm not having trouble with the tables, but with the macro definition,
> this is my approximation of what I want (which does not work):
>
> \startsetups crudmain
>   \long\def\startguiname #1 \stopguiname{\setvariables[crudmain][guiname=#1]}
>   \long\def\startclassname #1
> \stopclassname{\setvariables[crudmain][classname=#1]}
>
> GUI Name: \getvariable{crudmain}{guiname}
> Class Name: \getvariable{crudmain}{classname}
> \stopsetups
>
> \definestartstop[crudmain][commands=\setups{crudmain}]
>
> \startcrudmain
>   \startguiname
>   Some name here...
>   \stopguiname
>   \startclassname
>   Other name here...
>   \stopclassname
> \stopcrudmain
>
> At this point I'm getting this error:
>
> ! Use of \startguiname doesn't match its definition.
>
> I want the \long\def\startguiname inside the \startsetups /
> \stopsetups to be sure that it will only be called inside the
> \startcrudmain / \stopcrudmain (Cause other tables of different types
> may have fields with the same name). But even considering the previous
> point, if I move the \long\def\startguiname outside the \startsetups /
> \stopsetups definition it does not works, because the
> \getvariable{crudmain}{guiname} just returns blank.
>
> So is it possible to do what I want or something similar? What would
> be a good way to do it? Any advice on the code I've already written?
> This is really getting me crazy, cause context is not like any other
> programming language I'm used to use ;-)

\def\startcrudmain
  {\bgroup
   \def\startguiname##1\stopguiname
     {\setvalue{crudmain:guiname}{##1}}%
   \def\startclassname##1\stopclassname
     {\setvalue{crudmain:classname}{##1}}}

\def\stopcrudmain
  {\bTABLE[frame=off]%
   \bTR
     \bTD GUI Name: \eTD
     \bTD \getvalue{crudmain:guiname} \eTD
   \eTR
   \bTR
     \bTD Class Name: \eTD
     \bTD \getvalue{crudmain:classname} \eTD
   \eTR
   \eTABLE
   \egroup}

\starttext

\startcrudmain
  \startguiname
  Some name here...
  \stopguiname
  \startclassname
  Other name here...
  \stopclassname
\stopcrudmain

\stoptext

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

* Making a template, defining a macro
@ 2008-07-30 23:18 Demián Gutierrez
  2008-07-31  6:37 ` Wolfgang Schuster
  0 siblings, 1 reply; 3+ messages in thread
From: Demián Gutierrez @ 2008-07-30 23:18 UTC (permalink / raw)
  To: ntg-context

Hi,

I have to prepare a template to typeset a document that will have a  
lot of tables of similar kinds repeated across the document. I want to  
put that tables in some kind of templates, so I can use those  
templates over and over. So the idea is to hide to the authors all the  
format details behind the template allowing them to focus on the data  
that has to be filled in those tables (which is the important thing).

So, I would like to define some macros, that allows me to do something like:

\starttableX
   \startSomeField
   Some Field Value...
   \stopSomeField

   \startOtherField
   Other Field Value...
   \stopOtherField
\stoptableX

And the result, should be a table like this:

| Some Field Label:  | Some Field Value...  |
| Other Field Label: | Other Field Value... |

That way I define a template for each table type I'll have in the document.

I'm not having trouble with the tables, but with the macro definition,  
this is my approximation of what I want (which does not work):

\startsetups crudmain
   \long\def\startguiname #1 \stopguiname{\setvariables[crudmain][guiname=#1]}
   \long\def\startclassname #1  
\stopclassname{\setvariables[crudmain][classname=#1]}

GUI Name: \getvariable{crudmain}{guiname}
Class Name: \getvariable{crudmain}{classname}
\stopsetups

\definestartstop[crudmain][commands=\setups{crudmain}]

\startcrudmain
   \startguiname
   Some name here...
   \stopguiname
   \startclassname
   Other name here...
   \stopclassname
\stopcrudmain

At this point I'm getting this error:

! Use of \startguiname doesn't match its definition.

I want the \long\def\startguiname inside the \startsetups /  
\stopsetups to be sure that it will only be called inside the  
\startcrudmain / \stopcrudmain (Cause other tables of different types  
may have fields with the same name). But even considering the previous  
point, if I move the \long\def\startguiname outside the \startsetups /  
\stopsetups definition it does not works, because the  
\getvariable{crudmain}{guiname} just returns blank.

So is it possible to do what I want or something similar? What would  
be a good way to do it? Any advice on the code I've already written?  
This is really getting me crazy, cause context is not like any other  
programming language I'm used to use ;-)

Thanks in Advance
Demián

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

end of thread, other threads:[~2008-07-31 13:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-31 13:59 Making a template, defining a macro Demián Gutierrez
  -- strict thread matches above, loose matches on Subject: below --
2008-07-30 23:18 Demián Gutierrez
2008-07-31  6:37 ` Wolfgang Schuster

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