HOME  NEWS  FORUM  DOWNLOAD  LINK
OpenCOBOL - an open-source COBOL compiler
Main Menu
Download
Documentation
Development
Who's Online
12 user(s) are online (4 user(s) are browsing Forum)

Members: 0
Guests: 12

more...
Powered by
SourceForge

Xoops

Creative Commons

OpenCOBOL Forum Index
   OpenCOBOL
     single character display
Register To Post

Threaded | Newest First Previous Topic | Next Topic | Bottom
Poster Thread
jcurrey
Posted on: 2012/5/2 21:34
Home away from home
Joined: 2009/3/19
From: Texas
Posts: 181
single character display
Running a program compiled with:

cobc --version
cobc (OpenCOBOL) 1.1.0
Copyright (C) 2001-2009 Keisuke Nishida / Roger While
Built Jun 07 2009 06:00:30
Packaged Feb 06 2009 10:30:55 CET

I note that the statement
DISPLAY "." WITH NO ADVANCING.

does not display the period until another DISPLAY with a carriage return or an ACCEPT statement is executed.

I was doing this to try to show continuing progress, i.e. a growing line of ........... as the machine was processing issues that did not need terminal i/o. The periods were to let me know that the program will still alive. (It seems that my HP Itanium box with 64GB and 4 processors thinks that the computing chore that I have it doing should take some time to complete )

I do not know whether the issue is with the compiler or with TeraTerm (the terminal emulator that I am using).

This is not a problem to me but I thought I would post the issue in case someone else is confronted with this issue.

jimc
human
Posted on: 2012/5/3 6:45
Home away from home
Joined: 2007/5/15
From: GERMANY
Posts: 1416
Re: single character display
As OpenCOBOL only does an automatic flush, when ADVANCING is not used (surely because of performance issues and to avoid flickering), it depends how the underlying curses and/or terminal handles this. I did a quick test with the MinGW package (patched Feb09) with the program
       identification division.
       program-id. 'ADVTST'.
       procedure division.
      *
           PERFORM 10 TIMES
              DISPLAY "." WITH NO ADVANCING
              END-DISPLAY
              call 'C$SLEEP' using 1 end-call
           END-PERFORM
           DISPLAY "." 
           END-DISPLAY 
           DISPLAY "FINISHED"
           END-DISPLAY
           goback.
and everything worked fine. When trying the same prog with scoansi TERM setting on linux I get the same disturbing result as you.
As a workaround one could write a small C wrapper for fflush and call this in the COBOL prog.

human
btiffin
Posted on: 2012/5/3 14:35
Home away from home
Joined: 2008/6/7
From: CANADA
Posts: 1196
Re: single character display
Jim;

I took human's sample one step further, and cheat a little

       identification division.
       program-id. 'dots'.
       procedure division.
      *
           PERFORM 10 TIMES
              DISPLAY "." WITH NO ADVANCING END-DISPLAY
              call "flush_display" end-call
              call 'C$SLEEP' using 1 end-call
           END-PERFORM
           DISPLAY "." END-DISPLAY 
           DISPLAY "FINISHED" END-DISPLAY
           goback.

with dotflush.c
#include <stdio.h>
int flush_display() {
    fflush(stdout);
    fflush(stderr);
    return 0;
}

and
$ cobc -x dots.cob dotflush.c
$ ./dots
and there is one dot per second.

This fflushes both stdout and stderr as libcob/termio.c cob_display has
void
cob_display (const int outorerr, const int newline, const int varcnt, ...)
{
        FILE            *fp;
        cob_field       *f;
        int             i;
        va_list         args;

        if (!outorerr && !cob_screen_initialized) {
                fp = stdout;
        } else {
                fp = stderr;
        }
        va_start (args, varcnt);
        for (i = 0; i < varcnt; ++i) {
                f = va_arg (args, cob_field *);
                display (f, fp);
        }
        va_end (args);
        if (newline) {
                putc ('\n', fp);
                fflush (fp);
        }
}
and you'd have to predict if screenio had been used along with UPON phrases, so just flush both buffers, (cheating).

Cheers,
Brian
Threaded | Newest First Previous Topic | Next Topic | Top

Register To Post
 
Copyright (C) 2005 The OpenCOBOL Project. All rights reserved.
Powered by Xoops2 | PHP | MySQL | Apache
ocean-net