Pause a program while running

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amit Nath

    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
  • Mark A. Odell

    #2
    Re: Pause a program while running

    amitnath80@yaho o.com (Amit Nath) wrote in
    news:171fd4c9.0 406290448.5cb3c fab@posting.goo gle.com:
    [color=blue]
    > 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.[/color]

    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 ->
    --

    Comment

    • Dan Pop

      #3
      Re: Pause a program while running

      In <Xns95175AF458C 39CopyrightMark Odell@130.133.1 .4> "Mark A. Odell" <odellmark@hotm ail.com> writes:
      [color=blue]
      >amitnath80@yah oo.com (Amit Nath) wrote in
      >news:171fd4c9. 0406290448.5cb3 cfab@posting.go ogle.com:
      >[color=green]
      >> 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.[/color]
      >
      >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.[/color]

      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: Dan.Pop@ifh.de

      Comment

      • Mark A. Odell

        #4
        Re: Pause a program while running

        Dan.Pop@cern.ch (Dan Pop) wrote in news:cbs0vm$at7 $4@sunnews.cern .ch:

        [color=blue][color=green][color=darkred]
        >>> 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.[/color]
        >>
        >>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.[/color]
        >
        > Using a debugger is probably a better option in the first place, as it
        > doesn't require any changes in the program.[/color]

        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 ->
        --

        Comment

        • Amit Nath

          #5
          Re: Pause a program while running

          "Mark A. Odell" <odellmark@hotm ail.com> wrote in message news:<Xns95178A 03BA47DCopyrigh tMarkOdell@130. 133.1.4>...[color=blue]
          > Dan.Pop@cern.ch (Dan Pop) wrote in news:cbs0vm$at7 $4@sunnews.cern .ch:
          >
          >[color=green][color=darkred]
          > >>> 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.[/color]
          > >
          > > Using a debugger is probably a better option in the first place, as it
          > > doesn't require any changes in the program.[/color]
          >
          > 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.[/color]


          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.

          Comment

          • Mark A. Odell

            #6
            Re: Pause a program while running

            amitnath80@yaho o.com (Amit Nath) wrote in
            news:171fd4c9.0 406291852.7a64a a58@posting.goo gle.com:
            [color=blue]
            > 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.[/color]

            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 ->
            --

            Comment

            • Keith Thompson

              #7
              Re: Pause a program while running

              amitnath80@yaho o.com (Amit Nath) writes:
              [...][color=blue]
              > 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.[/color]

              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.p rogrammer. (But first consult
              your documentation and/or do a web search; search for "kbhit" is
              likely to be useful.)

              --
              Keith Thompson (The_Other_Keit h) kst-u@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.

              Comment

              • Amit Nath

                #8
                Re: Pause a program while running

                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

                Comment

                • Martin Ambuhl

                  #9
                  Re: Pause a program while running

                  Amit Nath wrote:
                  [color=blue]
                  > Thanks everyboby for all your help. kbhit() is a real hit and works
                  > fine.[/color]

                  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.
                  [color=blue]
                  > I used kbhit() as:[/color]

                  Who the f. cares?

                  Comment

                  • Dan Pop

                    #10
                    Re: Pause a program while running

                    In <40F99369.20603 03@earthlink.ne t> Martin Ambuhl <mambuhl@earthl ink.net> writes:
                    [color=blue]
                    >Amit Nath wrote:
                    >[color=green]
                    >> Thanks everyboby for all your help. kbhit() is a real hit and works
                    >> fine.[/color]
                    >
                    >Anyone on comp.lang.c that suggested the nonstandard kbhit() did you a
                    >real disservice.[/color]

                    Helping someone getting the job done in a platform specific manner, when
                    *no* portable solution exists doesn't exactly qualify as a "real
                    disservice".
                    [color=blue]
                    >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.[/color]

                    Yet, it is the only way of getting the job done. Therefore, it is also
                    the best way of getting the job done.
                    [color=blue]
                    >If, on the other hand, you received this off-topic information by
                    >private e-mail, then, godamit, respond by private e-mail.[/color]

                    Agreed.
                    [color=blue][color=green]
                    >> I used kbhit() as:[/color]
                    >
                    >Who the f. cares?[/color]

                    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: Dan.Pop@ifh.de

                    Comment

                    • Wynand Winterbach

                      #11
                      Re: Pause a program while running

                      Martin Ambuhl <mambuhl@earthl ink.net> wrote in message news:<40F99369. 2060303@earthli nk.net>...[color=blue]
                      > Amit Nath wrote:
                      >[color=green]
                      > > Thanks everyboby for all your help. kbhit() is a real hit and works
                      > > fine.[/color]
                      >
                      > 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.[/color]

                      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.
                      [color=blue]
                      > If, on the other hand, you received this off-topic information by
                      > private e-mail, then, godamit, respond by private e-mail.[/color]

                      If you make assumptions about other people's actions, then goddamnit,
                      take your belligerence elsewhere.
                      [color=blue][color=green]
                      > > I used kbhit() as:[/color]
                      >
                      > Who the f. cares?[/color]

                      The people who use newsgroups with the hope of receiving answers instead
                      of intimidation.

                      Comment

                      Working...