Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Hypo please help again( FUNCTION KEYS)

Posted on 2000-03-24
7
Medium Priority
?
199 Views
Last Modified: 2010-04-16
I need to know how to implement this knowledge of the function keys into a case statement.
What I want to do is say in the program is IF this button (i.e F1) is pressed THEN do this. I need to know how to write this up.
THANKYOU.
0
Comment
Question by:Waulsy
[X]
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
  • 4
  • 2
7 Comments
 
LVL 6

Expert Comment

by:My name is Mud
ID: 2656072
Program FunctionKeys;
USES
  CRT;
CONST
  Special: Boolean = False;
VAR
  Key: Char;

Begin
  Repeat
    Key:=#0;
    If KeyPressed Then
      Begin
        Key:=ReadKey;
        If Key = #0 Then
          Begin
            Special:=True;
            Key:=ReadKey;
          End
        Else Special:=False;
      End;
    Case Key Of
      #59:
        If Not Special Then
          WriteLn('Key ',Key,' Pressed...')
        Else
          WriteLn('Key F1 Special Pressed...');
      #60:
        If Not Special Then
          WriteLn('Key ',Key,' Pressed...')
        Else
          WriteLn('Key F2 Special Pressed...');
      #61:
        If Not Special Then
          WriteLn('Key ',Key,' Pressed...')
        Else
          WriteLn('Key F3 Special Pressed...');
      #62:
        If Not Special Then
          WriteLn('Key ',Key,' Pressed...')
        Else
          WriteLn('Key F4 Special Pressed...');
      #63:
        If Not Special Then
          WriteLn('Key ',Key,' Pressed...')
        Else
          WriteLn('Key F5 Special Pressed...');
      #64:
        If Not Special Then
          WriteLn('Key ',Key,' Pressed...')
        Else
          WriteLn('Key F6 Special Pressed...');
      #65:
        If Not Special Then
          WriteLn('Key ',Key,' Pressed...')
        Else
          WriteLn('Key F7 Special Pressed...');
      #66:
        If Not Special Then
          WriteLn('Key ',Key,' Pressed...')
        Else
          WriteLn('Key F8 Special Pressed...');
      #67:
        If Not Special Then
          WriteLn('Key ',Key,' Pressed...')
        Else
          WriteLn('Key F9 Special Pressed...');
      #68:
        If Not Special Then
          WriteLn('Key ',Key,' Pressed...')
        Else
          WriteLn('Key F10 Special Pressed...');
      Else If (Key <> #0) And Not Special Then
        WriteLn('Key ',Key,' Pressed...')
      Else If (Key <> #0) And Special Then
        WriteLn('Key ',Key,' Pressed, This is a Special Key...')
    End;
  Until (Key = #27) And Not Special
End.
0
 
LVL 49

Expert Comment

by:dbrunton
ID: 2656202
I don't think that's what he wants.  More like this.  Note this code was thrown together on the screen and not tested.

procedures DoHelp, DoFind are the procedures that are called when you press the corresponding key

procedure Menu(special_keypress : char);
begin
  case special_kepress of
     #59 : DoHelp; {F1 key pressed}
     #60 : DoFind; {F2 key pressed}
     #61 : DoExit;  {F3 key pressed}
     #107: DoCloes; {ALT-F4 key pressed}
 else
     ;   {Do Nothing}
  end;  
end;

If KeyPressed Then
  Begin
    Key := ReadKey;
    If Key = #0 then  {should really check if #224 has been entered as well}
      Begin
         Special:=True;
          Key:= ReadKey;
          Menu(Key);
             
We did use some of Whatboy's code here.  I don't thnk he'll mind.  :)      
0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 2656216
OK... Let him/her decide...
0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
LVL 12

Accepted Solution

by:
Hypo earned 150 total points
ID: 2656287
Here's that example again Waulsy, a bit modifyed though... ;)
Is this what you want?

regards Hypo

Program GetKeys;

uses crt;

var Ext : boolean;
    Key : byte;

Procedure GetKey;
begin
  Key := ord(Readkey);
  if Key = 0 then begin
   Key := ord(Readkey);
   Ext := true;
  end else Ext := false;
end;

begin
 ClrScr;
 repeat
  GetKey;
  GotoXy(1,1);
  clreol;
  Write('Key: ',Key:3,'  Extended: ',Ext:5,' - ');
  If Ext then
  { F1..F10 are extended keys and have the scancodes between 59-68 }
   Case Key of
    59 : Writeln('You pressed F1');
    60 : Writeln('You pressed F2');
    61 : Writeln('You pressed F3');
    62 : Writeln('You pressed F4');
    63 : Writeln('You pressed F5');
    64 : Writeln('You pressed F6');
    65 : Writeln('You pressed F7');
    66 : Writeln('You pressed F8');
    67 : Writeln('You pressed F9');
    68 : Writeln('You pressed F10');
   end;
 until Key = 27;
end.

0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 2656438
I have another one...

Program KeyChecker;

Procedure HiHeadWithHammer;
begin
  Call(Hammer);
  Use.Hammer;
End;

Procedure checkKeys;
Begin
  If Key not in [pocket,desk,TV] Then
    Begin
       If Replace.Key do
         Use.Key;
       Else
         While Seek.Key Do
           HitHeadWithHammer;
    End
End;

Begin
  CheckKeys;
End.
0
 
LVL 12

Expert Comment

by:Hypo
ID: 2656553
hehehe... annoyed by the fact that my program looks very much like yours???
well... whatboy, The reason I posted my comment was because of Waulsy's old question I answered.
http://www.experts-exchange.com/jsp/qShow.jsp?ta=pascal&qid=10316655 

0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 2657517
Nope...
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

604 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