Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Please check This Unit... Posted by godsfantasy on 29 Apr 2004 at 6:53 AM
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.


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;

Report
Re: Please check This Unit... Posted by Manning on 29 Apr 2004 at 12:53 PM
: 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.
:
:
: 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;
: 



Maybe you could point to the line with the error, and give the error message?
Report
Re: Please check This Unit... Posted by Phat Nat on 29 Apr 2004 at 7:15 PM
: 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.
:
: 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;
 Begin
 End.


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
Report
Re: Please check This Unit... Posted by TGPmielu on 25 May 2004 at 9:17 AM
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".
Report
Re: Please check This Unit... Posted by Martin626 on 18 Oct 2004 at 1:09 PM
: 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.
:
:
: 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;
:
:

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

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





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.