Thread: Reading buttons

  1. #1
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269

    Reading buttons

    How can you make the program read a button without using
    getch();
    or without pausing or stopping the program?
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Use any of the standard functions that get input from the console in either cstdio or iostream. There will probably be some o/s specific ways aswell.

  3. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    If you are programming on DOS platform you would write and INT 9 handler.

  4. #4
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    what does that excatly mean?
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    The INT 9 handler is the interrupt 9. That is the system call to the keyboard. You can also do this in windows, too, using the WM_KEYUP and WM_KEYDOWN messages. I've used both ways quite a bit and they are both....not so easy for a beginner. For the dos method I usually use asm. The windows version is actually slightly easier, however, that all depends on how much windows experience you've had.

  6. #6
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    can you give me an example?
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  7. #7
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    im using dos
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  8. #8
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    are you really using dos or do you just think you are?

    INT 9 handlers will not work in a console. You need real dos to do this.
    What compiler are you using ?
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  9. #9
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    I think it is borland C++ 4.0, but im getting Borland C++ 5.5
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  10. #10
    Señor Member
    Join Date
    Jan 2002
    Posts
    560
    I guess this is the same topic, so I'll post it here. For anyone that knows qBASIC, what's the C++ equivilent of inkey$? (I think that's what he wants).

  11. #11
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    make your life easy. Yes i believe that borland 4 had the ability to compile for dos but if you use a windows console instead (looks like dos, but is really just a simulated environment) then you can use the win32 api. Look into this or the other keyboard functions in the win32 api.
    Do you really want to go to the trouble of writing an int 9 handler when you could just program for a windows console.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  12. #12
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Do you really want to go to the trouble of writing an int 9 handler when you could just program for a windows console.

    Yes. Console programs are very limited. For full DOS support compile for DOS. Why is an interrupt 9 handler so hard to write?

    Look it up on a search engine and learn how to use setvect() and getvect(). It's really no different than writing a normal function in C. They've made it very easy to do int handlers in C.

  13. #13
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    console programs are really only limited in terms of graphics. If you want graphics then use the GUI side of the windows api or use opengl or directx. You will accomplish far more and your learning will be current. Why learn to program for dos anymore?
    Even the boot to dos mode does not give you real dos. Even that is still a far cry from dos 4 (classic dos). What you get is a very butchered version of dos 6.2. There are some old dos programs that refuse to work even after booting win98 into dos.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Resetting a ifstream object after reading the whole file
    By Zeeshan in forum C++ Programming
    Replies: 5
    Last Post: 03-31-2008, 08:03 AM
  2. Replies: 2
    Last Post: 01-28-2008, 03:07 AM
  3. help with reading from stream
    By movl0x1 in forum C Programming
    Replies: 7
    Last Post: 05-31-2007, 10:36 PM
  4. Fun with reading hex
    By dpro in forum C++ Programming
    Replies: 7
    Last Post: 02-17-2006, 06:41 PM
  5. reading file word by word
    By 98holb in forum C Programming
    Replies: 2
    Last Post: 01-25-2006, 05:49 PM