Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 13-01-2007, 01:34 PM   #1 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Question ASCII Code confusion

I m working on a project in C++. The prob I m facing is to distinguish between ASCII Codes, since some ASCII codes have two keys for them.

Code:
ASCII Code     Key-1     Key-2

  59            ;         F1
  60            <         F2
  .             =          .
  .             >          .
  .             ?          .
  .             @          .
  .             A          .
  .             B          .
  .             C          .
  68            D         F10

  71            Home      G
  82            Insert    R
                                        etc.
So how to a write program which scan any key but can distinguish between them.
__________________
Minds are like Parachutes They work best when open
n2casey is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 13-01-2007, 03:08 PM   #2 (permalink)
GUNNING DOWN TEAMS
 
wizrulz's Avatar
 
Join Date: Mar 2005
Location: MUMBAI
Posts: 1,724
Default Re: ASCII Code confusion

REFER THIS..mi8 help u

http://www.ascii.cl/
__________________
The moment U stop learning ......u stop improving
wizrulz is offline  
Old 13-01-2007, 03:32 PM   #3 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Question Re: ASCII Code confusion

Quote:
Originally Posted by wizrulz
REFER THIS..mi8 help u

http://www.ascii.cl/
I already know about that link but don't get nething there.
__________________
Minds are like Parachutes They work best when open
n2casey is offline  
Old 13-01-2007, 05:25 PM   #4 (permalink)
eWebGuru
 
ahref's Avatar
 
Join Date: Mar 2006
Location: Dehradun
Posts: 427
Default Re: ASCII Code confusion

For key-2, you have to press ctrl key means programatically you have to enable control key, which you can do by modifying memory address 0x417.
__________________
Windows and linux hosting at http://www.ewebguru.com
Get $50 per blog post PM me for details.
ahref is offline  
Old 13-01-2007, 06:11 PM   #5 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Post Re: ASCII Code confusion

Quote:
Originally Posted by ahref
For key-2, you have to press ctrl key means programatically you have to enable control key, which you can do by modifying memory address 0x417.
Plz tell more clearly.
__________________
Minds are like Parachutes They work best when open
n2casey is offline  
Old 13-01-2007, 08:10 PM   #6 (permalink)
eWebGuru
 
ahref's Avatar
 
Join Date: Mar 2006
Location: Dehradun
Posts: 427
Default Re: ASCII Code confusion

check this program
void main()
{
char x,y,z;
clrscr();
printf("Press any key");
x=getch();

if(x==0)
{
y=getch();
printf("\nExtended Ascii code is %d",y);
}
else
{
printf("\nAscii Code is %d",x);
}
getch();
}
__________________
Windows and linux hosting at http://www.ewebguru.com
Get $50 per blog post PM me for details.
ahref is offline  
Old 14-01-2007, 11:31 PM   #7 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Question Re: ASCII Code confusion

Still facing the problem.

Look at this

Code:
void main()
{
...
char x;
x=getch();
if(x==59)
pf("x = %d",x);
else
pf("\a");
...
....
}
Since according to this table
Code:
ASCII Code     Key-1     Key-2

  59            ;         F1
  60            <         F2
  .             =          .
  .             >          .
  .             ?          .
  .             @          .
  .             A          .
  .             B          .
  .             C          .
  68            D         F10

  71            Home      G
  82            Insert    R
                                        etc.
both ; & F1 key has ASCII code 59 & according to my program I want that when I press F1, a beep sound must b there & x = 59 must not print on screen but when I press ; no beep must occur & x = 59 must print on screen.
That's why I asked to distinguish btwn keys.
__________________
Minds are like Parachutes They work best when open
n2casey is offline  
Old 15-01-2007, 01:00 AM   #8 (permalink)
eWebGuru
 
ahref's Avatar
 
Join Date: Mar 2006
Location: Dehradun
Posts: 427
Default Re: ASCII Code confusion

void main()
{
char x,y,z;
clrscr();
printf("Press any key");
x=getch();

if(x==0)
{
y=getch();
printf("\a");
printf("\nExtended Ascii code is %d",y);
}
else
{
printf("\nAscii Code is %d",x);
}
getch();
}
__________________
Windows and linux hosting at http://www.ewebguru.com
Get $50 per blog post PM me for details.
ahref is offline  
Old 15-01-2007, 02:54 PM   #9 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Exclamation Re: ASCII Code confusion

