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

Locked
User avatar
hungerburg
Premier Member
Posts: 160
Joined: Fri May 28, 2010 7:35 pm

Persist variable values between script runs

Post by 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

tukuyomi
Full Member
Posts: 50
Joined: Mon Aug 09, 2010 6:15 pm

Post by tukuyomi » Sun Oct 10, 2010 8:39 pm

You suggest the best solution yourself, I'm afraid...
I can write those to a file

User avatar
hungerburg
Premier Member
Posts: 160
Joined: Fri May 28, 2010 7:35 pm

persist data with json

Post by 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.

Locked

Return to “QCAD 2.1/2.2 Developers”