Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

I need help with Python equivalent to FORTH "EKEY"

rgilliesrgillies Posts: 9Member
I'm having no luck with finding the equivalent Python function that waits for the user to hit a key to execute a procedure. This would be the functional equivalent of the FORTH languge word KEY, or EKEY.

What KEY, or EKEY does is return onto the stack the ASCII value of the key that was pressed. I could then determine if PAGE UP key was hit, for example, so that my function can scroll the screen.

Unfortunately, raw_input() waits for you to hit ENTER.

Can someone help me?

Comments

  • infidelinfidel Posts: 2,900Member
    : I'm having no luck with finding the equivalent Python function that waits for the user to hit a key to execute a procedure. This would be the functional equivalent of the FORTH languge word KEY, or EKEY.
    :
    : What KEY, or EKEY does is return onto the stack the ASCII value of the key that was pressed. I could then determine if PAGE UP key was hit, for example, so that my function can scroll the screen.
    :
    : Unfortunately, raw_input() waits for you to hit ENTER.
    :
    : Can someone help me?

    If you are on a Windows machine, try the msvcrt module's getch() method.

    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • rgilliesrgillies Posts: 9Member
    : : I'm having no luck with finding the equivalent Python function that waits for the user to hit a key to execute a procedure. This would be the functional equivalent of the FORTH languge word KEY, or EKEY.
    : :
    : : What KEY, or EKEY does is return onto the stack the ASCII value of the key that was pressed. I could then determine if PAGE UP key was hit, for example, so that my function can scroll the screen.
    : :
    : : Unfortunately, raw_input() waits for you to hit ENTER.
    : :
    : : Can someone help me?
    :
    : If you are on a Windows machine, try the msvcrt module's getch() method.
    :
    :
    :
    Thanks for your suggestion. That's just where I located kbdhit() and getch() and a snippet of code on the Activestate.com website.

    Would you or anyone else know what module contains kbdhit() and
    getchr() on the DOS version of the msvcrt module?

    Thanks in advance.
  • infidelinfidel Posts: 2,900Member
    : : If you are on a Windows machine, try the msvcrt module's getch() method.
    : :
    : Thanks for your suggestion. That's just where I located kbdhit() and getch() and a snippet of code on the Activestate.com website.
    :
    : Would you or anyone else know what module contains kbdhit() and
    : getchr() on the DOS version of the msvcrt module?

    Are you saying the DOS version doesn't have the msvcrt module or that the msvcrt module in the DOS version doesn't have these functions? I've never before done any ncurses programming, but maybe the curses module has everything you need.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • rgilliesrgillies Posts: 9Member
    : : : If you are on a Windows machine, try the msvcrt module's getch() method.
    : : :
    : : Thanks for your suggestion. That's just where I located kbdhit() and getch() and a snippet of code on the Activestate.com website.
    : :
    : : Would you or anyone else know what module contains kbdhit() and
    : : getchr() on the DOS version of the msvcrt module?
    :
    : Are you saying the DOS version doesn't have the msvcrt module or that the msvcrt module in the DOS version doesn't have these functions? I've never before done any ncurses programming, but maybe the curses module has everything you need.
    :
    :
    I booted the DOS version of PYHT_DOS.EXE (version 1.5.2), built on June 15, 1999. Double checked -- and msvcrt module's nowhere to be found. I couldn't find the curses module either. Perhaps I should dig around on the Web to find a survival guide for the DOS version.

    Any suggestions for hints and tips for getting documentation would be greatly appreciated.

    BTW, I got my Python version of FORTH's KEY implemented on the Windows version, finally.
  • infidelinfidel Posts: 2,900Member
    : I booted the DOS version of PYHT_DOS.EXE (version 1.5.2), built on June 15, 1999. Double checked -- and msvcrt module's nowhere to be found. I couldn't find the curses module either. Perhaps I should dig around on the Web to find a survival guide for the DOS version.
    :
    : Any suggestions for hints and tips for getting documentation would be greatly appreciated.
    :
    : BTW, I got my Python version of FORTH's KEY implemented on the Windows version, finally.

    Not sure what to tell you. I avoid DOS like the plague. Best I can recommend is to perhaps find a newer version of python. I'll see if I can find anything.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • rgilliesrgillies Posts: 9Member
    [b][red]This message was edited by rgillies at 2003-1-6 23:39:26[/red][/b][hr]
    : Not sure what to tell you. I avoid DOS like the plague. Best I can recommend is to perhaps find a newer version of python. I'll see if I can find anything.
    :
    :
    Many thanks. Some version of DOS would be of interest to me because we have this unused old 486 laptop running DOS and WIN 3.0 that I plan on using to data log and control our oven/cooler used to subject a batch of PCB's to temperature tests. This would include a serial terminal running scripts to control the setpoints on this oven. I've already whipped up some graphing code (in FORTH) and am converting everything over to Python. The challenge poses an opportunity for me to get familiar with Python. And any code of use to the Python community would be placed in the public domain. This could be fun. :-)


  • infidelinfidel Posts: 2,900Member
    : Many thanks. Some version of DOS would be of interest to me because we have this unused old 486 laptop running DOS and WIN 3.0 that I plan on using to data log and control our oven/cooler used to subject a batch of PCB's to temperature tests. This would include a serial terminal running scripts to control the setpoints on this oven. I've already whipped up some graphing code (in FORTH) and am converting everything over to Python. The challenge poses an opportunity for me to get familiar with Python. And any code of use to the Python community would be placed in the public domain. This could be fun. :-)

    Take a look at http://www.python.org/download/download_windows.html

    Down at the bottom are a couple of links for Python for DOS that should give you a newer version.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

  • rgilliesrgillies Posts: 9Member
    : Take a look at http://www.python.org/download/download_windows.html
    :
    : Down at the bottom are a couple of links for Python for DOS that should give you a newer version.
    :
    :
    Thanks again. I think I know why I couldn't find the MSVCRT module. It's not a *.PY module, but a DLL of Microsoft C runtime module.
Sign In or Register to comment.