473,241 Members | 2,011 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

Pause a program while running

Hi!

I am running a C program and need to pause the program and change some
of the variables. Is there any function that checks if there is a
character in the Standard Input Buffer, else the program keeps on
running. Can someone please help me on that.

AN
Nov 14 '05 #1
10 5130
am********@yahoo.com (Amit Nath) wrote in
news:17**************************@posting.google.c om:
Hi!

I am running a C program and need to pause the program and change some
of the variables. Is there any function that checks if there is a
character in the Standard Input Buffer, else the program keeps on
running. Can someone please help me on that.


No, not like I think you want. You'll need to find some platform-specific
function supplied by your compiler to "poll" for an input char. Such
functions are off-topic here, e.g. kbhit() for MS-DOS.

--
- Mark ->
--
Nov 14 '05 #2
In <Xn********************************@130.133.1.4> "Mark A. Odell" <od*******@hotmail.com> writes:
am********@yahoo.com (Amit Nath) wrote in
news:17**************************@posting.google. com:
I am running a C program and need to pause the program and change some
of the variables. Is there any function that checks if there is a
character in the Standard Input Buffer, else the program keeps on
running. Can someone please help me on that.


No, not like I think you want. You'll need to find some platform-specific
function supplied by your compiler to "poll" for an input char. Such
functions are off-topic here, e.g. kbhit() for MS-DOS.


Using a debugger is probably a better option in the first place, as it
doesn't require any changes in the program.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #3
Da*****@cern.ch (Dan Pop) wrote in news:cb**********@sunnews.cern.ch:

I am running a C program and need to pause the program and change some
of the variables. Is there any function that checks if there is a
character in the Standard Input Buffer, else the program keeps on
running. Can someone please help me on that.


No, not like I think you want. You'll need to find some
platform-specific function supplied by your compiler to "poll" for an
input char. Such functions are off-topic here, e.g. kbhit() for MS-DOS.


Using a debugger is probably a better option in the first place, as it
doesn't require any changes in the program.


Agreed. I had thought maybe he wanted to change variables normally input
by a user, like using the up arrow key to increase an averaging window
size or something.

--
- Mark ->
--
Nov 14 '05 #4
"Mark A. Odell" <od*******@hotmail.com> wrote in message news:<Xn********************************@130.133.1 .4>...
Da*****@cern.ch (Dan Pop) wrote in news:cb**********@sunnews.cern.ch:

I am running a C program and need to pause the program and change some
of the variables. Is there any function that checks if there is a
character in the Standard Input Buffer, else the program keeps on
running. Can someone please help me on that.

No, not like I think you want. You'll need to find some
platform-specific function supplied by your compiler to "poll" for an
input char. Such functions are off-topic here, e.g. kbhit() for MS-DOS.


Using a debugger is probably a better option in the first place, as it
doesn't require any changes in the program.


Agreed. I had thought maybe he wanted to change variables normally input
by a user, like using the up arrow key to increase an averaging window
size or something.

While I am running the program, I would like to change the value of a
certain variable, say 'int i', if a character, say ESC, is present in
the Standard Input. If the ESC character is present, the program would
ask the new value of 'int i', else, the program continues with the new
value of 'i'.

I am interfacing some Keithley instruments with CEC488 board and the
data acquisition process is fully automatic and goes on for 6-7 hours
without any user intervaention. As a further modification, I am trying
to change some of the variables in the program if the 'ESC' button is
pressed. I am using a bit older version of BC++ (v 3.0, 16-bit) and am
running the program from MS-DOS.
Nov 14 '05 #5
am********@yahoo.com (Amit Nath) wrote in
news:17**************************@posting.google.c om:
I am interfacing some Keithley instruments with CEC488 board and the
data acquisition process is fully automatic and goes on for 6-7 hours
without any user intervaention. As a further modification, I am trying
to change some of the variables in the program if the 'ESC' button is
pressed. I am using a bit older version of BC++ (v 3.0, 16-bit) and am
running the program from MS-DOS.


You are in luck then, there is an entire hierarchy of Borland newsgroups
to ask this question in. They will be able to help you "catch" the ESC key
using Borland extension to the C language. See the borland.public.*
hierarchy.

--
- Mark ->
--
Nov 14 '05 #6
am********@yahoo.com (Amit Nath) writes:
[...]
I am interfacing some Keithley instruments with CEC488 board and the
data acquisition process is fully automatic and goes on for 6-7 hours
without any user intervaention. As a further modification, I am trying
to change some of the variables in the program if the 'ESC' button is
pressed. I am using a bit older version of BC++ (v 3.0, 16-bit) and am
running the program from MS-DOS.


