[NTG-context] Loop?

Wolfgang Schuster wolfgang.schuster.lists at gmail.com
Fri Feb 12 20:25:52 CET 2021


Jairo A. del Rio schrieb am 12.02.2021 um 19:50:
> Hi, Ángel. Like this?
> 
> \def\mylist{Fulano,Mengano,Sutano}
> 
> \def\mycommand#1{#1\blank{\red Something here}\blank}
> 
> \starttext
> 
> \processcommacommand[\mylist]\mycommand
> 
> \stoptext
> 
> There are better ways to deal with data in ConTeXt, but it's basically 
> that way, I think.


You can use the commalist environment:

\starttext

\startprocesscommalist[One,Two,Three,Four]
     Person Number \currentcommalistitem\par
\stopprocesscommalist

\blank

\defineexpandable\NameList{One,Two,Three,Four}

\startprocesscommacommand[\NameList]
     Person Number \currentcommalistitem\par
\stopprocesscommacommand

\stoptext


Another way is to use the database module:

\usemodule[database]

\starttext

\defineseparatedlist
   [namelist]
   [command=\NameEntry]

\starttexdefinition unexpanded NameEntry #1
     Person Number #1\par
\stoptexdefinition

\startseparatedlist[namelist]
One
Two
Three
Four
\stopseparatedlist

\stoptext


Wolfgang


More information about the ntg-context mailing list