store data in the first run for later runs?
![](https://secure.gravatar.com/avatar/5955e8e90611e77ccbfc7721b6112027.jpg?s=120&d=mm&r=g)
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-pas... (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
participants (1)
-
Pablo Rodriguez