There's no portable way to do what you want in standard C, which is
what we discuss here. There is probably a non-portable way to do it.
You might try asking in comp.os.msdos.programmer. (But first consult
your documentation and/or do a web search; search for "kbhit" is
likely to be useful.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #7
Thanks everyboby for all your help. kbhit() is a real hit and works
fine. I used kbhit() as:

(1) while (!kbhit())
{
....
// Code here
....
}
getch(); // To clear the keyboard input buffer

(2) if (kbhit())
{
....
// Change program parameters
....
getch();
}

Thanks once again,

AN
Nov 14 '05 #8
Amit Nath wrote:
Thanks everyboby for all your help. kbhit() is a real hit and works
fine.
Anyone on comp.lang.c that suggested the nonstandard kbhit() did you a
real disservice. It is not part of the standard C language and may well
not be supplied with the next implementation of C you need to use.
Further, there are no defined semantics or syntax which hold between
various implementations of this function.

If, on the other hand, you received this off-topic information by
private e-mail, then, godamit, respond by private e-mail.
I used kbhit() as:


Who the f. cares?
Nov 14 '05 #9
In <40**************@earthlink.net> Martin Ambuhl <ma*****@earthlink.net> writes:
Amit Nath wrote:
Thanks everyboby for all your help. kbhit() is a real hit and works
fine.
Anyone on comp.lang.c that suggested the nonstandard kbhit() did you a
real disservice.


Helping someone getting the job done in a platform specific manner, when
*no* portable solution exists doesn't exactly qualify as a "real
disservice".
It is not part of the standard C language and may well
not be supplied with the next implementation of C you need to use.
Further, there are no defined semantics or syntax which hold between
various implementations of this function.
Yet, it is the only way of getting the job done. Therefore, it is also
the best way of getting the job done.
If, on the other hand, you received this off-topic information by
private e-mail, then, godamit, respond by private e-mail.


Agreed.
I used kbhit() as:


Who the f. cares?


Other people, confronted with the same problem, on the same (or similar)
implementations.

Agreed, kbhit is best discussed in an MSDOS programming newsgroup, but
there is nothing intrinsically wrong with a kbhit-based solution, as long
as nothing more portable is available.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #10
Martin Ambuhl <ma*****@earthlink.net> wrote in message news:<40**************@earthlink.net>...
Amit Nath wrote:
Thanks everyboby for all your help. kbhit() is a real hit and works
fine.
Anyone on comp.lang.c that suggested the nonstandard kbhit() did you a
real disservice. It is not part of the standard C language and may well
not be supplied with the next implementation of C you need to use.
Further, there are no defined semantics or syntax which hold between
various implementations of this function.


Does the C standard mandate that the usage of anything outside of it
is a sin worthy of punishment? Besides, you could wrap kbhit(), hiding
it as an implementation detail - a detail I might add which is not
covered properly by the standard.
If, on the other hand, you received this off-topic information by
private e-mail, then, godamit, respond by private e-mail.


If you make assumptions about other people's actions, then goddamnit,
take your belligerence elsewhere.
I used kbhit() as:


Who the f. cares?


The people who use newsgroups with the hope of receiving answers instead
of intimidation.
Nov 14 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Paminu | last post by:
Is there something like system("PAUSE") for linux?
8
by: Wim | last post by:
My GUI application starts a process (a console program) when the user hits Play. I would like to add an option to pause that process. The code I've added to detect if the user hit pause/unpause...
11
by: Marek | last post by:
What can I do in order to avoid first exception pause? I am sure everyone already experienced this behavior and there must be a solution. regards
2
by: allen | last post by:
I'm having a problem in that the first time an exception is thrown in my app, there is about a 2 second pause. After that first time, subsequent exceptions go very quickly. This pause is really...
2
by: Dave | last post by:
I have a program that I need the program to temporarly stop and wait for a response from a piece of equipment. After a set period I want the program to continue. Like below --execute lline...
38
by: Jackie | last post by:
I just want the programme to stop for a while. Thanks.
0
by: FaroeIslander | last post by:
Hello all. I am currently working on a program in VB.NET where the user can run a "hidden" DOS program and as the program is running the user can see how many computations have been performed by...
5
by: CoderMarc | last post by:
Hi, I can not get the system pause to work in a simple program. Here is my program below: // i/o example #include <iostream> using namespace std; int main ()
16
by: Kapteyn's Star | last post by:
Hello all, I want a function to make the program pause for a few seconds but K&R have not listed anything for this i even looked in index. can anyone help? Thank you very much. --...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.