ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Using defaults and indexes
@ 2009-01-21 15:02 Cecil Westerhof
  2009-01-21 15:36 ` Wolfgang Schuster
  0 siblings, 1 reply; 9+ messages in thread
From: Cecil Westerhof @ 2009-01-21 15:02 UTC (permalink / raw)
  To: mailing list for ConTeXt users

In my template I have:
    \long\def\letterclosing#1#2{
        \blank[line]#1,
        \blank[3*line]#2
    }

And in the main file I have:
    \letterclosing{Hoogachtend}{Cecil Westerhof}

But I would like to have this as the default, so I could use:
    \letterclosing

Beside that I would like to have the possibility to use:
    \letterclosing{business}
or
    \letterclosing{family}

This would then use defined values.

When the first parameter is filled, but not with a recognized value,
then the second parameter should be filled. If not, the compilation of
the file should generate an error. Is this something that can be done?

-- 
Cecil Westerhof
___________________________________________________________________________________
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] 9+ messages in thread

* Re: Using defaults and indexes
  2009-01-21 15:02 Using defaults and indexes Cecil Westerhof
@ 2009-01-21 15:36 ` Wolfgang Schuster
  2009-01-21 17:11   ` Cecil Westerhof
  0 siblings, 1 reply; 9+ messages in thread
From: Wolfgang Schuster @ 2009-01-21 15:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 21.01.2009 um 16:02 schrieb Cecil Westerhof:

> And in the main file I have:
>
>    \letterclosing{Hoogachtend}{Cecil Westerhof}
>
> But I would like to have this as the default, so I could use:
>
>    \letterclosing
>
> Beside that I would like to have the possibility to use:
>
>    \letterclosing{business}
> or
>    \letterclosing{family}
>
> This would then use defined values.
>
> When the first parameter is filled, but not with a recognized value,
> then the second parameter should be filled. If not, the compilation of
> the file should generate an error. Is this something that can be done?

\long\def\letterbody#1%
   {{\blank[line]\setupindenting[yes,medium]#1\par}}

\def\letterclosing
   {\dodoublegroupempty\doletterclosing}

\def\doletterclosing#1#2%
   {\ifsecondargument
      \dodoletterclosing{#1}{#2}%
    \else
      \doifelsenothing{#1}
        {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}%
        {\processaction
           [#1]
           [  family=>{\dodoletterclosing{Informal closing,}{Cecil  
Westerhof}},
            business=>{\dodoletterclosing{Formal closing}{Cecil  
Westerhof}},
             unknown=>{\errorisfataltrue\waitonfatalerror}]}%
    \fi}

\def\dodoletterclosing#1#2%
   {\blank[line]#1\blank[3*line]#2}

\setupindenting[yes,none]

\starttext

\letterbody{\dorecurse{2}{\input knuth\par}}
\letterclosing{Hoogachtend,}{Cecil Westerhof}

\page

\letterbody{\dorecurse{2}{\input knuth\par}}
\letterclosing{family}

\page

\letterbody{\dorecurse{2}{\input knuth\par}}
\letterclosing{business}

\page

\letterbody{\dorecurse{2}{\input knuth\par}}
\letterclosing{unknown}

\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] 9+ messages in thread

* Re: Using defaults and indexes
  2009-01-21 15:36 ` Wolfgang Schuster
