Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

non-scrolling text progress counter help ?

Status
Not open for further replies.

goliath

MIS
Aug 18, 1999
62
US
Hello,

I've found many instances where I am processing large text files as input to a process. I would like to be able to give some sort of indication of progress without scrolling a number off the screen.

My thought is to read in the input text file and determine its size (number of lines "yyyy") then print out progress as:

Progress: xxxx of yyyy

I am looking at Win32:console right now but wondered if anyone might have some suggestions.

Thank you in advance for any assistance.

 
Here's something I did a month or two back. It disables buffering and then spits the backspace character to the terminal when it needs to update.
Code:
use strict;
use warnings;

$| = 1;                                  #disable buffering
my @spin = ('|','/','-','\\');           #set array to character animation
my $i = 0;                               #initialize index

while(1)                                 #loop forever
{
        print $spin[$i];                 #print current animation char
        sleep 1;                         #doing something that takes time
        print chr 8;                     #print backspace, ascii character 8
        $i = ($i+1) % scalar @spin;      #increment index while looping over array
}
Instead of a spinning cursor, you could just update a number output of how much has been processed. You'd have to print more backspaces to eat however much input you'd be replacing. ----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top