The DataCAD Developer Network (DDN) is an online resource for information and support for DCAL® (DataCAD Applications Language) developers as well as anyone interested in creating fonts, toolbars, hatch patterns, or linetypes for use in DataCAD.
#11247 by devinder
Tue Apr 25, 2006 9:35 am
Hi,
Here it goes and I hope this is understandable. I am a programmer :)

1. WantType/dcalstate: This is just a unique ID assigned to a function so that DATACAD knows which function it has to call next. So if you are writing a complex macro then you will need more of these states, as in the case of AEC_MODL macro.

2. act : This could be one of (Afirst, Alast, Aagain, AlSize).
AlSize -> Called only once when state is called for the first time by DataCAD. Macro should tell DataCAD how much local memory it should allocate for your pointer to local record that pl uses. All your variables should for this state should be defined in local record (eg. ArrowL). Though you can have all your variables as global I would not recommend it because in complex macros where you can have multiple states, manageability and re-usability of same code can become an issue.
Afirst -> After the memory has been allocated it is time for initializing it. AFirst tells you can initialize all your parameters at this point. It is in AFirst you specify the first local state number, the state is in. This is the right time to read any INI settings for your macro.
Alast -> This is the last call from DataCAD to this subroutine. Users should clear out any temporary data they have generated or finish any unfinished process. Memory allocated for pl local record (allocated by Alsize) will be freed when DataCAD gets control.
Aagain -> This tells pl and pargs are active variable records and hold information and macro writer decides how the flow of program works.

3. pl : This is a pointer to local record, which can contain variables and track in what state the program is in, while moving from one menu level to another. (eg. pl is a pointer to ArrowL).

4. pargs : This is a pointer to the record that is passed by your calling function to a new menu. This is used when you want to send/update parameters from one state to another state. Eg. when calling getpoint function you pass a variable which is type getpointArg, this variable holds the mouse click, mouse status or keyboard status. This status is set in a different dcalstate called getpoint.

DataCAD controls these states/variables and you should not update these variables directly.

Hope this helps.
#11270 by devinder
Wed Apr 26, 2006 12:56 pm
DataCAD looks for 'Main' procedure inside the DMX calls and makes a calls with 'XDcalStateBegin'. There is also 'XDcalStateEnd' which represents the end of DCAL states. These states represents these indexes are reserved for user macros. Thus a single macro you can have up-to 100 states. These meaning to these indexes are given by macro author. Any number except in the range (XDcalStateBegin to XDcalStateEnd) are controlled by DataCAD and you should not worry about them. Example after you call getpoint:
ex. getpoint(l.getpargs,iwant);
the value for iwant gets set to 3 by DataCAD. This value can change at any time in future but will not effect your code as long as you use getpoint. Using iwant = 3 in future can cause macro not to work properly.

If you follow AEC_MODL you will see there are about 25 states, starting from XDcalStateBegin. Main procedure in aec_modl_main.pas and all constants defined in winddoor.pas.

We have used asint, afloat so it is easier to change the scope of variable from integer to longint or extended in the future. This is not likely to happen soon. You should also not change the scope, otherwise they will mismatch with DataCAD and cause DataCAD to crash or misbehave. You can define your local variables as integer, double, if you wish.

I would recommend debugging AEC_MODL macro to give more idea. Sometimes visualization gives more feedback than words.
#11278 by Miguel Palaoro
Wed Apr 26, 2006 2:14 pm
#11307 by devinder
Fri Apr 28, 2006 10:14 am
Image to infinity and beyond
#11320 by devinder
Mon May 01, 2006 4:23 pm
#11365 by Jsosnowski
Wed May 03, 2006 8:30 pm
The recent activity in this discussion has drawn me to tackle the actual interface between Datacad and the macros. The previous discussions have been very helpful, Thank You!

I am not clear on the uses of the Pl versus Parg variables in the main call to Datacad. the arg parameters i see as the arguments necessary for datacad to use its various input procedures as defined in their type definitions in UInterfacesrecords. The Pl pointer, however, I am not as clear about. IN the arrows example the Pl variable links to ArrowL record. IN AEC_Modl it appears to link with the procedure DCALMacro. What is the difference between these two pointer paramters
? Something isn't clicking for me.
EDIT:
After posting this I reread everything above including devinders post from April 25th. I would swear that wasn't there before! and very clear! THANKS.

So if I interpret this correctly pl is used by the macro to record its internal progress between loops of the execution and Datacad does nothing with it except pass it back in the next loop, similar to state variable. Datacad is only interested in the contents of Parg. My question here is what is the difference between the state variable in the ArrowL record and the DCALState parameter in the main procedure? By the way, what does the "L" in "ArrowL" stand for?
#11371 by devinder
Thu May 04, 2006 9:13 am
#11630 by devinder
Thu May 18, 2006 8:59 am

Who is online

Users browsing this forum: No registered users and 47 guests

About DataCAD Forum

The DataCAD Forum is a FREE online community we provide to enhance your experience with DataCAD.

We hope you'll visit often to get answers, share ideas, and interact with other DataCAD users around the world.

DataCAD

Software for Architects Since 1984