Page 1 of 1

Menu Curves problem

PostPosted: Thu Dec 06, 2007 7:20 am
by ERT
Hello

I write this:

Code: Select allconst
   AIsClosed: Boolean = False;
   ADoCover: Boolean = False;
var
   CurveArg: TCircArg;
begin
   CurveArg.CircOpts.DoPolyline := False;
   ADoCover := False;
   CurveArg.CircOpts.pDoPLineCover := @ADoCover;
   AIsClosed := False;
   CurveArg.CircOpts.pDoPLineClosed := @AIsClosed;
   menuCurves(RetVal, CurveArg, False, @ADoCover, @AIsClosed);
end;


Enter the menu. Is OK!

Why does DataCAD draw polyline and not arc?
Why does shown the Cover and the Close menuitem?

ERT

PostPosted: Wed Jan 30, 2008 7:17 am
by ERT
Please help.

What is it the correct syntax, that I can call the Curve menu, not the Polyline menu?

Thanks before
ERT

PostPosted: Wed Jan 30, 2008 9:03 am
by devinder
If your code is not part of the state machine and your code is executing without any crash, you are very luck, and unfortunately it would be wrong and thus not work as desired.

There is no record in DCAL called TCircArg. Menucurve uses CircMenuArg record.

CurveArg, Docover and doclosed cannot be:
1. local addresses of boolean
2. Cannot be declared constants
3. Docover and Doclosed cannot point to same address
and thus they have to part of local record.

Example

Code: Select alll=record
   state : asint;
   ...
   CurveArg: CircMenuArg;
  ADoCover,AIsClosed : boolean;
end;


procedure main(....)
begin
....
if act<>alsize then
case l.state of
   ...
2:begin
   menuCurves(retval,l.curvearg,false,@l.adocover,@l.aisclosed);
end;
...
result := retval;
end;

PostPosted: Mon Feb 11, 2008 11:50 pm
by ERT
The code:
Code: Select alllibrary Curves;

uses
  URecords,  // or 12
  UConstants, // or 12
  UInterfacesRecords, // or 12
  UInterfaces, // or 12
  SysUtils,
  Classes;

{$E dmx}

{$R *.res}

type
   TCurvesL = record
      State: aSInt;
      ADoCover, AIsClosed, ADoPolyline: Boolean;
      case Byte of
         1: (GetE: getescArg);
         2: (CurveArg: CircMenuArg);
   end ;
   PCurvesL = ^TCurvesL;

function CurvesMain(act: action; pl, pargs: Pointer): wantType;
var
   RetVal: aSInt;
   L: PCurvesL;
begin
   L := PCurvesL(pl);
   if act = aagain then begin
      case l.state of
         1: begin
            case l.GetE.Key of
               f1: l.state := 2;
               f3: l.state := 3;
               f4: l.state := 4;
               f5: l.state := 5;
               f6: l.state := 6;
               f7: l.state := 7;
               f8: l.state := 8;
               f0: l.state := 9;
               S1: l.state := 10;
               S2: l.state := 11;
               S5: L.ADoPolyline := not L.ADoPolyline;
               S6: L.AIsClosed := not L.AIsClosed;
               S7: L.ADoCover := not L.ADoCover;
            else
               l.State := 0;
            end;
         end ;
         2..11: l.state := 1;
         else l.state := 0;
      end;
   end;
   if act = afirst then begin
      l.state := 1;
      l.ADoCover := False;
      l.AIsClosed := False;
      l.ADoPolyline := False;
      l.CurveArg.CircOpts.DoPolyline := False;
   end else if act = alsize then begin
      SetLocalSize(sizeof(l^));
   end;
   if act <> alsize then begin
      wrterr('DCAL Macro Call Curve Menu - Version 1.0.');
      case l.state of
         1: begin
            WrtLvl('Call Curve');
            LblsInit;
            LblSet(1, 'Curve');
            LblSet(3, 'Arc2pt');
            LblSet(4, 'Arc3pt');
            LblSet(5, 'ArcCentAng');
            LblSet(6, 'ArcCentArc');
            LblSet(7, 'ArcCentChrd');
            LblSet(8, 'ArcTan');
            LblSet(10, 'CrcRad');
            LblSet(11, 'CrcDia');
            LblSet(12, 'Crc3pt');
            LblSetT(15, 'DoPolyline', L.ADoPolyline);
            LblSetT(16, 'IsClosed', L.AIsClosed);
            LblSetT(17, 'DoCover', L.ADoCover);
            LblSet(20, 'Exit');
            LblsOn;
            WrtMsg('Select function.');
            GetEsc(l.gete, retval);
         end;
         2: begin
            menuCurves(retval, L.CurveArg, L.ADoPolyline, @L.ADoCover, @L.AIsClosed);
         end;
         3: begin
            menuArc2pt(retval, L.CurveArg, L.ADoPolyline, @L.ADoCover, @L.AIsClosed);
         end;
         4: begin
            MenuArc3pt(retval, L.CurveArg, L.ADoPolyline, @L.ADoCover, @L.AIsClosed);
         end;
         5: begin
            MenuArcCentAng(retval, L.CurveArg, L.ADoPolyline, @L.ADoCover, @L.AIsClosed);
         end;
         6: begin
            MenuArcCentArc(retval, L.CurveArg, L.ADoPolyline, @L.ADoCover, @L.AIsClosed);
         end;
         7: begin
            MenuArcCentChrd(retval, L.CurveArg, L.ADoPolyline, @L.ADoCover, @L.AIsClosed);
         end;
         8: begin
            MenuArcTan(retval, L.CurveArg, L.ADoPolyline, @L.ADoCover, @L.AIsClosed);
         end;
         9: begin
            MenuCrcRad(retval, L.CurveArg, L.ADoPolyline, @L.ADoCover, @L.AIsClosed);
         end;
         10: begin
            MenuCrcDia(retval, L.CurveArg, L.ADoPolyline, @L.ADoCover, @L.AIsClosed);
         end;
         11: begin
            MenuCrc3pt(retval, L.CurveArg, L.ADoPolyline, @L.ADoCover, @L.AIsClosed);
         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 := CurvesMain(act, pl, pargs);
   else Result := XDone;
   end;