Quote:
Originally Posted by ahref
void main()
{
char x,y,z;
clrscr();
printf("Press any key");
x=getch();

if(x==0)
{
y=getch();
printf("\a");
printf("\nExtended Ascii code is %d",y);
}
else
{
printf("\nAscii Code is %d",x);
}
getch();
}
I have tried that but still problem not solved coz the statement
Code:
if(x==0)
{
y=getch();
printf("\a");
printf("\nExtended Ascii code is %d",y);
}
never gets executed. Every time I press F1, F2 etc. then first statement is executed & it prints Ascii Code is ...
__________________
Minds are like Parachutes They work best when open
n2casey is offline  
Old 15-01-2007, 04:31 PM   #10 (permalink)
eWebGuru
 
ahref's Avatar
 
Join Date: Mar 2006
Location: Dehradun
Posts: 427
Default Re: ASCII Code confusion

That code should execute when you press F1,F2 key etc. It is working fine in my end. Probably you have to flush your keyboard buffer.
__________________
Windows and linux hosting at http://www.ewebguru.com
Get $50 per blog post PM me for details.
ahref is offline  
Old 15-01-2007, 06:33 PM   #11 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Default Re: ASCII Code confusion

OK ahref. Unfortunately your trick doesn't work on my system but I have solved my prob by modifying the program code.
Anyway, thx a lot for ur help. Ur trick added a new idea in my programming knowledge.
__________________
Minds are like Parachutes They work best when open
n2casey is offline  
Old 26-01-2007, 02:23 AM   #12 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Question Re: ASCII Code confusion

Now a new prob. in another program.
Take a look at this prog.

Code:
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
int i=0;
char c='\0',s[50];
clrscr();
do
{
 c=getch();
 if(c>31 && c<127)
 {
  s[i]=c;
  i++;
  }
 else if(c==13)
 printf("%s",s);
 else              //or else if(c==0) both r ineffective
 {
  sound(400);
  delay(50);
  nosound();
  }
 }while(c!=13);
getch();
}
So for this prog, Keys F1 to F12, Home, End etc. must not b stored in string but they r stored in string.
I want that F1, F2.... etc. keys must not b stored in string. How can I do that?
__________________
Minds are like Parachutes They work best when open
n2casey is offline  
Old 26-01-2007, 07:34 AM   #13 (permalink)
eWebGuru
 
ahref's Avatar
 
Join Date: Mar 2006
Location: Dehradun
Posts: 427
Default Re: ASCII Code confusion

I have done slight modifications. now it is not storing function keys check it
Code:
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main()
{
int i=0;
char c='\0',s[50],d;
clrscr();
do
{
 c=getch();
 if(c>31 && c<127)
 {
  s[i]=c;
  i++;
  }
 else if(c==13)
 {
 s[i]='\0';
 printf("%s",s);
 }
 else              //or else if(c==0) both r ineffective
 {
  d=getch();
  sound(400);
  delay(50);
  nosound();
  }
 }while(c!=13);
getch();
}
__________________
Windows and linux hosting at http://www.ewebguru.com
Get $50 per blog post PM me for details.
ahref is offline  
Old 26-01-2007, 12:43 PM   #14 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Default Re: ASCII Code confusion

OK ahref. Thx a lot for ur help.
Ur slight modification made a big difference. I don't know that why that idea doesn't came in my mind
Anyway, thx again & repu for u.
__________________
Minds are like Parachutes They work best when open
n2casey is offline  
Old 26-01-2007, 12:57 PM   #15 (permalink)
Google Bot
 
Pathik's Avatar
 
Join Date: Aug 2005
Posts: 9,751
Default Re: ASCII Code confusion

offtopic: wich book to refer for c++... i ll start in a few days...
Pathik is offline  
Old 26-01-2007, 01:08 PM   #16 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Smile Re: ASCII Code confusion

Quote:
Originally Posted by pathiks
offtopic: wich book to refer for c++... i ll start in a few days...
Book for C++ & OOP in C++, which I have -

THE WAITE GROUP'S
OBJECT ORIENTED PROGRAMMING IN
TURBO C++
Writer - ROBERT LAFORE
Publishers - Galgotia Publicators Pvt. Ltd., 5, Ansari Road, Daryaganj, New Delhi

Price - 350 Rs.
__________________
Minds are like Parachutes They work best when open

Last edited by n2casey; 26-01-2007 at 01:52 PM.
n2casey is offline  
Old 26-01-2007, 02:43 PM   #17 (permalink)
Google Bot
 
Pathik's Avatar
 
Join Date: Aug 2005
Posts: 9,751
Default Re: ASCII Code confusion

@n2casey r u into engg???? wich yr??? wich book is recommended by univ???
n thx for the name.. i ll try to get it...
Pathik is offline  
Old 26-01-2007, 05:49 PM   #18 (permalink)
Alpha Geek
 
Ganeshkumar's Avatar
 
Join Date: Dec 2006
Location: 13.04 N, 80.17 E (Chennai)
Posts: 838
Default Re: ASCII Code confusion

