Solved

getting input without the enter key

Posted on 2001-09-10
8
203 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:darentan
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:darentan
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
forgot about the readkey :?


thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Delphi ADO query as a string 4 2,520
Rave Reports - Adding a Data Band 1 993
FMXGrid getting check box state 5 507
File restrict, lock. 4 209
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
In this step by step tutorial with screenshots, we will show you HOW TO: Enable SSH Remote Access on a VMware vSphere Hypervisor 6.5 (ESXi 6.5). This is important if you need to enable SSH remote access for additional troubleshooting of the ESXi hos…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now