how to control position of output values on output console

Discussion in 'C++' started by pratap, Jul 18, 2007.

  1. pratap

    pratap Guest

    I have an application which periodically gives me an output of sonar
    values .However i am unable to view the values as they get replaced by
    the new ones below in realtime and are displayed after the previous
    output is displayed. Is there any mechanism in C++ where i can fix
    position of the string on console e.g. "sonar 0 =" and the output
    147.000 gets replaced by the new value as the new reading gets read.
    This way the results would be more visible.

    sonar 0 = 147.000000 sonar 1 = 19.700000 sonar 2 =
    282.400000 sonar 3 = 491.000000 sonar 4 = 348.000000 sonar 5
    = 220.300000 sonar 6 = 106.900000 sonar 7 = 301.30000

    Regards
    Pratap
     
    pratap, Jul 18, 2007
    #1
    1. Advertising

  2. On 2007-07-18 13:13, pratap wrote:
    > I have an application which periodically gives me an output of sonar
    > values .However i am unable to view the values as they get replaced by
    > the new ones below in realtime and are displayed after the previous
    > output is displayed. Is there any mechanism in C++ where i can fix
    > position of the string on console e.g. "sonar 0 =" and the output
    > 147.000 gets replaced by the new value as the new reading gets read.
    > This way the results would be more visible.


    There's no way to do that with the standard IO capabilities of C++, you
    have to use some third-party library, which depends on your platform.

    --
    Erik Wikström
     
    =?ISO-8859-1?Q?Erik_Wikstr=F6m?=, Jul 18, 2007
    #2
    1. Advertising

  3. On Wed, 18 Jul 2007 11:13:21 +0000, pratap wrote:

    > I have an application which periodically gives me an output of sonar
    > values .However i am unable to view the values as they get replaced by
    > the new ones below in realtime and are displayed after the previous
    > output is displayed. Is there any mechanism in C++ where i can fix
    > position of the string on console e.g. "sonar 0 =" and the output
    > 147.000 gets replaced by the new value as the new reading gets read.
    > This way the results would be more visible.
    >
    > sonar 0 = 147.000000 sonar 1 = 19.700000 sonar 2 =
    > 282.400000 sonar 3 = 491.000000 sonar 4 = 348.000000 sonar 5
    > = 220.300000 sonar 6 = 106.900000 sonar 7 = 301.30000
    >


    Try ncurses, or something similar.

    --
    Obnoxious User
     
    Obnoxious User, Jul 18, 2007
    #3
  4. pratap

    James Kanze Guest

    On Jul 18, 1:27 pm, Erik Wikström <> wrote:
    > On 2007-07-18 13:13, pratap wrote:


    > > I have an application which periodically gives me an output of sonar
    > > values .However i am unable to view the values as they get replaced by
    > > the new ones below in realtime and are displayed after the previous
    > > output is displayed. Is there any mechanism in C++ where i can fix
    > > position of the string on console e.g. "sonar 0 =" and the output
    > > 147.000 gets replaced by the new value as the new reading gets read.
    > > This way the results would be more visible.


    > There's no way to do that with the standard IO capabilities of C++, you
    > have to use some third-party library, which depends on your platform.


    If the values are all on one line, outputting enough '\b' and
    then rewriting the entire line will usually work. (Not that I'd
    really recommend it.) Otherwise, curses/ncurses is pretty much
    the de facto standard.

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Jul 19, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Finney
    Replies:
    2
    Views:
    1,001
    Egor Bolonev
    Jun 30, 2003
  2. Egor Bolonev
    Replies:
    0
    Views:
    491
    Egor Bolonev
    Jun 30, 2003
  3. Serge Terekhoff
    Replies:
    0
    Views:
    652
    Serge Terekhoff
    Jun 30, 2003
  4. Replies:
    5
    Views:
    3,447
    James Kanze
    Mar 4, 2008
  5. James Wong
    Replies:
    4
    Views:
    517
    James Wong
    Jul 14, 2004
Loading...

Share This Page