Reputation: 21
i have this line code
GAMBAR;
SETBKCOLOR(15);
BINTANG(17,0,23,12,23,12,36,12,0,12,13,12,36,12,26,21,26,21,29,34,29,34,18,27,18,27,7,34,7,34,10,21,10,21,0,12,0,12,13,12,13,12,17,0,2);
READLN;
FOR I:= 1 TO 20 DO
BEGIN
SKALA(17,0,23,12,23,12,36,12,0,12,13,12,36,12,26,21,26,21,29,34,29,34,18,27,18,27,7,34,7,34,10,21,10,21,0,12,0,12,13,12,13,12,17,0,2,I,I,XA,YA,XB,YB,XC,YC,XD,YD,XE,YE,XF,XG,XH,XI,XJ,W);
BINTANG(XA,YA,XB,YB,XC,YC,XD,YD,XE,YE,XF,XG,XH,XI,XJ,W);
DELAY(500);
END;
READLN;
CLOSEGRAPH;
END.
But Turbo Pascal gives error "line to long"
so i tried to do this
GAMBAR;
SETBKCOLOR(15);
BINTANG(17,0,23,12,23,12,36,12,0,12,13,12,36,
12,26,21,26,21,29,34,29,34,18,27,18,27,7,
34,7,34,10,21,10,21,0,12,0,12,13,12,13,12,17,0,2);
READLN;
FOR I:= 1 TO 20 DO
BEGIN
SKALA(17,0,23,12,23,12,36,12,0,12,13,12,36,12,26,21,26,21,29,
34,29,34,18,27,18,27,7,34,7,34,10,21,10,21,0,12,0
,12,13,12,13,12,17,0,2,I,I,XA,YA,XB,YB,XC,YC,XD,YD,XE,YE,XF,XG,XH,XI,XJ,W);
BINTANG(XA,YA,XB,YB,XC,YC,XD,YD,XE,YE,XF,XG,XH,XI,XJ,W);
DELAY(500);
END;
READLN;
CLOSEGRAPH;
END.
But turbo Pascal gives error 89: ")" expected.
I searched in Google about this, but i found nothing.
so,how to solve this code in turbo pascal?
This full view code :
VAR GD,GM,XA,YA,XB,YB,W,I:INTEGER;
PROCEDURE GAMBAR;
BEGIN
GD:=VGA;
GM:=VGAHI;
INITGRAPH(GD,GM,'D:\TP\BGI');
END;
PROCEDURE BINTANG(X0,Y0,X1,Y1,X2,Y2,X3,Y3,X4,Y4,X5,X6,X7,X8,X9,C:INTEGER);
BEGIN
SETCOLOR(C);
LINE(X0,Y0,X1,Y1);
LINE(X1,Y1,X2,Y1);
LINE(X2,Y1,X3,Y2);
LINE(X3,Y2,X4,Y3);
LINE(X4,Y3,X5,Y4);
LINE(X5,Y4,X6,Y3);
LINE(X6,Y3,X7,Y2);
LINE(X7,Y2,X8,Y1);
LINE(X8,Y1,X9,Y1);
LINE(X9,Y1,X0,Y0);
END;
PROCEDURE SKALA(X0,Y0,X1,Y1,X2,Y2,X3,Y3,X4,Y4,X5,X6,X7,X8,X9,C,SX,SY:INTEGER;
VAR XA,YA,XB,YB,XC,YC,XD,YD,XE,YE,XF,XG,XH,XI,XJ,W:INTEGER);
BEGIN
XA:=X0*SX;
YA:=Y0*SY;
XB:=X1*SX;
YB:=Y1*SY;
XC:=X2*SX;
YC:=Y2*SY;
XD:=X3*SY;
YD:=Y3*SY;
XE:=X4*SY;
YE:=Y4*SY;
XF:=X5*SY;
XG:=X6*SY;
XH:=X7*SY;
XI:=X8*SY;
XJ:=X9*SY;
W:=C+2;
END;
{PROGRAM UTAMA}
BEGIN
GAMBAR;
SETBKCOLOR(15);
BINTANG(17,0,23,12,23,12,36,12,0,12,13,12,36,12,26,21,26,21,29,34,29,34,18,27,18,27,7,34,7,34,10,21,10,21,0,12,0,12,13,12,13,12,17,0,2);
READLN;
FOR I:= 1 TO 20 DO
BEGIN
SKALA(17,0,23,12,23,12,36,12,0,12,13,12,36,12,26,21,26,21,29,34,29,34,18,27,18,27,7,34,7,34,10,21,10,21,0,12,0,12,13,12,13,12,17,0,2,I,I,XA,YA,XB,YB,XC,YC,XD,YD,XE,YE,XF,XG,XH,XI,XJ,W);
BINTANG(XA,YA,XB,YB,XC,YC,XD,YD,XE,YE,XF,XG,XH,XI,XJ,W);
DELAY(500);
END;
READLN;
CLOSEGRAPH;
END.
Thank...
Upvotes: 2
Views: 707
Reputation: 34909
The number of parameters in a procedure must be matched in the procedure call.
The BINTANG()
procedure has 16 parameters, but in the first call you are passing 45 parameters, which is why the compiler complains. The second call is correct though.
Note also that there is a mismatch with the number of parameters in the call to SKALA()
.
About the maximum program line length in Turbo Pascal. It is 127. If a line is longer than that, you will have to split the line to match that limit.
If you want to pass different number of (X,Y) pairs to a line-drawing procedure, learn how to use DrawPoly(NumPoints: word; var PolyPoints)
.
Example :
const
Triangle : array[1..4] of PointType =
((x: 50; y: 100),
(x: 100; y: 100),
(x: 150; y: 150),
(x: 50; y: 100));
...
DrawPoly(SizeOf(Triangle) div SizeOf(PointType),Triangle);
PointType
is a predefined type declared in the Graph unit.
This will require a bit of work, but is a step into structured programming.
Upvotes: 2