[Pascal] Lỗi exitcode 201 và 2

Thảo luận trong 'Lập trình C++'

  1. tunep [Thành viên mới]

    Code:
    PROGRAM dictionary;
    USES crt;
    TYPE banghi = RECORD
    W: STRING;
    T: STRING;
    M: STRING;
    END;
    VAR Enw,Ent,Enm,Vit,Vil,Vin: TEXT; {bien tep}
    F: ARRAY [1..100] OF banghi; {mang luu du lieu tam thoi}
    soluong: LONGINT; {bien lu so luong tu}
    td: STRING; {bien danh dau tu dien dang dung}
    PROCEDURE Information;
    BEGIN
    writeln ('hoho hihi hehe');
    readln;
    END;

    PROCEDURE Menuchinh;FORWARD;
    PROCEDURE Menuphu1;FORWARD;
    PROCEDURE Menuphu2;FORWARD;
    PROCEDURE Menuphu11;FORWARD;
    PROCEDURE Menuphu21;FORWARD;

    PROCEDURE ghidulieu;
    VAR i:INTEGER;
    BEGIN
    clrscr;
    IF td='2' THEN
    BEGIN
    rewrite(Vit);rewrite(Vil);rewrite(Vin);
    FOR i:= 1 TO soluong DO
    BEGIN
    writeln (Vit,F.W);
    writeln (Vil,F.T);
    writeln (Vin,F.M);
    END;
    close(Vit);close(Vil);Close(Vin);
    Menuphu11;
    END
    ELSE
    BEGIN
    clrscr;
    rewrite(Enw);rewrite(Ent);rewrite(Enm);
    FOR i:= 1 TO soluong DO
    BEGIN
    writeln (Enw,F.W);
    writeln (Ent,F.T);
    writeln (Enm,F.M);
    END;
    close(Enw);close(Ent);Close(Enm);
    Menuphu11;
    END;
    END;

    PROCEDURE taidulieu;
    VAR i: INTEGER;
    BEGIN
    IF td='2' THEN
    BEGIN
    clrscr;
    reset (Vit);reset(Vil);reset(Vin);
    WHILE NOT (eof(Vit)AND eof(Vil) AND eof(Vin)) DO
    BEGIN
    i:= i+1;
    IF NOT (eoln(Vit)AND eoln(Vil) AND eoln(Vin)) THEN
    BEGIN
    read (Vit,F.W);
    read (Vil,F.T);
    read (Vin,F.M);
    END
    ELSE
    BEGIN
    readln(Vit);readln(Vil);readln(Vin);
    END;
    soluong:=i-1;
    END;
    close(Vit);close(Vil);Close(Vin);
    END
    ELSE
    BEGIN
    clrscr;
    reset (Enw);reset(Ent);reset(Enm);
    WHILE NOT (eof(Enw)AND eof(Ent) AND eof(Enm)) DO
    BEGIN
    i:= i+1;
    IF NOT (eoln(Enw)AND eoln(Ent) AND eoln(Enm)) THEN
    BEGIN
    read (Enw,F.W);
    read (Enw,F.T);
    read (Enw,F.M);
    END
    ELSE
    BEGIN
    readln(Enw);readln(Ent);readln(Enm);
    END;

    END;
    close(Enw);close(Ent);Close(Enm);
    soluong:=i-1;
    END;
    END;
    PROCEDURE contain;
    BEGIN
    clrscr;
    writeln('contain');
    readln;
    Menuphu21;
    END;

    PROCEDURE lastword;
    BEGIN
    clrscr;
    writeln('lastword');
    readln;
    Menuphu21;
    END;

    PROCEDURE addd;
    BEGIN
    clrscr;
    writeln('add');
    readln;
    Menuphu11;
    END;

    PROCEDURE delete;
    BEGIN
    clrscr;
    writeln('delete');
    readln;
    Menuphu11;
    END;

    PROCEDURE change;
    BEGIN
    clrscr;
    writeln('change');
    readln;
    Menuphu11;
    END;

    PROCEDURE save;
    BEGIN
    clrscr;
    writeln('save');
    readln;
    Menuphu11;
    END;

    PROCEDURE Data;
    BEGIN
    clrscr;
    writeln ('[1] Anh-Viet');
    writeln ('[2] Viet-Anh');
    REPEAT
    IF ((td <> '1' ) AND (td <> '2')) THEN
    BEGIN
    write ('-> Nhap lai: ');
    readln (td);
    END;
    UNTIL ((td='1') OR (td='2'));
    taidulieu;
    END;

    PROCEDURE Searchnormal;
    BEGIN
    clrscr;
    writeln ('Searchnormal');
    readln;
    Menuphu2;
    END;
    PROCEDURE menuphu11;
    VAR lc:STRING;
    BEGIN
    clrscr;
    writeln ('[1] Add');
    writeln ('[2] Change');
    writeln ('[3] Delete');
    writeln ('[4] Save your edit');
    write ('-> ');
    readln (lc);
    REPEAT
    IF (lc <> '1' ) AND (lc <> '2') AND (lc<>'3') AND (lc<>'4') AND (lc<>'0') THEN
    BEGIN
    write ('-> Nhap lai: ');
    readln (lc);
    END;
    UNTIL ((lc='1') OR (lc='2') OR (lc='3') OR (lc='4') OR (lc='0'));
    IF lc='1' THEN Addd ELSE IF lc='2' THEN Change
    ELSE IF lc='3' THEN Delete
    ELSE IF lc='4' THEN save
    ELSE IF lc='0' THEN Menuphu1;
    END;

    PROCEDURE menuphu21;
    VAR lc: STRING;
    BEGIN
    clrscr;
    writeln ('[1] Last word');
    writeln ('[2] Contain');
    write ('-> ');
    readln (lc);
    REPEAT
    IF (lc <> '1' ) AND (lc <> '2') AND (lc<>'0') THEN
    BEGIN
    write ('-> Nhap lai: ');
    readln (lc);
    END;
    UNTIL ((lc='1') OR (lc='2') OR (lc='0'));
    IF lc='1' THEN Lastword ELSE IF lc='2' THEN Contain ELSE IF lc='0' THEN Menuphu2;
    END;

    PROCEDURE menuphu2;
    VAR lc: STRING;
    BEGIN
    clrscr;
    writeln ('[1] Search normal');
    writeln ('[2] Search advanced');
    write ('-> '); readln (lc);
    REPEAT
    IF (lc <> '1' ) AND (lc <> '2') AND (lc<>'0') THEN
    BEGIN
    write ('-> Nhap lai: ');
    readln (lc);
    END;
    UNTIL ((lc='1') OR (lc='2') OR (lc='0'));
    IF lc='1' THEN Searchnormal ELSE IF lc='2' THEN Menuphu21 ELSE IF lc='0' THEN Menuchinh;
    END;

    PROCEDURE menuphu1;
    VAR lc: STRING;
    BEGIN
    clrscr;
    writeln ('[1] Data');
    writeln ('[2] Edit');
    write ('-> ');
    readln (lc);
    REPEAT
    IF ((lc <> '1' ) AND (lc <> '2') AND (lc<> '0'))THEN
    BEGIN
    write ('-> Nhap lai: ');
    readln (lc);
    END;
    UNTIL ((lc='1') OR (lc='2') OR (lc='0'));
    IF lc='1' THEN Data ELSE IF lc='2' THEN menuphu11 ELSE IF lc='0' THEN menuchinh;
    END;

    PROCEDURE menuchinh;
    VAR lc:STRING;
    BEGIN
    clrscr;
    textcolor(yellow);writeln('HOME');textcolor(white);
    writeln ('[1] Dictionary');
    writeln ('[2] Search');
    writeln ('[3] How to use this software and informations');
    write ('-> ');
    readln (lc);
    REPEAT
    IF (lc <> '1') AND (lc <> '2') AND (lc <> '3') AND (lc<>'0') THEN
    BEGIN
    write ('-> Nhap lai: ');
    readln (lc);
    END;
    UNTIL (((lc='1') OR (lc='2') OR (lc='3') OR (lc='0')));
    IF lc='1' THEN menuphu1
    ELSE IF lc='3' THEN Information
    ELSE IF lc='2' THEN Menuphu2;
    END;

    BEGIN
    clrscr;
    assign (Enw,'C:\Dictionary\EnVi\Word.txt');
    assign (Ent,'C:\Dictionary\EnVi\Wordtype.txt');
    assign (Enm,'C:\Dictionary\EnVi\Meaning.txt');
    assign (Vit,'C:\Dictionary\ViEn\Tu.txt');
    assign (Vil,'C:\Dictionary\ViEn\Loaitu.txt');
    assign (Vin,'C:\Dictionary\ViEn\Nghia.txt');
    menuchinh;
    END.
    Đây là phần mêm từ điển em nộp cho trường, các phần khác thì ko có gì tuy nhiên khi vào data để chọn từ điển nếu chon Anh-Viet thì văng ra exitcode là 201 còn viet-anh thì 2 @@. Em chỉ mới viết 1 nửa, các phần còn lại đều ổn. Em nghĩ là ct con taidulieu có vấn đề.

Chia sẻ trang này