@ 2009-01-21 17:11   ` Cecil Westerhof
  2009-01-21 17:44     ` Wolfgang Schuster
  2009-01-21 17:59     ` Tad Ashlock
  0 siblings, 2 replies; 9+ messages in thread
From: Cecil Westerhof @ 2009-01-21 17:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users

2009/1/21 Wolfgang Schuster <schuster.wolfgang@googlemail.com>:
>> And in the main file I have:
>>
>>   \letterclosing{Hoogachtend}{Cecil Westerhof}
>>
>> But I would like to have this as the default, so I could use:
>>
>>   \letterclosing
>>
>> Beside that I would like to have the possibility to use:
>>
>>   \letterclosing{business}
>> or
>>   \letterclosing{family}
>>
>> This would then use defined values.
>>
>> When the first parameter is filled, but not with a recognized value,
>> then the second parameter should be filled. If not, the compilation of
>> the file should generate an error. Is this something that can be done?
>
> \long\def\letterbody#1%
>  {{\blank[line]\setupindenting[yes,medium]#1\par}}
>
> \def\letterclosing
>  {\dodoublegroupempty\doletterclosing}
>
> \def\doletterclosing#1#2%
>  {\ifsecondargument
>     \dodoletterclosing{#1}{#2}%
>   \else
>     \doifelsenothing{#1}
>       {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}%
>       {\processaction
>          [#1]
>          [  family=>{\dodoletterclosing{Informal closing,}{Cecil
> Westerhof}},
>           business=>{\dodoletterclosing{Formal closing}{Cecil Westerhof}},
>            unknown=>{\errorisfataltrue\waitonfatalerror}]}%
>   \fi}
>
> \def\dodoletterclosing#1#2%
>  {\blank[line]#1\blank[3*line]#2}
>
> \setupindenting[yes,none]
>
> \starttext
>
> \letterbody{\dorecurse{2}{\input knuth\par}}
> \letterclosing{Hoogachtend,}{Cecil Westerhof}
>
> \page
>
> \letterbody{\dorecurse{2}{\input knuth\par}}
> \letterclosing{family}
>
> \page
>
> \letterbody{\dorecurse{2}{\input knuth\par}}
> \letterclosing{business}
>
> \page
>
> \letterbody{\dorecurse{2}{\input knuth\par}}
> \letterclosing{unknown}
>
> \stoptext

Goes a long way. With two parameters it works. When using 'unknown' or
'dummy', I get \wait= messages. When giving enter, the document is
still generated. But that is not a real problem. But when using:
    \letterclosing
or
    \letterclosing{}

I get the same wait= message and there is no letterclosing generated
(or an empty one).

Found the problem.
     \doifelsenothing{#1}
       {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}%
should be:
     \doifelsenothing{#1}
       {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}%

Now it seems to do what I want.

-- 
Cecil Westerhof
___________________________________________________________________________________
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] 9+ messages in thread

* Re: Using defaults and indexes
  2009-01-21 17:11   ` Cecil Westerhof
@ 2009-01-21 17:44     ` Wolfgang Schuster
  2009-01-21 18:28       ` Cecil Westerhof
  2009-01-21 17:59     ` Tad Ashlock
  1 sibling, 1 reply; 9+ messages in thread
From: Wolfgang Schuster @ 2009-01-21 17:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 21.01.2009 um 18:11 schrieb Cecil Westerhof:

> Goes a long way. With two parameters it works. When using 'unknown' or
> 'dummy', I get \wait= messages. When giving enter, the document is
> still generated. But that is not a real problem. But when using:
>    \letterclosing
> or
>    \letterclosing{}
>
> I get the same wait= message and there is no letterclosing generated

>>> When the first parameter is filled, but not with a recognized value,
>>> then the second parameter should be filled. If not, the  
>>> compilation of
>>> the file should generate an error.

I did only what you wrote.

>
IF you don't want a error on the terminal replace

unknown=>{\errorisfataltrue\waitonfatalerror}]}%

with

unknown=>{\dodoletterclosing{Hoogachtend,}{Cecil Westerhof}}]}%

or something else.

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

* Re: Using defaults and indexes
  2009-01-21 17:11   ` Cecil Westerhof
  2009-01-21 17:44     ` Wolfgang Schuster
@ 2009-01-21 17:59     ` Tad Ashlock
  2009-01-21 18:18       ` Wolfgang Schuster
  2009-01-21 18:30       ` Cecil Westerhof
  1 sibling, 2 replies; 9+ messages in thread
