Please check This Unit...

Greetings,

Question 1:
How come when I read other ppl's code, I can't seem to understand them? There are just syntax which I neve saw before...

Question 2:
Well, below is a unit which I'm unable to get running. My compiler keeps on telling me about this error at the end of file, but I can't seem to see the error myself... Please, if anyone does see the error, please tell me what it is.

[size=1]
unit menuselection;

interface
procedure menuselection (var iup, idown, ileft, iright, iintx, iinty, iformat, isummon : integer);

implementation

uses crt;

procedure menuselection (var iup, idown, ileft, iright, iintx, iinty, iformat, isummon : integer);

var iupcount, idowncount, ileftcount, irightcout : integer;
var ch : char;

begin
repeat
ch := readkey;
gotoxy (iintx, iinty);
writeln ('*');

if ch = #72 then {down}
begin
if idown = 1 then
begin
gotoxy (iintx, iinty);
writeln (' ');
iinty := iinty + 1;
end
else
begin
end;
end
else if ch = #75 then {left}
begin
if ileft = 1 then
begin
gotoxy (iintx, iinty);
writeln (' ');
iintx := iintx - 1;
end
else
begin
end;
end
else if ch = #77 then {right}
begin
if iright = 1 then
begin
gotoxy (iintx, iinty);
writeln (' ');
iintx := iintx + 1;
end
else
begin
end;
end
else if ch = #80 then {up}
begin
if iup = 1 then
begin
gotoxy (iintx, iinty);
writeln (' ');
iinty := iinty - 1;
end
else
begin
end;
end
else
begin
end;

repeat until ch = #13;

if ch = #13 then
begin
end;

end;
[/size]

