Re: [NTG-context] High level user macro (howto?)

2004-08-10 Thread Peter Mnster
On Mon, 28 Jun 2004, Taco Hoekwater wrote:

 The 'key' to the keyval functionality in ConTeXt are two macros called
 \getparameters and \processaction.
 
 Here is a 'quickstart', assuming you want to define \myzigzag:
 
 [...]

Hello Taco,
thank you for your 'quickstart'!
I've just tried to apply \getparameters to the \Changes macro on the Wiki
(http://contextgarden.net/Changes). But there is a problem and any help
would be nice.

Here is the new macro:

\def\Changes#1[#2]{%
  \getparameters[CH][#2]% Auteur, Modif, Labels, Date
  \ifnum\RevC=0 \BigTitle \vskip0.5ex \Vfil \startChanges \fi
  \global\advance\RevC by 1 \VL \the\RevC \VL \CHDate \VL \CHModif \VL
  XXX%\In[\CHLabels,\relax] % does not work, but not so important for now
  \VL \CHAuteur \VL\AR\HL}

And later on, the usage of the macro:

\Changes[Date=1/2/2004,Modif=First version,Auteur=Peter]
\Changes[Date=3/4/2004,Modif=Some modifications,Lables={sec:S1,sec:S2},
  Auteur=Peter Münster]
\Changes[Date=5/6/2004,Modif=Some other modifications,Lables={sec:S2},
  Auteur=Peter]

The problem:
the parameter values are not updated in the two last calls of the macro.

Regards, Peter

-- 
http://pmrb.free.fr/contact/
_
FilmSearch engine: http://f-s.sf.net/
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] High level user macro (howto?)

2004-08-10 Thread Peter Mnster
Pardon, I forgot the whole tex-file:

