ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Character -> command substitution...
@ 2000-07-30 15:31 Joop Susan
  2000-07-31  8:57 ` Hans Hagen
  0 siblings, 1 reply; 2+ messages in thread
From: Joop Susan @ 2000-07-30 15:31 UTC (permalink / raw)


Hello,

I need te be able to substitute certain characters in a parameter string 
for commands as a sortof shorthand notation. For example:

	' ' -> {\kern 10mm}
	'-' -> {\kern 0.5mm ---\kern 0.5mm}
	'.' -> { ... }
	'x' -> { ... }

Can anyone tell me if this is possible in ConTEXt and if so how?

Joop


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Character -> command substitution...
  2000-07-30 15:31 Character -> command substitution Joop Susan
@ 2000-07-31  8:57 ` Hans Hagen
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2000-07-31  8:57 UTC (permalink / raw)
  Cc: ConTeXt

At 05:31 PM 7/30/00 +0200, Joop Susan wrote:
>
>Hello,
>
>I need te be able to substitute certain characters in a parameter string 
>for commands as a sortof shorthand notation. For example:
>
>	' ' -> {\kern 10mm}
>	'-' -> {\kern 0.5mm ---\kern 0.5mm}
>	'.' -> { ... }
>	'x' -> { ... }
>
>Can anyone tell me if this is possible in ConTEXt and if so how?

You need some tex trickery here: 

(1) For simple cases you may use something: 

\def\DoReplaceToken#1{\doifelse{#1}{-}{\kern1em}{#1}}
\def\ReplaceToken  #1{\handletokens#1\with\DoReplaceToken}

\ReplaceToken{abc-def}

(2) For more complicate ones, the following will do. 

\bgroup
  \catcode`\-=\active
  \gdef\ReplaceMinus#1{\catcode`\-=\active \def-{#1}}
\egroup

\def\ReplaceToken#1%
  {\bgroup
   \ReplaceMinus{\kern1em}%
   \def\TheTokens{#1}%
   \expandafter\scantokens\expandafter{\TheTokens}%
   \egroup}

\ReplaceToken{abc-def}

Hans 

-------------------------------------------------------------------------
                                                  Hans Hagen | PRAGMA ADE
                      Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2000-07-31  8:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-30 15:31 Character -> command substitution Joop Susan
2000-07-31  8:57 ` Hans Hagen

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