💾 Archived View for mirrors.apple2.org.za › archive › ground.icaen.uiowa.edu › Srcs › Spinning.Curso… captured on 2024-06-16 at 14:27:43.

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

From - Thu Feb 27 18:33:56 1997
Path: news2.cais.com!news.intr.net!news.charm.net!news.fred.net!gail.ripco.com!tezcat!cam-news-hub1.bbnplanet.com!cpk-news-hub1.bbnplanet.com!su-news-hub1.bbnplanet.com!news.bbnplanet.com!newsxfer3.itd.umich.edu!portc01.blue.aol.com!audrey01.news.aol.com!not-for-mail
From: mikew50@aol.com (MikeW50)
Newsgroups: comp.sys.apple2.programmer
Subject: Re: SPINNING CURSOR
Date: 24 Feb 1997 16:42:40 GMT
Organization: AOL http://www.aol.com
Lines: 154
Message-ID: <19970224164200.LAA07674@ladder02.news.aol.com>
References: <9702182142.0UHON00@techall.wa.com>
NNTP-Posting-Host: ladder02.news.aol.com
X-Admin: news@aol.com

In message <9702182142.0UHON00@techall.wa.com>,
norman.dodge@techall.wa.com wrote:

>Would you do this in C or assembly?

Yes. :)

I would also write it in Pascal. In fact, I've written it in all 3, and
use whichever version matches the program it is in.

>Can you give any hints that will get me started in the right direction?

Hows this:

{---------------------------------------------------------------}
{                                                               }
{  Spin                                                         }
{                                                               }
{  Implements a spinning cursor for text programs.              }
{                                                               }
{---------------------------------------------------------------}
{                                                               }
{  Use:                                                         }
{                                                               }
{  Call SpinInit once to initialize the module.                 }
{                                                               }
{  Call Spin periodically to display the spinner.               }
{                                                               }
{  Call SpinStop before writing a carriage return and before    }
{  exiting the program.                                         }
{                                                               }
{  Adjust the value of spinSpeed of the spinner spins too fast  }
{  or too slow.                                                 }
{                                                               }
{---------------------------------------------------------------}

unit Spin;

interface

procedure Spin;

{ Spin the spinner                                              }
{                                                               }
{ Notes: Starts the spinner if it is not already in use         }


procedure SpinInit;

{ Initialize this module                                        }


procedure SpinStop;

{ Stop the spinner                                              }
{                                                               }
{ Notes: The call is safe, and ignored, if the spinner is       }
{       inactive.                                               }


{---------------------------------------------------------------}

implementation

const
   spinSpeed = 8;                       {calls before one spinner move}

type
   consoleOutDCBGS = record
      pcount: integer;
      ch: char; 
      end;

var
   spinning: boolean;                   {are we spinning now?}
   spinDisp: integer;                   {disp to the spinner character}
   spinCount: integer;                  {spin loop counter}

   spinner: array[0..3] of char;        {spinner characters}

procedure ConsoleOutGS (var parms: consoleOutDCBGS); prodos ($015A);

{---------------------------------------------------------------}

procedure Spin;

{ Spin the spinner                                              }
{                                                               }
{ Notes: Starts the spinner if it is not already in use         }

var
   coRec: consoleOutDCBGS;              {Console out record}

begin {Spin}
if not spinning then begin
   spinning := true;
   spinCount := spinSpeed;
   end; {if}
spinCount := spinCount - 1;
if spinCount = 0 then begin
   spinCount := spinSpeed;
   spinDisp := spinDisp - 1;
   if spinDisp < 0 then
      spinDisp := 3;
   coRec.pcount := 1;
   coRec.ch := spinner[spinDisp];
   ConsoleOutGS(coRec);
   coRec.ch := chr(8);
   ConsoleOutGS(coRec);
   end; {if}
end; {Spin}


procedure SpinInit;

{ Initialize this module                                        }

begin {SpinInit}
spinning := false;                      {not spinning the spinner}
spinDisp := 0;                          {start spinning with the first
character}
spinner[0] := '|';                      {set up the spinner characters}
spinner[1] := '/';
spinner[2] := '-';
spinner[3] := '\';
end; {SpinInit}


procedure SpinStop;

{ Stop the spinner                                              }
{                                                               }
{ Notes: The call is safe, and ignored, if the spinner is       }
{       inactive.                                               }

var
   coRec: consoleOutDCBGS;              {Console out record}

begin {SpinStop}
if spinning then begin
   spinning := false;
   coRec.pcount := 1;
   coRec.ch := ' ';
   ConsoleOutGS(coRec);
   coRec.ch := chr(8);
   ConsoleOutGS(coRec);
   end; {if}
end; {SpinStop}

end.

This source is hereby released to the public domain.

Mike Westerfield