Forum > General

How do i use units in my program?

<< < (2/2)

captian jaster:
OK heres what i dont get..

--- Code: --- unit Console;

interface

uses CRT,SysUtils,Windows,Dos,Classes;

const
 ERROR1 = 'File Not Found!';
 ERROR2 = 'Unkown Error!';

var
 Command : String;

implementation

Procedure HELP;
BEGIN
  writeln('EXIT, Close the Program');
  writeln('[OPEN]MENU, Go to the Main menu');
END;

BEGIN
  ClrScr;
  GotoXY(30,30);
  writeln('Xhydriks Version 0.00');
  writeln('By Adam N.Andujar');
  Repeat
  writeln('Awaiting Command..');
  readln(Command);
  until(Command = 'EXIT');
END.
--- End code ---

--- Code: --- program Xhydriks;

uses CRT,Console;

var
 sel : string;


BEGIN
  writeln('Welcome!');
  writeln('1. Console');
  writeln('2. Exit');
  Repeat
  sel := Readkey;
  if sel = '1' then Console
  else writeln('ERROR!, only input listed chars');
  Until(sel = '2');
END.

 
--- End code ---
it say identifier expected bu else found when i try to compile the xhydriks

Peter_Vadasz:
Try this:

Unit:

--- Code: ---unit consoleu;

interface

uses crt;

const
 ERROR1 = 'File Not Found!';
 ERROR2 = 'Unkown Error!';

 procedure Console;

implementation

var
 Command : String;
 
Procedure HELP;
BEGIN
  writeln('EXIT, Close the Program');
  writeln('[OPEN]MENU, Go to the Main menu');
END;

procedure Console;
BEGIN
  ClrScr;
  GotoXY(30,30);
  writeln('Xhydriks Version 0.00');
  writeln('By Adam N.Andujar');
  writeln;
  HELP;
  Repeat
    writeln('Awaiting Command..');
    readln(Command);
  until(Command = 'EXIT');
END;

END.
--- End code ---

program:

--- Code: ---program Xhydriks;

uses CRT,Consoleu;

var
 sel : string;

begin
  writeln('Welcome!');
  writeln('1. Console');
  writeln('2. Exit');
  Repeat
  sel := Readkey;
  if sel = '1' then Console
  else writeln('ERROR!, only input listed chars');
  Until(sel = '2');
end.
--- End code ---

captian jaster:
Thank you!

Bart:
Note: what happens if the user presses '2' ?
Try it.
Do you really want that to happen?

Bart

Navigation

[0] Message Index

[*] Previous page

Go to full version