Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

getting input without the enter key

Posted on 2001-09-10
8
219 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Neural Networks with Delphi 3 1,604
Delphi, how to Format DateTime values bigger than 24h in 'hh:nn:ss' format 5 1,521
copy one tchart to another 1 534
Secure Boot on W8 & 8.1 8 47
Most MSPs worth their salt are already offering cybersecurity to their customers. But cybersecurity as a service is wide encompassing and can mean many things.  So where are MSPs falling in this spectrum?
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

861 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