Dr. Thomas Möbius <mailto:kont...@thomasmoebius.de>
17. Juni 2015 15:23
Dear list,

having used ConTeXt for years now, I am the first time in need
to, well, "programming" something. And I realised, I am a little bit
lost. I have a rather long list of variable descriptions that I would
like to typeset in a usable and readable way. It should look something
like this:

---snip: minimal example---
\starttext
\setupdelimitedtext[blockquote]

{{\bf Geschlecht} \qquad Geschlecht \hfill $0,1$}

\startblockquote
Das Geschlecht des Probanden.
\stopblockquote

\blank
{{\bf SoB} \qquad Geburtssaison \hfill $1,\dots,4$}

\startblockquote
Jahreszeit der Geburt. Kodierung: 1 = Winter, 2 = Frühling, 3 = Sommer,
4 = Herbst.
\stopblockquote

\blank
{{\bf BildungV} \qquad Bildung Vater \hfill $1,\dots,6$}

\startblockquote
Ordinale Beschreibung der Bildung des Vaters zum Zeitpunkt der Erhebung.
Kodierung: 0 = kein Abschluss, 1 = Volksschule, 2 = Hauptschule, 3 =
Realschule, 4 = Fachabitur, 5 = Abitur, 6 = Studium.
\stopblockquote

\blank
{{\bf BildungM} \qquad Bildung Mutter \hfill $1,\dots,6$}

\startblockquote
Ordinale Beschreibung der Bildung der Mutter zum Zeitpunkt der Erhebung.
Kodierung siehe {\bf BildungV}.
\stopblockquote

\blank
{{\bf Urb15} \qquad Urbanität \hfill $\naturalnumbers$}

\startblockquote
Beschreibung der Urbanität des Umfelds in den ersten 15 Lebensjahren.
Kodierung: $\sum_{i=1}^{15} u_i$ mit $u_i=$ ein Punkt für eine Stadt bis
10.000 Einwohner, 2 Punkte für bis 100.000 Einwohner, 3 Punkte über
100.000 Einwohner im Jahr $i$.
\stopblockquote

\blank
{{\bf LQ} \qquad Händigkeit \hfill $(0,1)$}

\startblockquote
Lateralisierungsquotient, wobei -1 = perfekt linkshändig und +1 =
perfekt rechtshändig.
\stopblockquote

\stoptext
---end snip---

What I would like to have is a function/environment/something that would
allow me to write the above text in the following way:

---snip: want to example---
\starttext

\startvariable [alias=Geschlecht, name=Geschlecht, range={$0,1$}]
Das Geschlecht des Probanden.
\stopvariable

\startvariable [alias=SoB, name=Geburtssaison, range={$1,\dots,4$}]
Jahreszeit der Geburt. Kodierung: 1 = Winter, 2 = Frühling, 3 = Sommer,
4 = Herbst.
\stopvariable

\startvariable [alias=BildungV, name={Bildung Vater},
range={$1,\dots,6$}, reference=bildungDesVater]
Ordinale Beschreibung der Bildung des Vaters zum Zeitpunkt der Erhebung.
Kodierung: 0 = kein Abschluss, 1 = Volksschule, 2 = Hauptschule, 3 =
Realschule, 4 = Fachabitur, 5 = Abitur, 6 = Studium.
\stopvariable

\startvariable [alias=BildungM, name={Bildung Mutter},
range={$1,\dots,6$}]
Ordinale Beschreibung der Bildung der Mutter zum Zeitpunkt der Erhebung.
Kodierung siehe \in[bildungDesVater].
\stopvariable

\startvariable [alias=Urb15, name=Urbanität, range={$\naturalnumbers$}]
Beschreibung der Urbanität des Umfelds in den ersten 15 Lebensjahren.
Kodierung: $\sum_{i=1}^{15} u_i$ mit $u_i=$ ein Punkt für eine Stadt bis
10.000 Einwohner, 2 Punkte für bis 100.000 Einwohner, 3 Punkte über
100.000 Einwohner im Jahr $i$.

\startvariable [alias=LQ, name=Händigkeit, range={$(0,1)$}]
Lateralisierungsquotient, wobei -1 = perfekt linkshändig und +1 =
perfekt rechtshändig.
\stopvariable

\stoptext
---end snip---

Could someone point me in the right direction, or get me started
somehow? Is this difficult to accomplish? Or is it super easy and I just don't know it?

The code below does what you want.

\def\startvariable
  {\begingroup
   \dosingleempty\dostartvariable}

\def\dostartvariable[#1]%
  {\getrawparameters[variable][alias=,name=,range=,reference=,#1]%
   \grabbufferdata[variable][startvariable][stopvariable]}

\def\stopvariable
  {\directsetup{variable:content}%
   \endgroup}

\startsetups[variable:content]

    \startlinealignment[middle]
        \variablealias
        \qquad
        \variablename
        \hfill
        \variablerange
\doifsomething{\variablereference}{\expanded{\reference[\variablereference]{\variablealias}}}
    \stoplinealignment

    \startblockquote
        \getbufferdata[variable]
    \stopblockquote

\stopsetups

\starttext

\startvariable [alias=Geschlecht, name=Geschlecht, range={$0,1$}]
Das Geschlecht des Probanden.
\stopvariable

\startvariable [alias=SoB, name=Geburtssaison, range={$1,\dots,4$}]
Jahreszeit der Geburt. Kodierung: 1 = Winter, 2 = Frühling, 3 = Sommer, 4 = Herbst.
\stopvariable

\startvariable [alias=BildungV, name={Bildung Vater}, range={$1,\dots,6$},reference=bildungDesVater]
Ordinale Beschreibung der Bildung des Vaters zum Zeitpunkt der Erhebung.
Kodierung: 0 = kein Abschluss, 1 = Volksschule, 2 = Hauptschule, 3 =
Realschule, 4 = Fachabitur, 5 = Abitur, 6 = Studium.
\stopvariable

\startvariable [alias=BildungM, name={Bildung Mutter}, range={$1,\dots,6$}]
Ordinale Beschreibung der Bildung der Mutter zum Zeitpunkt der Erhebung.
Kodierung siehe \in[bildungDesVater].
\stopvariable

\startvariable [alias=Urb15, name=Urbanität, range={$\naturalnumbers$}]
Beschreibung der Urbanität des Umfelds in den ersten 15 Lebensjahren.
Kodierung: $\sum_{i=1}^{15} u_i$ mit $u_i=$ ein Punkt für eine Stadt bis
10.000 Einwohner, 2 Punkte für bis 100.000 Einwohner, 3 Punkte über
100.000 Einwohner im Jahr $i$.
\stopvariable

\startvariable [alias=LQ, name=Händigkeit, range={$(0,1)$}]
Lateralisierungsquotient, wobei -1 = perfekt linkshändig und +1 =
perfekt rechtshändig.
\stopvariable

\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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to