I have some code like this--it is a very reduced minimum-working example, from 
10,000+ lines of code:
fileA.tex------------------------------

\datatypeA{fish}{an animal that lives in the sea}
\datatypeA{bear}{a big animal with claws and fur}
\datatypeA{squid}{a sea creature with many legs}

fileB.tex------------------------------

\datatypeB{fish}{an animal that lives in the sea}
\datatypeB{bear}{a big animal with claws and fur}
\datatypeB{squid}{a sea creature with many legs}

main.tex------------------------------

\datatypeA[2]{\startitemize \item #1 #2 \stopitemize}
\datatypeA[B]{#1 -- #2}

\define[8]\activity{
    \subject{#1}
        #2
        \startitemize
            \item #3
            \item #4
            \item #5
            \item #6
            \item #7
        \stopitemize
    #8
}

\define[2]\balloongame{
    \activity{Balloon Toss Game}{Instructions}{scissors}{plates}{construction 
paper}{#1}{#2}{\input fileA}
}
\define[2]\fishinggame{
    \activity{Fun Fishing Game}{Instructions}{scissors}{plates}{construction 
paper}{#1}{#2}{\input fileB}
}

\starttext

    \balloongame{balloons}{tape}
    \fishinggame{crayons}{glue}

\stoptext
Basically, I have different classroom activities, defined as macros. 
\balloongame gives all details to the teacher about a "Balloon Toss Game" and 
\fishinggame defines a "Fun Fishing Game". (code has been reduced and 
simplified significantly).
The main issue I have is I have data being stored in filesA.tex, fileB.tex, 
etc. (there are often a dozen such files). Note that strangly the datasets are 
all identical, but a different file is called, and the only difference in the 
dataset is they call different macros. So "Balloon Game" pulls the list, but 
displays them in datatypeA format, the other game takes the same data, but its 
in a different file, and since the macros are different, it displays the 
information differently.
Basically, I have tons of data files sharing basically the same information, 
but each one defined inside the file as using a different macro, according to 
how the information is to be displayed (maybe sometimes as a list, sometimes in 
a table, etc.)
This method seems horribly inefficient. I should be able to store that data in 
one file, but display the data in different ways. The problem is if I use one 
format, like this...

 \datatype{fish}{an animal that lives in the sea}
\datatype{bear}{a big animal with claws and fur}
\datatype{squid}{a sea creature with many legs}
...how do I get that dataset to be included, but displayed in a different 
format each time?
My thinking is perhaps constantly redefine the macro \datatype, but that seems 
still inefficient and prone to lead to errors in the code. Is that the best 
solution?

Any suggestion for the most proper way to go about displaying the information 
from this file, but in different ways in the document?
NOTE: My event code already uses 8 of the #1 #2 variables, so there's not 
really room to include that information there.

--Joel

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to