From: Tad Ashlock @ 2009-01-21 17:59 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Cecil Westerhof wrote:
[snip]
> Found the problem.
>      \doifelsenothing{#1}
>        {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}%
> should be:
>      \doifelsenothing{#1}
>        {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}%
> 
> Now it seems to do what I want.

I don't see the difference.  Would you point it out for me?

Thanks,
Tad

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

* Re: Using defaults and indexes
  2009-01-21 17:59     ` Tad Ashlock
@ 2009-01-21 18:18       ` Wolfgang Schuster
  2009-01-21 18:30       ` Cecil Westerhof
  1 sibling, 0 replies; 9+ messages in thread
From: Wolfgang Schuster @ 2009-01-21 18:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 21.01.2009 um 18:59 schrieb Tad Ashlock:

> Cecil Westerhof wrote:
> [snip]
>> Found the problem.
>>     \doifelsenothing{#1}
>>       {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}%
>> should be:
>>     \doifelsenothing{#1}
>>       {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}%
>> Now it seems to do what I want.
>
> I don't see the difference.  Would you point it out for me?


It should be

      \doifelsenothing{#1}
        {\dodoletterclosing{Hoogachtend,}{Cecil Westerhof}}%

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

* Re: Using defaults and indexes
  2009-01-21 17:44     ` Wolfgang Schuster
@ 2009-01-21 18:28       ` Cecil Westerhof
  2009-01-21 19:12         ` Wolfgang Schuster
  0 siblings, 1 reply; 9+ messages in thread
From: Cecil Westerhof @ 2009-01-21 18:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users

2009/1/21 Wolfgang Schuster <schuster.wolfgang@googlemail.com>:
>>>> When the first parameter is filled, but not with a recognized value,
>>>> then the second parameter should be filled. If not, the compilation of
>>>> the file should generate an error.
>
> I did only what you wrote.

I was not clear enough again.
What I mend was that when there is not a recognized value, then the
output file should not be generated. When you give a return the file
is still generated. But that is only a minor. (Maybe what I want is
not possible.)

-- 
Cecil Westerhof
___________________________________________________________________________________
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] 9+ messages in thread

* Re: Using defaults and indexes
  2009-01-21 17:59     ` Tad Ashlock
  2009-01-21 18:18       ` Wolfgang Schuster
@ 2009-01-21 18:30       ` Cecil Westerhof
  1 sibling, 0 replies; 9+ messages in thread
From: Cecil Westerhof @ 2009-01-21 18:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users

2009/1/21 Tad Ashlock <taashlo@sandia.gov>:
> Cecil Westerhof wrote:
> [snip]
>>
>> Found the problem.
>>     \doifelsenothing{#1}
>>       {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}%
>> should be:
>>     \doifelsenothing{#1}
>>       {\doletterclosing{Hoogachtend,}{Cecil Westerhof}}%
>>
>> Now it seems to do what I want.
>
> I don't see the difference.  Would you point it out for me?

You are right, bad copying/pasting from me. It should be:
     \doifelsenothing{#1}
       {\dodoletterclosing{Hoogachtend,}{Cecil Westerhof}}%

(dodo instead of do)

-- 
Cecil Westerhof
___________________________________________________________________________________
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] 9+ messages in thread

* Re: Using defaults and indexes
  2009-01-21 18:28       ` Cecil Westerhof
@ 2009-01-21 19:12         ` Wolfgang Schuster
  0 siblings, 0 replies; 9+ messages in thread
From: Wolfgang Schuster @ 2009-01-21 19:12 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 21.01.2009 um 19:28 schrieb Cecil Westerhof:

> 2009/1/21 Wolfgang Schuster <schuster.wolfgang@googlemail.com>:
>>>>> When the first parameter is filled, but not with a recognized  
>>>>> value,
>>>>> then the second parameter should be filled. If not, the  
>>>>> compilation of
>>>>> the file should generate an error.
>>
>> I did only what you wrote.
>
> I was not clear enough again.
> What I mend was that when there is not a recognized value, then the
> output file should not be generated. When you give a return the file
> is still generated. But that is only a minor. (Maybe what I want is
> not possible.)


\long\def\letterbody#1%
   {\def\@@letterbody{{\blank[line]\setupindenting[yes,medium]#1\par}}}

\def\letterclosing
   {\dodoublegroupempty\doletterclosing}

\def\doletterclosing#1#2%
   {\ifsecondargument
      \dodoletterclosing{#1}{#2}%
    \else
      \doifelsenothing{#1}
        {\dodoletterclosing{Hoogachtend,}{Cecil Westerhof}}%
        {\processaction
           [#1]
           [  family=>{\dodoletterclosing{Informal closing,}{Cecil  
Westerhof}},
            business=>{\dodoletterclosing{Formal closing}{Cecil  
Westerhof}},
             unknown=>{\message{Warning: Wrong keyword for \string 
\letterclosing.}}]}%
    \fi}

\def\dodoletterclosing#1#2%
   {\@@letterbody
    \blank[line]#1\blank[3*line]#2}

\starttext

\letterbody{\dorecurse{2}{\input knuth\par}}
\letterclosing{unknown}

\stoptext

Best wishes
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] 9+ messages in thread

end of thread, other threads:[~2009-01-21 19:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-21 15:02 Using defaults and indexes Cecil Westerhof
2009-01-21 15:36 ` Wolfgang Schuster
2009-01-21 17:11   ` Cecil Westerhof
2009-01-21 17:44     ` Wolfgang Schuster
2009-01-21 18:28       ` Cecil Westerhof
2009-01-21 19:12         ` Wolfgang Schuster
2009-01-21 17:59     ` Tad Ashlock
2009-01-21 18:18       ` Wolfgang Schuster
2009-01-21 18:30       ` Cecil Westerhof

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