tp draw - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# tp draw

Posts: 1Member
I compile an old Turbo Pascal (1987) program with

errors : illegal identifier DRAW.
=======================

What is the correct one ,

for NEW TURBO PASCAL (7.0 , FREE PASCAL) ? Thank you.

---------------------------------------------------------

procedure DrawDistribution ; {draws the distribution of weight vectors:
linear array}
const
cl = 200 ; { white ; }
xw = 320 ;
yw = 160 ;
var
x, y, xo, yo : integer ;

procedure DrawLine (i : integer) ;
begin {draw A line connecting two weight vectors}
xo := X ;
X := round ((xw div 2) * (m[i,0] + m[i+1,0])) ;
yo := Y ;
Y := round ((yw div 2) * (m[i,1] + m[i+1,1])) ;
draw (xo, yo, x, y, cl) ;
draw (x-1, y-1, x+1, y-1, cl) ;
draw (x-1, y, x+1, y, cl) ;
draw (x-1, y+1, x+1, y+1, cl) ;
end ; {DrawLine}

begin {DrawDistribution}
hires ;
{ graphbackground (black) ; }
case DensityFunction of {draw the corresponding frame}
Square : begin
draw (159, 19, 481, 19, cl) ;
draw (481, 19, 481, 181, cl) ;
draw (481, 181, 159, 181, cl) ;
draw (159, 181, 159, 19, cl) ;
end ;
triangle : begin
draw (159, 181, 481, 181, cl) ;
...............................

• Posts: 6,349Member
: I compile an old Turbo Pascal (1987) program with
:
: errors : illegal identifier DRAW.
: =======================
:
: What is the correct one ,
:
: for NEW TURBO PASCAL (7.0 , FREE PASCAL) ? Thank you.
:
: ---------------------------------------------------------
:
:
: procedure DrawDistribution ; {draws the distribution of weight vectors:
: linear array}
: const
: cl = 200 ; { white ; }
: xw = 320 ;
: yw = 160 ;
: var
: x, y, xo, yo : integer ;
:
: procedure DrawLine (i : integer) ;
: begin {draw A line connecting two weight vectors}
: xo := X ;
: X := round ((xw div 2) * (m[i,0] + m[i+1,0])) ;
: yo := Y ;
: Y := round ((yw div 2) * (m[i,1] + m[i+1,1])) ;
: draw (xo, yo, x, y, cl) ;
: draw (x-1, y-1, x+1, y-1, cl) ;
: draw (x-1, y, x+1, y, cl) ;
: draw (x-1, y+1, x+1, y+1, cl) ;
: end ; {DrawLine}
:
: begin {DrawDistribution}
: hires ;
: { graphbackground (black) ; }
: case DensityFunction of {draw the corresponding frame}
: Square : begin
: draw (159, 19, 481, 19, cl) ;
: draw (481, 19, 481, 181, cl) ;
: draw (481, 181, 159, 181, cl) ;
: draw (159, 181, 159, 19, cl) ;
: end ;
: triangle : begin
: draw (159, 181, 481, 181, cl) ;
: ...............................
:
It looks like Draw() is a user-defined procedure, which calls MoveTo() and LineTo() to draw a line. It isn't so hard to code it again. Other than that, it should run on both versions of Pascal.