forcing immediate output of a subroutine



I wanted to do something fancy for the user when they run my script
from the command line. Basically, I wrote this subroutine so that it
would output what would appear to be a spinning cursor while the
script was running.

##start of Fancy subroutine
sub Fancy
{
$FlashIndex = shift;
++$FlashIndex;

if ($FlashIndex == 1) { $StatusLine = " \\"; }
elsif ($FlashIndex == 2) { $StatusLine = " \|"; }
elsif ($FlashIndex == 3) { $StatusLine = " \/"; }
else { $StatusLine = " \-"; $FlashIndex = 0;}

$StatusLen = length($StatusLine);
print "$StatusLine";
print "\b" x $StatusLen;
}
##end of Fancy subroutine

$FlashIndex and $StatusLine are scoped globally, and each time the
function is called, $FlashIndex is passed to the function. The output
should be what appears to be a spinning cursor made up of \,|,/, and
-.

The problem is that the print statement executes at the end of the
script, not during, so I don't get a spinning cursor until the end of
the program. Is this because I am executing it in a subroutine? Is
there something about subroutines that prevents output from being
generated until program termination?

Thanks in advance.

.



Relevant Pages

  • Re: DAP that looks like a Calendar?
    ... : Hey if you think it will work, ... This doesn't need to be fancy, just easy for the staff to read and see ... 'call a subroutine to fill your data ... private Sub yourSub ...
    (microsoft.public.access.dataaccess.pages)
  • Re: Shift vs. @_
    ... parameters passed to a subroutine and when it is appropriate to just ... sub fancy_sub { ... ...do some fancy stuff... ... my $a = shift; ...
    (perl.beginners)
  • Re: Word 2004 VBA -> Applescript
    ... That sounds like a reason in itself for trying out AppleScript Studio. ... the main script file and call out to "action" handlers in another script ... subroutines, from tiny to small (my find & replace subroutine is the largest ... The truth is, despite the difficulty of working with VBA on the Mac, I ...
    (microsoft.public.mac.office.word)
  • Re: Javascript Confirm()
    ... need to display a confirmation alert to user. ... Below is the script I'm using in the Submit_Clicksubroutine. ... Dim strScript As String = "<script ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: MsgBox Timeout
    ... "S Moran" wrote: ... actually a subroutine even though I haven't defined it as a subroutine? ... So what I am doing is writing a login script for our company and part ... strMsg & VbCrLf &_ ...
    (microsoft.public.scripting.vbscript)