Board index » delphi » DELPHI - ACAD QUESTION

DELPHI - ACAD QUESTION

I AM ATTEMPTING TO WRITE A REPLACEMENT FOR THE ACAD PLOT DIALOG IN
DELPHI 3 - DELPHI 4.
WHAT IS WRONG WITH THIS CODE? I GET A "TYPE MISMATCH" ON THE
"PlotObj.PlotScale := Scale;"
STATEMENT.

VAR
  PlotObj : oleVariant;

...
...
...

procedure TMPlotForm.SetPlotScale;

var
  Scale : oleVariant;

begin
  Scale := VarArrayCreate([0, 1], varDouble);
  if Scale2Fit.Checked then begin
    Scale[0] := -1;
    Scale[1] := -1;
  end else begin
    Scale[0] := txtScale.Text;
    Scale[1] := txtPlotUnits.Text;
  end;
  PlotObj.PlotScale := Scale;
end;

 

Re:DELPHI - ACAD QUESTION


Ron
Quite a lot of ACAD functions take arrays of doubles as parameters.
Having constructed them, as you do, as varaiant arrays of doubles, they
fail at run time with the same "type mismatch" error. The answer seems
to be to first convert your array into an array reference. This seems to
answer your case too. So, declare another variant and do this:
  OtherVariant := VarArrayRef(Scale);
  PlotObj.PlotScale := OtherVariant;
or more simply replace your last line with
  PlotObj.PlotScale := VarArrayRef(Scale);
As far as I've tested, this works.
By the way, do the lines in your else clause work? You seem to be
assigning text to a double.
Good luck, Alex

Other Threads