Persist variable values between script runs

Post here to ask questions about or get help with the scripting module of QCAD 2.1/2.2.

Moderator: andrew

Persist variable values between script runs

Postby hungerburg » Thu Sep 09, 2010 3:08 pm

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
User avatar
hungerburg
Senior Member
 
Posts: 125
Joined: Fri May 28, 2010 7:35 pm

Postby tukuyomi » Sun Oct 10, 2010 8:39 pm

You suggest the best solution yourself, I'm afraid...
I can write those to a file
tukuyomi
Junior Member
 
Posts: 19
Joined: Mon Aug 09, 2010 6:15 pm

persist data with json

Postby hungerburg » Tue Oct 12, 2010 11:57 am

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.
User avatar
hungerburg
Senior Member
 
Posts: 125
Joined: Fri May 28, 2010 7:35 pm


Return to QCAD 2.1/2.2 Developers

Who is online

Users browsing this forum: No registered users and 0 guests

cron