Any descent freee e boook???
Ganeshkumar is offline  
Old 26-01-2007, 05:54 PM   #19 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Smile Re: ASCII Code confusion

Quote:
Originally Posted by pathiks
@n2casey r u into engg???? wich yr??? wich book is recommended by univ???
n thx for the name.. i ll try to get it...
I have completed my Engg. in June-06.
The book I have told U is recommended by Univ. for OOP in C++.
In First yr I read Let Us C or C++ by Yashwant Kanitker to learn C from beginning. In third yr I read the book

THE WAITE GROUP'S
OBJECT ORIENTED PROGRAMMING IN
TURBO C++
Writer - ROBERT LAFORE

& that time I come to know that it covers all topic in detail with very ease & lot of exapmles.
Let Us C/C++ both the books r good for beginners & easy too but will not cover all topics & so I told u to read OOP in Turbo C++ by Robert Lafore.
__________________
Minds are like Parachutes They work best when open
n2casey is offline  
Old 29-01-2007, 10:18 PM   #20 (permalink)
Google Bot
 
Pathik's Avatar
 
Join Date: Aug 2005
Posts: 9,751
Default Re: ASCII Code confusion

@n2casey i saw the book OOPS in C++ by robert lafore...
but it was priced 540 rs... r u sure the price is 350 rs.
Pathik is offline  
Old 29-01-2007, 11:08 PM   #21 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Smile Re: ASCII Code confusion

Quote:
Originally Posted by pathiks
@n2casey i saw the book OOPS in C++ by robert lafore...
but it was priced 540 rs... r u sure the price is 350 rs.
I have purchased it 2 months before in 350 Rs. from Delhi (not from publisher's shop). I will confirm its price & will tell u.

I was reading from my friend's book for last 2 yrs but now I have my own.
Well I suggest u to get one year old edition coz I don't found more changes in the book in last one year.

This link might help u
__________________
Minds are like Parachutes They work best when open

Last edited by n2casey; 29-01-2007 at 11:28 PM.
n2casey is offline  
Old 30-01-2007, 08:33 PM   #22 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default Re: ASCII Code confusion

I have a header file for all these key-codes. You have to just #include and start using it

So insted of 0x1b you can use ESC for escape key.

Have a look at http://www.mailnspace.com/download/c.source/
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
tuxfan is offline  
Old 30-01-2007, 11:15 PM   #23 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Default Re: ASCII Code confusion

@ tuxfan

Nice link friend. Repu for u.
__________________
Minds are like Parachutes They work best when open
n2casey is offline  
Old 31-01-2007, 12:34 PM   #24 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default Re: ASCII Code confusion

Quote:
Originally Posted by n2casey
@ tuxfan

Nice link friend. Repu for u.
Thanks

BTW, any more reps for writing that C code? Each line of code in the files offerred there is written by me! Just pay little more attention to the functions lib and that sample calendar application where those functions are used.
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
tuxfan is offline  
Old 31-01-2007, 09:47 PM   #25 (permalink)
Google Bot
 
Pathik's Avatar
 
Join Date: Aug 2005
Posts: 9,751
Default Re: ASCII Code confusion

@n2casey n others...
i saw the book oops in turbo c++ and also Oops in C++ by the same author- r lafore....... wich is better???
@ tuxfan can u also recommend some good book on c++ wich covers all the advanced topics....
Pathik is offline  
Old 31-01-2007, 10:03 PM   #26 (permalink)
Super Hero - Super Powers
 
n2casey's Avatar
 
Join Date: Sep 2006
Location: Dynamic
Posts: 766
Smile Re: ASCII Code confusion

Quote:
Originally Posted by pathiks
@n2casey n others...
i saw the book oops in turbo c++ and also Oops in C++ by the same author- r lafore....... wich is better???
@ tuxfan can u also recommend some good book on c++ wich covers all the advanced topics....
OOP in Turbo C++ is much better than OOP in C++.
Also it will cover many advanced topics. It's a good book for both beginners & advance programmers.

One suggestion for u, use the term OOP (Object Oriented Programming) instead of OOPs.
__________________
Minds are like Parachutes They work best when open
n2casey is offline  
Old 01-02-2007, 11:00 AM   #27 (permalink)
Human Spambot
 
tuxfan's Avatar
 
Join Date: Feb 2004
Location: Mumbai
Posts: 2,653
Default Re: ASCII Code confusion

I really have no idea on books on C++. But I have read Yashwant Kanetkar's Let Us C, Pointers in C, etc. and they were good. There is also a book called Let Us C++ by the same author.

I have also read his columns in newspapers, magazines, etc. and know that he is a knowledgeable person who writes well. Try his book.
__________________
:: Free hosting and free domain names available in special cases. Conditions apply ::
tuxfan is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 11:50 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2