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.
#14763 by devinder
Mon Nov 06, 2006 11:23 am
From DCAL Manual:
Code: Select allFUNCTION getarc (msg : IN string; init : IN OUT boolean; center : OUT point;
                radius, bang, eang : OUT real; key : OUT integer) : integer;

All these parameters are now variables of "TArcArg" record.
Code: Select all   TArcArg = RECORD
      Result: crtstat;     { out }
      key: aSInt;     { out }
      init: pboolean;    { in out }
      state: aSInt;     { in out }
      center: point;       { in out }
      begang,                 { in out }
      endang,                 { in out }
      radius: aFloat;       { in out }
      msg: str80;       { in }
   END;

Old Result is returned in "Result" field of this record, including any key press.

Init field could have boolean instead of pboolean and probably was in insight. You have to initialize this value to True before the calling procedure. Here is the dummy code on what you can do.

Code: Select allTLocalRecord = Packed Record
                             arcinit : boolean;
                             ...... // other fields 
                              case byte of
                                    garc : TArcArg;
                       End;

Function CallArc(...)
begin
   ....
   if act <> alsize then
   begin
       case localrecord(pl).state of
             1 :  begin
                       localrecord(pl).arcinit := true;
                       localrecord(pl).garc.init := @localrecord(pl).arcinit;
                       getarc(localrecord(pl).garc, retval);
                  end;
              ....
         end;
   end;
    ....
end;   
#14791 by devinder
Tue Nov 07, 2006 2:55 pm
I am sorry to tell you that UInterfacesRecords.pas has the incorrect declaration of TArcArg record. Please update that unit with the following correct declaration:
Code: Select all   TArcArg = RECORD
      Result: crtstat;     { out }
      key: aSInt;     { out }
      init: pboolean;    { in out }
      state: aSInt;     { in out }
      center: point;       { in out }
      begang,                 { in out }
      endang,                 { in out }
      radius: aFloat;       { in out }
      msg: str80;       { in }
   END;


Example Code:
Code: Select all
library PArc;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  SysUtils,
  Classes,
  UVariables in '..\Headers\UVariables.pas',
  UDCLibrary in '..\Headers\UDCLibrary.pas',
  UInterfaces in '..\Headers\UInterfaces.pas',
  UInterfacesRecords in '..\Headers\UInterfacesRecords.pas',
  URecords in '..\Headers\URecords.pas',
  UConstants in '..\Headers\UConstants.pas';

{$R *.res}
{$E dmx}

type
   DCMainL = record
      state: asint;
      arcinit : boolean;
      case byte of
         0: (garc : TArcArg);
   end;
   PDCMainL = ^DCMainL;


Function DCAL_Main(act: action; pl, pargs: Pointer): wantType;
var
   retval: asint;
   l: PDCMainL;
   ent : entity;
BEGIN
   l := PDCMainL(pl);
   if act = aagain then
   begin
      case l.state of
         1:
            begin
               if l.garc.Result = res_escape then
               begin
                  case l.garc.key of
                     s0: l.state := 0;
                  end;
               end
               else if l.garc.Result = res_normal then
               begin
                  ent_init (ent, entar3);
                  inmat_curr(ent.matrix);
                  l.garc.center.z := PGSavevar.basez;
                  l.garc.center.z := PGSavevar.hitez;
                  settran (ent.Matrix, l.garc.center.x, l.garc.center.y, l.garc.center.z);
                  ent.ar3div  := PGSV.circldiv1;
                  ent.ar3rad  := l.garc.radius;
                  ent.ar3bang := l.garc.begang;
                  ent.ar3eang := l.garc.endang;
                  ent.ar3close := PGSV.shelclosed;
                  stopgroup;
                  IF ent_add (ent) THEN BEGIN
                     ent_draw (ent, drmode_white);
                  END;
                  stopgroup;
               end;
            end;
         2 : l.state := 1;
         else l.state := 0;
      end;
   end;
   if act = afirst then
   begin
      l.state := 1;
   end
   else if act = alsize then
   begin
      SetLocalSize(sizeof(l^));
   end;
   if act <> alsize then
   begin
      case l.state of
         1:
            begin
               lblsinit;
               lblson1;
               l.arcinit := true;
               l.garc.init := @l.arcinit;
               getarc(l.garc, retval);
            end;
         else
            retval := XDone;
      end;
   end;
   Result := retval;
end;

Function Main(dcalstate: asint; act: action; pl, pargs: Pointer): wantType; stdcall;
begin
   case dcalstate of
      XDcalStateBegin: Result := DCAL_main(act, pl, pargs);
      else Result := XDone;{Necessary}
   end;
end;


exports
   Main;{This is the entry function that will be called by DataCAD. All DCAL Dlls
   will have this function.}

begin
end.


Msg parameter gets overwritten with the internal DataCAD messages and thus at this point msg field is not useful.

Who is online

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