end;

exports
   Main;
   
begin
end.


The problems:
in DataCAD11:
F1: Curve: ERROR, macro out, the drawing closed
F3-S2: Why does shown the Cover and the Close menuitem?

in DataCAD12: here drawing is correct, draw arc and circle, but
F1: Curve: menu call OK, but click maybe F2 menuitem (F1-S3), and why does shown the Cover and the Close menuitem?
F3-S2: Why does shown the Cover and the Close menuitem?

But (in DataCAD 11)
Code: Select all         2: begin
            l.CurveArg.CircOpts.pDoPlineCover := @l.ADoCover;
            l.CurveArg.CircOpts.pDoPlineClosed := @l.AIsClosed;
            L.CurveArg.CircOpts.DoPolyline := L.ADoPolyline;
            menuCurves(retval, L.CurveArg, L.ADoPolyline, @L.ADoCover, @L.AIsClosed);
         end;

this case: macro call to curve menu, but
    only the curve menu, polyline menu: no
    exit from the curve menu, do not return the macro


Please help.

What is it the correct syntax in DataCAD11, that I can call the Curve menu, or call the Polyline menu and then return the macro?


Thanks before
ERT

PostPosted: Tue Feb 12, 2008 3:22 am
by ERT
in DataCAD 11:
menuCurves procedure has an error.

Before call: L.State = 2
After call: L.State = @L.CurveArg.CircOptions.DoPolyline

if after call then I wrote this:
Code: Select all   ADoPoly := L.ADoPolyline;

        menuCurves(same like above);

   L.ADoPolyline := ADoPoly;
   L.CurveArg.CircOpts.DoPolyline := ADoPoly;
   L.State := 2;


Then the macro call the curve menu or polyline menu correctly.
but if click the curve menuitem and click the first point then macro out, and drawing closed.

Has the problem solving?

(I Submit this messages above and after ...)

Yes

I found the problem solving:
this is the correct type (in this case)
Code: Select alltype
   TCurvesL = record
      CurveArg: CircMenuArg;
      ADoPolyline, ADoCover, AIsClosed: Boolean;
      GetE: getescArg;
      State: aSInt;
   end ;

then correct menu calling:
Code: Select all   ADoPoly := L.ADoPolyline;
   l.CurveArg.CircOpts.pDoPlineCover := @l.ADoCover;
   l.CurveArg.CircOpts.pDoPlineClosed := @l.AIsClosed;

   menuCurves(retval, L.CurveArg, L.ADoPolyline, @L.ADoCover, @L.AIsClosed);

   L.ADoPolyline := ADoPoly;
   L.CurveArg.CircOpts.DoPolyline := ADoPoly;
   l.CurveArg.CircOpts.pDoPlineCover := @l.ADoCover;
   l.CurveArg.CircOpts.pDoPlineClosed := @l.AIsClosed;



That's all.

ERT