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.

Moderator: pjdixit

#71991 by dhs
Thu Aug 03, 2017 10:30 am
I recently posted the source code to my PntInPly function and stated that it was based on a Classic DCAL function that had had quite a lot of testing. Whilst that was true, the translation to DCAL had introduced a bug for the following reason:

Arrays in Classic DCAL are indexed starting at 1 by default
Arrays in Delphi are indexed starting at 0 by default

Whilst the predefined array types are defined with 1 as the low index (e.g. pntarr is defined as array[1 .. maxpoly]), if you have used open arrays in your DCAL code then you need to be aware of the difference if you bring your code over to Delphi.
In my DCAL PntInPly function I had simply defined the parameter as 'Array of Point'. This allowed me to pass an array of any size as the parameter and I did this because I wanted to allow it to process larger arrays as well as the predefined pntarr type (which in Classic DCAL on ly has 36 elements). The requirement for arrays larger then pntarr is not nearly as important in D4D as maxpoly is now 256, but none-the-less I brought the existing open array definition over into my Delphi code. But I did not update the processing within the procedure.
The result of this is the the procedure I posted has a bug because the parameter passed is a zero based array, but I treat it as though it has a lower bound of 1. Easity fixed by either changing the parameter to pntarr or changing the logic to start the processing loop at 0 instead of 1.

Who is online

Users browsing this forum: No registered users and 2 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.


Software for AEC Professionals Since 1984