LordKingSquirrel.com



Doing it Old School - A character based status spinner

July 6th, 2007 · No Comments

Tagged with:  

Back in the day when you were running something in DOS that took a long time to run you’d sometimes see a “spinner” display on the command line - similar to what many AJAX-y websites do now when something is loading.

As many readers know, I do a lot of work in the Windows Command shell. And as a matter of course, I’ve created several scripts, including some in VBScript (and the windows script host “wscript”) that do take some time to run. Enter the resurrected spinner - a simple feedback to the user that something is still happening.

It’s pretty easy to setup. The method I use starts with an array of the text characters to use:


Dim symbols(8)
symbols(1) = "|"
symbols(2) = "/"
symbols(3) = "-"
symbols(4) = "\"
symbols(5) = "|"
symbols(6) = "/"
symbols(7) = "-"
symbols(8) = "\"

To display the spinner, I use the following code inside the main loop of my script (of course this assumes that you are using some sort of processing loop - if not, you’re on your own):


symindex = symindex + 1
printsym = ( symindex mod 8 ) + 1
Wscript.StdOut.Write( symbols(printsym) + chr( 8 ) )

I use this in my scripts that build the index for our county map book, and it really helps to know whether or not your script has hung.

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment