[dev-context] Storing and retrieving two-pass data

Wolfgang Schuster schuster.wolfgang at googlemail.com
Wed Apr 18 13:06:50 CEST 2012


Am 18.04.2012 um 12:55 schrieb Marco:

> Hi,
> 
> I am trying to  save a string to the .tuc  file and to retrieve
> it in the next run. My attempt:
> 
> \starttext
> \startluacode
> 	local collected = utilities.storage.allocate()
> 	local tobesaved = utilities.storage.allocate()
> 
> 	job.register("job.userdata", tobesaved)
> 
> 	tobesaved["foo"] = "value_foo"
> 	tobesaved["bar"] = "value_bar"
> \stopluacode
> \stoptext
> 
> This leads to the following entry in the .tuc file:
> 
> utilitydata.job.userdata={
> ["bar"]="value_bar",
> ["foo"]="value_foo",
> }
> 
> I  expected  to  be  able   to  retrieve  the  data  with  e.g.
> collected["foo"], but the collected table is empty. What is the
> interface to  retrieve the  values from  the .tuc  file? Aditya
> mentioned  that there  will  be  a new  interface  in this  (or
> the upcoming) beta.


The following works with the current beta, you can find another example in core-dat.mkiv.

\definedataset[test-1]
\definedataset[test-2]

\starttext

\setdataset[test-1][x=Value X 1,y=Value Y 1]
\setdataset[test-1][x=Value X 2,y=Value Y 2]

\setdataset[test-2][a][name=Ben Lee User,job=Manager]
\setdataset[test-2][b][title=TeX by Topic]

\startlines
\datasetvariable{test-1}{1}{x}:\datasetvariable{test-1}{1}{y}
\datasetvariable{test-1}{2}{x}:\datasetvariable{test-1}{2}{y}
\stoplines

Name: \datasetvariable{test-2}{a}{name} \par
Job: \datasetvariable{test-2}{a}{job} \par

\stoptext

Wolfgang


More information about the dev-context mailing list