[comp.sys.mac.programmer] in trouble between Graf3D and THINK pascal ! Help

VOIROL@rcgl1.eng.ohio-state.edu (Voirol, Philippe) (07/13/89)

I am having big trouble adding a graphical output to a
simulation program ( in Pascal ) I am working on .
(I am working with THINK Pascal 2.01 on a MacII)
  MY QUESTIONS : (see example program below for terminology)
     1) The data to be plot comes from the program in type DOUBLE
        and I convert it into Fixed using Convert() but I am getting
  sometimes a bug dialog saying ADDRESS ERROR. What's wrong ?
      2) More annoying:
         I adapted the InitGraphics part from the box drawing demo
  program which comes with TML but it is apparently not suited
  to the THINK environment because the machine crashes *BADLY*
  most of the time. I suspect a dangling pointer somewhere , I dont
  understand that business with GPort1 and GPort2 ...
  So could somebody out there tell me how to safely interface
  Graf3D with the Drawing window port in LSP
AtDhVaAnNkCsE
Philippe            e-mail : voirol%RCGL1@eng.ohio-state.edu
  Follows an example program showing what I was trying to do :
(*--------------------------------------------------------------*)
program example;
   var GPort1: GrafPort;GPort2: Port3D;myPort: GrafPtr;
       myPort3D, thePort3D: Port3DPtr;data: double;
procedure InitGraphics;
begin
  InitGrf3D(@thePort3D);GetPort(myPort);
  myPort3D := @GPort2;Open3DPort(myPort3D);
  ViewPort(myPort^.portRect);
  LookAt(wleft, wtop, wright, wbottom);{and set roll,pitch,etc...}
end;{InitGraphics}
function Convert (x: double): Fixed;const c = 65536;scal = 10;
begin  Convert := Fixed(round(c * scal * x))  end;
begin{main}
  InitGraphics;
  repeat
  {update data...}
  Draw3D(Convert(data));
  until done;
end.
Philippe Voirol
e-mail : voirol%rcgl1@eng.ohio-state.edu