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.
#27780 by Jsosnowski
Fri Sep 07, 2007 10:20 am
I am experiencing a hell of a problem!

Note the following code:
Const
MetricFactor = 1259.84252; {DataCad to imperial to metric}

VAR
WorkStr : str255;
debugRl : real;

A point is initialized with these settings:
RelPnt.x := 433000.0;
RelPnt.y := 7712000.0;
RelPnt.z := 0.0;
Surveyvec is an array of records that includes a point in the location field.

And runs through this code: (note line numbers at end of each line for reference)

Reportstr (‘ X = ‘); !1
Reportstr (‘String: ‘); !2
Reportstr (workstr); !3
IF cvstrll (workstr, surveyvec [1].location.x) THEN !4
Reportstr (‘, Converted Loc.x: ‘); !5
reportdis (surveyvec [1].location.x*metricfactor); !6
surveyvec [1].location.x := (surveyvec [1].location.x – RelPnt.x)* metricfactor; !7
END; !8
Reportstr (‘, RelPnt.x: ‘); !9
Reportdis (relpnt.x*metricfactor); !10
Reportstr (‘, Adjusted Loc.x: ‘); !11
reportdis (surveyvec [1].location.x); !12
Reportstr (‘ metricfactor= ‘); !13
Debugrl := metricfactor; !14
Reportdis (debugRl); !15
Reportstr (‘ 32,800 meter = ‘); !16
Debugrl := 32800.0; !17
DebugRl := debugRl * metricfactor; !18
Reportdis(debugRl); !19
Reportshow; !20

The procedures reportstr, reportdis etc. are similar to utilities in the wrtutl module, except they write to a file instead of the screen. They do not affect the math error I found.

Yields the following in the report file:
X = String: 433847.493,
Converted Loc.x: 433847.487 m,
RelPnt.x: 25751.999 m,
Adjusted Loc.x: 459599.48 m
metricfactor= 1.00 m
32,800 meter = 32735.999 m

The workstr variable reads from a file. Notice that the conversion is handled correctly. RelPnt.x is not handled correctly given an incorrect answer. Also notice that it is adding to the Loc.x variable instead of deducting as is established in the formula. I then tested metricfactor which is correctly reported as one meter. Any multiplication to the metric factor up to 32760 (the limit of an integer) is handled correctly. Once the multiplier surpasses 32760 it begins to deduct instead of add to the value. Note that the variable debugRl handles multiplication in line 18 the same way location does in line 12, but one has the error, and the other does not.

Comments?
#27804 by ERT
Fri Sep 07, 2007 3:23 pm
#27823 by ERT
Sat Sep 08, 2007 12:00 pm
When I worked with older DCAL (DCAD 6-7 ver.), I did the next:
I put my data to file,
execute external program (I wrote it in Turbo Pascal)
the external program calculate and put result to a file
external program finished, back retun to dcal and read the result from the file.

Sorry for my bad english language.

Who is online

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