Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

getting input without the enter key

Posted on 2001-09-10
8
Medium Priority
?
249 Views
Last Modified: 2010-04-16
An example

if i have a value and i would like to use the plus key to increase the value and the minus key to decrease the value, and i would not like to press + follow by enter or - follow by enter, is there any way where i can interactively see the my value on screen with the press of + and - key ??.
 Notes - normal screen , not using turbo vision or the menu interface pls.
0
Comment
Question by:darentan
  • 5
  • 3
8 Comments
 
LVL 6

Expert Comment

by:My name is Mud
ID: 6473283
You can use a loop of some kind, like while or repeat on the main program, and exit on esc, for example...

Var
  A: Integer;
  Key: Char;

Begin
  A:=0;
  Repeat
    If keypressed Then
      begin
        Key:=RedKey;
        If Key = #0 Then  {Take off the first char of the control code key}
          Key:=RedKey;
      end;
    Case Key Of
      "+":
        Begin
          Inc(A);       {Increment A}
          Key:=#0;   {Make Key other than what it is, to avoid repeat without pressing a key}
        End;
      "-":
        Begin
          Dec(A);     {Decrement A}
          Key:=#0;   {Same as above}
        End;
    End;
  Until key = #27 {Exit on "esc" key}
End.
0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 6473288
BTW if you receive some help on this question http://www.experts-exchange.com/jsp/qShow.jsp?ta=pascal&qid=11303078 or if you did not, you should awarded or delete it...
0
 
LVL 6

Accepted Solution

by:
My name is Mud earned 200 total points
ID: 6473306
Oh forgot to tell you that with a ReadKey, you don't need to press the Enter key, that function returns the KeyCode of the key a user has pressed... for example...


If the user press "+" on the NumPad it will return a keyCode of 43, "-" 45...

If a user press F1 it will return... hey why don't you try it... use it with "shift", "Ctrl" and "Alt" and any other combinations...

****************************************************************
Program Test_Key_Pressed;
Uses
  Crt;
Var
  Key: Char;

Begin
  Repeat
    If KeyPressed Then
      Begin
        Key:=ReadKey;
        If Key = #0 Then
          Begin
            Write(0:3);
            Key:=ReadKey;
          End;
        WriteLn(Byte(Key):3,Char(Key):3);
      End
  Until Key = #27;
End.
****************************************************************
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:darentan
ID: 6473308
but if as u show above, the first key read (readln) aready require a enter key.The keypressed would requir a readln input, errr...
0
 

Author Comment

by:darentan
ID: 6473311
Sorry about that, i did not refresh my screen as it show the first comment, i trying it out now
0
 

Author Comment

by:darentan
ID: 6473328
Sorry about that, i did not refresh my screen as it show the first comment, i trying it out now
0
 

Author Comment

by:darentan
ID: 6473329
Sorry about that, i did not refresh my screen as it show the first comment, i trying it out now
0
 

Author Comment

by:darentan
ID: 6473438
forgot about the readkey :?


thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have come across a situation where you need to find some EDB mailbox recovery techniques, then here you will find the same. In this article, we will take you through three techniques using which you will be able to perform EDB recovery. You …
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question