Dear list,

I have the following sample:

  \starttext
  \startTEXpage[offset=1em]

  \startmode[*first]
  \startluacode
  io.write(" What’s your name?    ")
  document.user_name = io.read()
  document_data = { "\\def\\UserName{" .. document.user_name .. "}" }
  io.savedata(tex.jobname.."_document-tmp-data.txt", document_data)
  \stopluacode
  \stopmode

  \input{\jobname_document-tmp-data.txt}
  \UserName, nice to meet you.
  \stopTEXpage
  \stoptext

This prompts user input on the first run, but I have to save to an
external file to be able to read it in next runs.

Just in case you might wonder, the actual code requires "--purgeall".

Is there no way to save that in the .tuc file for later runs?

I have tried
https://wiki.contextgarden.net/System_Macros/Key_Value_Assignments#Multi-pass_data
(as Aditya suggested to me), but runs after the first one see to empty
the data in the Lua table.

Adapting a sample from the wiki:

  \starttext

  \definedataset[somedataset]
  \startmode[*first]
  \setdataset[somedataset][wantscake=yes, wantsdeath=no]
  \stopmode

  Do you want cake? \datasetvariable{somedataset}{1}{wantscake}.\\
  BTW, do you want death? \datasetvariable{somedataset}{1}{wantsdeath}.
  \stoptext

I wonder whether there is no cleaner way to do this.

Many thanks for your help,

Pablo
--
http://www.ousia.tk
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to