Hello Everybody,
Here's the background, started coding C back in 1986 on Xinux, then AT&T Unix, then MS-DOS, then Windows 95. As the years have passed I'll been pulled into more
analytic work and package programming: MS Access, Crystal Reports, SAS, SQL MS VBasic, etc... Back in the day, I coded with MS C version 5.0. I wrote a few dozen utilities that have over the years, stopped working, not all, but some. No big deal, the net provided other replacement utilities for most of them, however, one I have really missed was a util called wait.exe. I would use this util in batch files to allow a timed pause to occur. It would take a parameter of seconds and it would do either of two things; wait for the number of seconds and return, or if a keyboard key was pressed, it would return.
More background, my primary PC with all my source, compiler, etc.. has a harddrive crash
a few years after I got out of C (around 2000) . Well of course I was backing it up and had multiple backups, because I had already learned that lesson! However, since I really didn't need it right away, I kind of put off restoring it
--- another lesson learned. Now I still have the backup tape and the old PC with the tape drive. However, the backup tapes are somewhere in a box, somewhere in storage and I could find it, but...
So now to the present. I haven't been able to find a replace wait.exe util that does the two things I need it to do, so about a week ago, I thought that I would just re-write it. Reviewed the available C compilers and selected Pelles C
. Then searched for some source code on the web and started to compile a few timer programs. Got them working, so then started to code the "check the keyboard for a key being pressed" into the timer loop. The functionality that I want is not to wait on a key to be pressed, but to check if a key has been pressed. If no key has been pressed, continue to the next step. If this functionality can be done with ftn calls like _cgets, _cscanf, _eof, _tell, etc.. then my problem would be solved, just give me a sample of the code. It took a few days of working on this part of the code, then I remembered that I had written a few .obj libraries and one of those .obj files was what I used to inspect the keyboard buffer to see if a key was waiting. This .obj ftn was directly accessing the keyboard interrupt. Then I started doing more research on the forum here and understand that (I think) there is no direct interrupt interface, at least not the way I would need it to work. The forum has been very informative and has helped me understand the reasons why my old MS-DOS utils have stopped working and that I will need to write code as Win32 or Win64 console programs.
So now to the help I need. Are there ways, in Pelles C, to check to see if a key has been pressed without waiting on a "Enter" key to be pressed? In other words, call the ftn and the ftn returns either 0 or -1 based on if a key in sitting in the keyboard buffer. If someone can tell me if writing the wait.exe console ftn, with the two options of ending the util is possible in Pelles C, I would really appreciate it. If someone has already written the wait.exe ftn and would be willing to share the code I would really, really appreciate it. If someone just has the code for the ftn to check to see if a keyboard key has been pressed and would share the code I will buy you a drink (of your choice) the next time we meet!