2

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...

RIZKY A
  • 21
  • 3
  • 1
    Turbo Pascal has hard limits on line length. But your problem looks to be trying to pass too many arguments to a procedure. This might be another hard limit in TP, but you should verify that the target procedure and the invocation match. – Dúthomhas Nov 11 '21 at 03:54
  • Without the declaration of `BINTANG` and `SKALA` it is hard to give an answer. One note is that the number of arguments to `BINTANG` differs in your calls. I'm sure the compiler also gives a clear notation at the position of the error. – LU RD Nov 11 '21 at 06:12
  • I just edited it to show declare `BINTANG` and `SKALA` in the question column. I hope it can help me solve this problem. Thank.. – RIZKY A Nov 11 '21 at 06:31
  • Next time indicate, in addition to the error you receive, *where* that error happens. – linuxfan says Reinstate Monica Nov 11 '21 at 09:39

1 Answers1

2

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.

LU RD
  • 34,438
  • 5
  • 88
  • 296
  • How to split the line? sorry can you answer include the solve code, please... i'm newbie in this I want to display on output the star object by using `for` – RIZKY A Nov 11 '21 at 07:45
  • The correct way to split a line was given in the question. As for how to making the program work, see my last edit that explains how to draw lines between points. This can be expanded with different number of points. – LU RD Nov 11 '21 at 10:58