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

#71849 by dhs
Thu Jul 13, 2017 10:41 pm
I s there an existing method to allow entry of distances in a VCL form? I am looking for is something to format a distance for display in an edit field, and also to parse the input from that field and return a number in 1/32".
Hopefully this exists and I just haven't found it ... It would be possible to write my own logic based on the scale type, but there are quite a few scale types and the logic must already exist in DataCAD itself so I am hoping I can hook into that.
David H.
#71885 by Jsosnowski
Wed Jul 19, 2017 7:45 pm
Conversion to strings can be performed directly by DCAl. See "Chapter 6 Data Routines" for:

Code: Select allPROCEDURE cvdisst (dis : real; str : OUT string);

cvdisst converts a distance to a string. The distance is in DataCAD units as described earlier.
The returned string depends upon the current scale type (metric, architectural, etc.).

This will work inside a macro, but not in an independent form Program in which case you must write your own method.

There is no conversion available in DCAl to go back to the real variable value. You willhave to generate this yourself.
#71906 by dhs
Tue Jul 25, 2017 12:37 pm
Thanks Joe,

I had not considered cvdisst because I felt that it formatted a string for display rather than for input (e.g. for the DataCAD's Arch scale an input of 12.11.31/32 is formatted as '12-11 31/32' by cvdisst if Units is disabled in the scale type menu, or as 12'-11 31/32" if units are enabled).

So it seems that if I want to be able to accept distance input in a VCL form I do in fact need to write both format & parse functions. They need to take into account not only the current scale type but also various other parameters (e.g. dofloat, sig digits for mm scale, 32nds/64ths/128ths etc for Arch scale, and possibly other settings for other scale types), so it is not a particularly simple piece of code.
... When I think about it, the formatting code could probably use cvdisst as a starting point and just replace spaces and dashes with dots (for Arch Scale) and remove units characters(you can of course use cvdisst in a VCL form that is part of a DCAL for Delphi project so long as you include UInterfaces in the uses clause). Might just work ...

I've put aside the project that I was working on when I asked this question, but will most likely return to it at some point (was more of a concept than a very worked out project). If I do come back to it I will be tempted to just accept mm or decimal inch inputs at least in the initial version, as they will both be pretty simple to parse.

David H.
#74012 by dhs
Fri Jun 01, 2018 10:10 am
ok, a year later and I am starting to look at D4D again, and have discovered that the procedures I was looking for did in fact exist all along (and are used in the sample AEC_Model macro, which is how I found them).

To convert a distance to string (in the input format) use:
toStr (dis: double; var trash80: ShortString; RoundIt: boolean);
(the variable trash80 on output is the appropriately formatted string)

To convert a distance string (in the input format) back to a double use:
toDis(str: ShortString; var dis: double): boolean;

Glad to have found these, as they did seem to be glaring omissions from the interface if they did not exist!

David H.

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