Enter required 
Author Message
 Enter required

I am doing learning Pascal for school and have been given a problem which we
have to  program

The program is a simple home loan calculator. Basically I have to present a
menu to the user which they can choose 4 options. Is it possible to make
pascal select their choice without the user having to press enter. Or be
able for the user to enter a number and press enter, but to not show it on
the screen (apart from using black color font)?



Wed, 18 Jun 1902 08:00:00 GMT  
 Enter required
use function readkey:char; {in Unit CRT}

You can read a key whthout pressing the enter.
It does not show the char on the screen.

eg.

uses crt;

{  note: if you encounter an RunTime Error 200: Divide by zero}
{  then you need to install a bug patch for unit crt. see end of message}

var c:char;
begin
{blah...}
  {write your menu}
  c:=readkey;
  case c of
    '0': {...};
    '1': {...};
    'a': {...};  {note that 'a' and 'A' are treated differently}
  end;
{blah...}
end.

{copied from TSFAQP a FAQ for Pascal. just try one of them}

Prevent the "Divide by 0" error, Roger Donais. You'll need
ftp://users.southeast.net/private/rdonais/rdelay.zip
ftp://users.southeast.net/private/rdonais/util.zip

NewDelay, Fix for bug in Crt unit's Delay procedure, by F.Heckenbach
http://fjf.gnu.de/programs.html#NewDelay

Problems with the Crt.Delay procedure, by Dr John Stockton
http://www.merlyn.demon.co.uk/pas-r200.htm

Fix for "Runtime Error 200" bug of Borland Pascal 7 on fast PCs,
by Klaus Hartnegg
http://www.brain.uni-freiburg.de/~klaus/pascal/runerr200/

Roger's solution is also available as (or whichever version numbers
are current when you read this):
4903 Jan 20 1997 ftp://garbo.uwasa.fi/pc/turbopas/rdelay10.zip
rdelay10.zip Prevent the divide-by-0 Crt error on fast machines, R.Donais
:
56849 Jun 21 1997 ftp://garbo.uwasa.fi/pc/turbopas/rutil10.zip
rutil10.zip Turbo Pascal utilities by R.Donais, (needed by rdelay)

Then there also is
ftp://garbo.uwasa.fi/pc/turbspec/bp7patch.zip
CRT Delay patch for TURBO.TPL 48,432 10-27-92 7:00a
and probably later versions in circulation.


Quote:
>I am doing learning pascal for school and have been given a problem which
we
>have to  program

>The program is a simple home loan calculator. Basically I have to present a
>menu to the user which they can choose 4 options. Is it possible to make
>pascal select their choice without the user having to press enter. Or be
>able for the user to enter a number and press enter, but to not show it on
>the screen (apart from using black color font)?



Wed, 18 Jun 1902 08:00:00 GMT  
 Enter required
It is possible:

uses crt;
var  bla:char;

begin
 bla:=readkey;
end.



Quote:
> I am doing learning pascal for school and have been given a problem which
we
> have to  program

> The program is a simple home loan calculator. Basically I have to present
a
> menu to the user which they can choose 4 options. Is it possible to make
> pascal select their choice without the user having to press enter. Or be
> able for the user to enter a number and press enter, but to not show it on
> the screen (apart from using black color font)?



Wed, 18 Jun 1902 08:00:00 GMT  
 Enter required

Quote:

> I am doing learning pascal for school and have been given a problem which we
> have to  program

> The program is a simple home loan calculator. Basically I have to present a
> menu to the user which they can choose 4 options. Is it possible to make
> pascal select their choice without the user having to press enter. Or be
> able for the user to enter a number and press enter, but to not show it on
> the screen (apart from using black color font)?

if you want something REALLY COOL (not that much after all), try this :
it runs under my DOS (maybe it could be adapted, idonot know)

USES CRT;
VAR com : char;
        o : shortint;

o:=0;
gotoxy(x,y); write('OPTION1');
gotoxy(x,y+1);write('OPT2); and so on...
repeat
  gotoxy(x-2,y+o); write('>');       {this is a cursor}
  com:=readkey;
  if com=#0 then begin
    com:=readkey;
    gotoxy(x-2,y+o); write(' '); {clean the cursor position}
    case com of
      #72 : dec(o); {UP key}
      #80 : inc(o); {DOWN key}
    end;
    if o<0 then o:={number of the last option, four in your case};
    if o>numberlastoption then o:=0;
  end;
  if com IN [#13,#32] then case o of {SPACE or ENTER}
    1 : launch option 1
    2 : launch opt2, etc..
  end;
until com=#27; {ESCAPE}



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Q: Enter = Tab in GRIDs ?

2. MemDB - Memory Database Expert enters public beta

3. Enter=TAB?

4. Enter as Tab

5. Enter to next column in dbgrid

6. Using ENTER to change fields

7. Dropping Combo on Entering Column

8. Enter and DBEdit problem

9. tecla enter no DBGrid

10. Using ENTER Key instead of TAB

11. System has been illegally re-entered.

12. TP Question: Problem with inputing integers and ENTER

 

 
Powered by phpBB® Forum Software