Comments

  • : Greetings,
    :
    : Question 1:
    : How come when I read other ppl's code, I can't seem to understand them? There are just syntax which I neve saw before...
    :
    : Question 2:
    : Well, below is a unit which I'm unable to get running. My compiler keeps on telling me about this error at the end of file, but I can't seem to see the error myself... Please, if anyone does see the error, please tell me what it is.
    :
    : [code]
    : unit menuselection;
    :
    : interface
    : procedure menuselection (var iup, idown, ileft, iright, iintx, iinty, iformat, isummon : integer);
    :
    : implementation
    :
    : uses crt;
    :
    : procedure menuselection (var iup, idown, ileft, iright, iintx, iinty, iformat, isummon : integer);
    :
    : var iupcount, idowncount, ileftcount, irightcout : integer;
    : var ch : char;
    :
    : begin
    : repeat
    : ch := readkey;
    : gotoxy (iintx, iinty);
    : writeln ('*');
    :
    : if ch = #72 then {down}
    : begin
    : if idown = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iinty := iinty + 1;
    : end
    : else
    : begin
    : end;
    : end
    : else if ch = #75 then {left}
    : begin
    : if ileft = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iintx := iintx - 1;
    : end
    : else
    : begin
    : end;
    : end
    : else if ch = #77 then {right}
    : begin
    : if iright = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iintx := iintx + 1;
    : end
    : else
    : begin
    : end;
    : end
    : else if ch = #80 then {up}
    : begin
    : if iup = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iinty := iinty - 1;
    : end
    : else
    : begin
    : end;
    : end
    : else
    : begin
    : end;
    :
    : repeat until ch = #13;
    :
    : if ch = #13 then
    : begin
    : end;
    :
    : end;
    : [/code]


    Maybe you could point to the line with the error, and give the error message?
  • : Greetings,
    :
    : Question 1:
    : How come when I read other ppl's code, I can't seem to understand them? There are just syntax which I neve saw before...
    :
    : Question 2:
    : Well, below is a unit which I'm unable to get running. My compiler keeps on telling me about this error at the end of file, but I can't seem to see the error myself... Please, if anyone does see the error, please tell me what it is.
    :
    [code]
    : unit menuselection;
    :
    : interface
    : procedure menuselection (var iup, idown, ileft, iright, iintx, iinty, iformat, isummon : integer);
    :
    : implementation
    :
    : uses crt;
    :
    : procedure menuselection (var iup, idown, ileft, iright, iintx, iinty, iformat, isummon : integer);
    :
    : var iupcount, idowncount, ileftcount, irightcout : integer;
    : var ch : char;
    :
    : begin
    : repeat
    : ch := readkey;
    : gotoxy (iintx, iinty);
    : writeln ('*');
    :
    : if ch = #72 then {down}
    : begin
    : if idown = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iinty := iinty + 1;
    : end
    : else
    : begin
    : end;
    : end
    : else if ch = #75 then {left}
    : begin
    : if ileft = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iintx := iintx - 1;
    : end
    : else
    : begin
    : end;
    : end
    : else if ch = #77 then {right}
    : begin
    : if iright = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iintx := iintx + 1;
    : end
    : else
    : begin
    : end;
    : end
    : else if ch = #80 then {up}
    : begin
    : if iup = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iinty := iinty - 1;
    : end
    : else
    : begin
    : end;
    : end
    : else
    : begin
    : end;
    :
    : repeat until ch = #13;
    :
    : if ch = #13 then
    : begin
    : end;
    :
    : end;
    [b] Begin
    End.[/b]
    [/code]

    You need to have a main procedure in Units, even if there is nothing contained in it. Anything in here is run immediately when the program is loaded (before the main program's Main procedure)

    Phat Nat
  • The name of the unit must be the same as the name of the file wer the unit code will be compiled. In MS-DOS a file can only be for 8 chars long.
    At your unit you should try to rename it from
    menuselection -> "menusel" and save it in a file named "menusel".
  • : Greetings,
    :
    : Question 1:
    : How come when I read other ppl's code, I can't seem to understand them? There are just syntax which I neve saw before...
    :
    : Question 2:
    : Well, below is a unit which I'm unable to get running. My compiler keeps on telling me about this error at the end of file, but I can't seem to see the error myself... Please, if anyone does see the error, please tell me what it is.
    :
    : [size=1]
    : unit menuselection;
    :
    : interface
    : procedure menuselection (var iup, idown, ileft, iright, iintx, iinty, iformat, isummon : integer);
    :
    : implementation
    :
    : uses crt;
    :
    : procedure menuselection (var iup, idown, ileft, iright, iintx, iinty, iformat, isummon : integer);
    :
    : var iupcount, idowncount, ileftcount, irightcout : integer;
    : var ch : char;
    :
    : begin
    : repeat
    : ch := readkey;

    : gotoxy (iintx, iinty);
    : writeln ('*');
    :
    : if ch = #72 then {down}
    : begin
    : if idown = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : inty := iinty + 1;
    : end
    : else
    : begin
    : end;
    : end
    : else
    if ch = #75 then {left}
    : begin
    : if ileft = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iintx := iintx - 1;
    : end
    : else
    : begin
    : end;
    : end
    : else
    if ch = #77 then {right}
    : begin
    : if iright = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iintx := iintx + 1;
    : end
    : else
    : begin
    : end;
    : end
    : else
    if ch = #80 then {up}
    : begin
    : if iup = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iinty := iinty - 1;
    : end
    : else
    : begin
    : end;
    : end
    : else
    : begin
    : end;
    :
    : repeat until ch = #13;
    :
    : if ch = #13 then
    : begin
    : end;
    :
    : end;
    :
    : [/size]
    :
    : The only thing that I can see wrong with this program is you forgot to put an [ end. ] at the end of your unit. See below to see corrected code.

    : [size=1]
    : unit menuselection;
    :
    : interface
    : procedure menuselection (var iup, idown, ileft, iright, iintx, iinty, iformat, isummon : integer);
    :
    : implementation
    :
    : uses crt;
    :
    : procedure menuselection (var iup, idown, ileft, iright, iintx, iinty, iformat, isummon : integer);
    :
    : var iupcount, idowncount, ileftcount, irightcout : integer;
    : var ch : char;
    :
    : begin
    : repeat
    : ch := readkey;

    : gotoxy (iintx, iinty);
    : writeln ('*');
    :
    : if ch = #72 then {down}
    : begin
    : if idown = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : inty := iinty + 1;
    : end
    : else
    : begin
    : end;
    : end
    : else
    if ch = #75 then {left}
    : begin
    : if ileft = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iintx := iintx - 1;
    : end
    : else
    : begin
    : end;
    : end
    : else
    if ch = #77 then {right}
    : begin
    : if iright = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iintx := iintx + 1;
    : end
    : else
    : begin
    : end;
    : end
    : else
    if ch = #80 then {up}
    : begin
    : if iup = 1 then
    : begin
    : gotoxy (iintx, iinty);
    : writeln (' ');
    : iinty := iinty - 1;
    : end
    : else
    : begin
    : end;
    : end
    : else
    : begin
    : end;
    :
    : repeat until ch = #13;
    :
    : if ch = #13 then
    : begin
    : end;
    :
    : end;
    : end. <- put [ end. ] here
    : [/size]

Sign In or Register to comment.

Howdy, Stranger!

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

Categories