Page 1 of 1

Persist variable values between script runs

Posted: Thu Sep 09, 2010 3:08 pm
by hungerburg
Is there a way I can persist variable values inside of qcad?

Eg. I want to display a dialogue, that asks some values, and on a subsequent run starts with the previously entered values instead of its builtin defaults.

I know I can write those to a file, but would rather not go this way.

--
peter

Posted: Sun Oct 10, 2010 8:39 pm
by tukuyomi
You suggest the best solution yourself, I'm afraid...
I can write those to a file

persist data with json

Posted: Tue Oct 12, 2010 11:57 am
by hungerburg
I noticed too, so I write my object as a json string by printf(), as the builtin interpreter does not like json2.js from crockford's json.org.

reading back with "JSON = F.read(); try { preset = eval("(" + JSON + ")"); }" is OK too.

One problem: the windows version of qcad does not read UTF-8. So only plain ascii will transfer correctly between windows and linux versions. I guess there is no utf-8 locale for windows xp, so I will have to live with mangled umlauts until qcad3 comes around.