\useregime[il1]
\enableregime[il1]
\useencoding[ffr]
\definehspace[fr][:][.16667em]
\definehspace[fr][;][.16667em]
\definehspace[fr][!][.16667em]
\definehspace[fr][?][.16667em]
\mainlanguage[fr]
\newdimen\BigWidth \BigWidth=18cm
\setupscreens[screen=0.85]
\setupcolors[state=start]
\setupheadertexts[Rév.: \the\RevC]
\def\Vfil{\vskip0pt plus3fil\relax}
\def\In[#1,#2]{\ifx#1\empty\else\in[#1]\fi\if\relax#2\else, \In[#2]\fi}
\def\BigTitle{\centerline{\framed[width=\BigWidth,offset=2mm,
  background=screen]{\bfb\setupinterlinespace\cbox{Title

\def\startChanges{\hbox to \hsize\bgroup\hss\SetTableToWidth{\BigWidth}%
  \starttable[s1 | c | c | p(95mm) | p(17mm) | p(37mm) |]
  \HL\BL[5]\AR\VL Rév.\VL Date\VL Origine de la mise à jour\VL§ modifié\VL
  Auteur\VL\AR\HL}
\def\stopChanges{\stoptable\hss\egroup}\newcount\RevC
\def\Changes#1[#2]{%
  \getparameters[CH][#2]% Auteur, Modif, Labels, Date
  \ifnum\RevC=0 \BigTitle \vskip0.5ex \Vfil \startChanges \fi
  \global\advance\RevC by 1 \VL \the\RevC \VL \CHDate \VL \CHModif \VL
  XXX%\In[\CHLabels,\relax] % does not work, but not so important for now
  \VL \CHAuteur \VL\AR\HL}
\def\Destinataires#1{\stopChanges\Vfil
  \def\temp{#1}\ifx\temp\empty\else\noindenting Destinataires:\crlf#1\blank\fi
\centerline{\SetTableToWidth{\BigWidth}%
\bf\starttable[| c | c | c |]
\HL\BL[3]\AR\VL Approbateur\VL Date\VL Visa\VL\AR\HL
\VL\vbox to 2cm{}\VL\VL\VL\AR\HL
\stoptable}\par\page\completecontent}

\starttext
\Changes[Date=1/2/2004,Modif=First version,Auteur=Peter]
\Changes[Date=3/4/2004,Modif=Some modifications,Lables={sec:S1,sec:S2},
  Auteur=Peter Münster]
\Changes[Date=5/6/2004,Modif=Some other modifications,Lables={sec:S2},
  Auteur=Peter]
%
\Destinataires{Peter, Olivier}

\section[sec:S1]{A section}
some text
\subsection{Bla}
\subsection{Bla}

\section[sec:S2]{Another section}
some text
\stoptext

Cheers, Peter

-- 
http://pmrb.free.fr/contact/
_
FilmSearch engine: http://f-s.sf.net/
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] High level user macro (howto?)

2004-08-10 Thread Peter Mnster
On Tue, 10 Aug 2004, Vit Zyka wrote:

\getparameters[CH][#2]% Auteur, Modif, Labels, Date
 
 Try \getgparameters

Thanks!!  What an easy fix, just ONE letter :-)
Peter

-- 
http://pmrb.free.fr/contact/
_
FilmSearch engine: http://f-s.sf.net/
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] High level user macro (howto?)

2004-06-28 Thread Maurice Diamantini dom
Bonjour à tous,
One thing is missing in context (or not documented in reference manual?)
is a standard and easy way to build arbitrary parametrised high level 
macros.

For exemple, instead of
   \def\myCommand#9{...}
That I should call by
   \myCommand{param1}{param2}{...} {param9}
Id'like too keep default value for most of the parameters but param7
and write something like:
   \myCommand[param7=value7]{body}
In LaTeX, there is a package keyval for doing this
And context use this everywere, but I haven't seen anything for
a user beeing able to do this.
This is the base for building arbitrary complex user commands with
some defauld behavior, and then, if this personal macro is usefull
enough, building some user contribution library.
As a true exemple, see a latex package I've written some years
ago for drawing uml diagramms whith LaTeX command (using PsTricks).
This file is available at
  http://www.ensta.fr/~diam/latex/pst-uml/pst-uml-981218-09h41.tar.gz
(should now be available on CTAN too)
See documents for the samples (in french but the samples are in LaTeX 
and
drawing are in picture !)

One of the first exemple I'd like is some command to put some little
table as caractere in a line (see that as some personalised box):
  start of line
  $-$\myStack[border=1ex,baseline=0.5]{
  aaa  bbb \\
  aaa  bbb \\
  aaa  bbb
  }$-$
  end of line
Or a little command to draw some picture, with default but modifiable
parameters:
  $-$\myzigzag[dir=down,linewith=1pt,color=red,with=3\em]$-$
Using Metafun.
Cordialement,
-- Maurice
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] High level user macro (howto?)

2004-06-28 Thread Giuseppe Bilotta
Saturday, June 26, 2004 Maurice Diamantini dom wrote:

 Bonjour à tous,

 One thing is missing in context (or not documented in reference manual?)
 is a standard and easy way to build arbitrary parametrised high level
 macros.

 For exemple, instead of
 \def\myCommand#9{...}
 That I should call by
 \myCommand{param1}{param2}{...} {param9}

 Id'like too keep default value for most of the parameters but param7
 and write something like:

 \myCommand[param7=value7]{body}

It is true, we need a programming in ConTeXt manual. It is
still possible to 'know' how to do things by looking at the way
things are done in ConTeXt itself. For example, in your case
you want something like this:

\def\myCommand[#1]#2{%
 \rawgetparameters[myCommand][param1=defaultvalue1,param2=defaultvalue2,#1]%
 do something with \csname myCommandparam1\endcsname and #2}


This is of course very draft, and can be highly tuned and done
multilingual, but that's much more complex.

-- 
Giuseppe Oblomov Bilotta



___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] High level user macro (howto?)

2004-06-28 Thread Taco Hoekwater

Hi Maurice,

The 'key' to the keyval functionality in ConTeXt are two macros called
\getparameters and \processaction.

Here is a 'quickstart', assuming you want to define \myzigzag:

%
\unprotect % enable exclamations in macro names

\def\myzigzag#1[#2]{% 
  % the #1 makes sure we allow a space before the bracket
  %
  \getparameters[ZZ][Dir=,Linewidth=1pt,Color=Red,Width=3em,#2]
  %
  % Now you have a set of new macros that all start with ZZ. 
  % At least there are \ZZDir,\ZZLinewidth, \ZZColor and \ZZWidth
  % (these have default values) but possibly others as well, 
  % depending on user input.
  % 
  % Here's a usage example: 
  %
  \edef\mywidth{\ZZWidth}%
  %
  % If you want to use keyword values, then you also need 
  % to use \processaction.
  % 
  % Say you want Dir to be mandatory and that it 
  % accepts 4 directional keywords, as well as a direct 
  % angle specification.
  %
  % I've used all mixed case keywords, because otherwise
  % you might run into conflicts with the multilingual interface
  %
  \expandafter\processaction\expandafter[\ZZDir]
[Down   =\def\Dir{270},
 Left   =\def\Dir{180},
 Up =\def\Dir{90},
 Right  =\def\Dir{0},
 \s!default =\errorDir, 
 \s!unknown =\checkDir{\ZZDir}]
  % 
  % \s!default may be triggered because \ZZDir's expansion is 
  % empty unless the user supplied something.
  %
  % The first argument to \processaction has to be expanded,
  % so you need the \expandafter's.q
}

% for completeness, here is an example definition of \checkDir and
% \errorDir:

\def\errorDir{%
   \def\Dir{0}% error recovery
   \message{Please supply Dir argument}%
}

\def\checkDir#1{%
  \doifnumberelse {#1}
  {\def\Dir{#1}}
  {\message{Invalid Dir argument! (#1)}}
}

\protect % end of definitions


On Sat, 26 Jun 2004 11:51:14 +0200, Maurice wrote:

 Bonjour à tous,
 
 One thing is missing in context (or not documented in reference manual?)
 is a standard and easy way to build arbitrary parametrised high level 
 macros.
 


-- 
groeten,

Taco
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] High level user macro (howto?)

2004-06-28 Thread Hans Hagen
Giuseppe Bilotta wrote:
It is true, we need a programming in ConTeXt manual. It is
still possible to 'know' how to do things by looking at the way
things are done in ConTeXt itself. For example, in your case
you want something like this:
\def\myCommand[#1]#2{%
\rawgetparameters[myCommand][param1=defaultvalue1,param2=defaultvalue2,#1]%
do something with \csname myCommandparam1\endcsname and #2}
 

There is 

 \setvariables [yournamespace] [yourvar=yourval]
which operates independent of the language interface
 \getvariable{yournamespace}{yourvar} 

can be used to pick up a var
The most important issue here is that you need to use some unique prefix, preferable something MyPrefix (capital and verbose). 

Hans 

-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re[2]: [NTG-context] High level user macro (howto?)

2004-06-28 Thread Giuseppe Bilotta
Monday, June 28, 2004 Hans Hagen wrote:

 There is

   \setvariables [yournamespace] [yourvar=yourval]

 which operates independent of the language interface

   \getvariable{yournamespace}{yourvar} 

 can be used to pick up a var

What is the difference between setvariable and getparameters?

-- 
Giuseppe Oblomov Bilotta

___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re[2]: [NTG-context] High level user macro (howto?)

2004-06-28 Thread Giuseppe Bilotta
Monday, June 28, 2004 Hans Hagen wrote:

 Giuseppe Bilotta wrote:

What is the difference between setvariable and getparameters?
  

 the second one does interface translations 

Sorry, I meant rawgetparameters

-- 
Giuseppe Oblomov Bilotta

___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context