Solved

getting input without the enter key

Posted on 2001-09-10
8
225 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 50 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
Building a cohesive image for your brand is vital to making an impression on consumers. When the economy is tough, brands do better than unbranded  products. This can have a huge impact on your long-term profits, as the economy goes up and down.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

713 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