Page 1 of 1

Maintaining 'user preferences' in Dcal for Delphi

PostPosted: Wed Apr 05, 2006 7:17 am
by rod_walker
Hello,
When a macro is first run it is normal to provide default values. In 'old DCAL' this was done by detecting a boolean value, say 'init' which when first time run defaulted to false, so the programmer set up the defaults by a procedure(initialize) and set init to true; The user would typically change these settings to their own preferances, which was then maintained.
In Dcal for Delphi the initialiazation is set by the action 'afirst' eg.
Code: Select allif act = afirst then
        begin
           b.ptno:=1;
           b.state:=1;
           b.outlineClr:=clrred;
           b.xClr:=clrltred;
           b.Width:=75.0/metricconv;
           b.depth:=38.0/metricconv;
           b.endspc:=900.0/metricconv;
           b.intspc:=1200.0/metricconv;
         end

No problem so far. Now when the user changes these am I correct in thinking I will have to write these to a file and read them in under the act=afirst code?
Regards
Rod Walker

PostPosted: Wed Apr 05, 2006 7:51 am
by David A. Giesselman
Hi Rod,

Yes, you are correct in your assumption that DCAL for Delphi will not automatically store the values for global variables. In the old DCAL (.dcx format) this came for free due to the macro itself being the container for both Code and Data space.

Dave

Global Variables

PostPosted: Thu May 04, 2006 2:17 pm
by Jsosnowski
This post and response confuse me. I have not yet paid atention to global variables in a DCAL macro dll. It is my understanding that global variables in each unit are preserved, similar to what happened under DCAl before delphi units. If I interpret the question and Dave's response here, I must explicitly save and load any global variables from a file each time the macro is opened and closed in order to use them again in a DCAL macro. Please confirm this?

PostPosted: Thu May 04, 2006 3:56 pm
by devinder
Yes you must explicitly save and load any global variables to/from a file. DMX files are actually Windows DLLs. They are not self modifiable.