Date: Sat, 16 May 1998 12:38:41 -0400
From: Sam Koski <skoski@compuserve.com>
Subject: Using apstrings (an example)
Sender: ap-compsci@ets.org

Hi all,
        I finally got apstrings to work.  With a little help from Chris
Nevison and the discussion about ap classes from Maria Litvin, I was able
to create this little program. It gives a little demonstration of
apstrings.

(If your apstring.h and apstring.cpp libraries are in your include
directory, it should run as is.  If not, change the path on the include
files.  The program is a little animated "telegram" to my two benefactors,
but the message can be changed.  I make no claims about how "good" my
programming style so go easy on me.)

Sam Koski
Miami Springs Senior High.
skoski@compuserve.com

Cut and paste this into your c++ editor.  Of course, you may direct
any questions to me if you have any problems.

=========================================================================

// This program uses a fix for apstring suggested by Chris Neverson.
// I also used Maria Litvin's discussion of The Five AP Classes to
// create a cute animation.  I got Maria's worksheet from
// http://www.cris.com/~Skylit/apclass/index.shtml.

// Program by Sam Koski, Miami Springs Senior High.
// Minor editing by Henry Walker to repair e-mail generated troubles

// The programming style (mistakes and misconceptions) is mine.
#include <iostream.h>
#include <apstring.h>
#include <apstring.cpp>  //temporary fix to get apstrings to work
#include <conio.h>       //used for gotoxy

const long ScrollRate = 800000;
const int ScrollTimes = 5;

void create_telegram(int bound) {
  gotoxy(25,5);
  cout << "SCROLLING TELEGRAM" << endl;
  gotoxy(9,9);
  for (int lcv=1; lcv<=bound ; lcv++)
    cout << '-';
  gotoxy(9,11);
  for (int lcv=1; lcv<=bound; lcv++)
    cout << '-';
  gotoxy(25,15);
  cout << "THANKS FOR YOUR HELP" << endl;
  }

void delay() {
  // used to slow down marquis scroll rate
  for (long i=0; i<=ScrollRate; i++);
  }

void main() {
  apstring s="Chris Neverson and Maria Litvin rule!!!.........";
  int len = s.length();          //measures length of string
  int counter=ScrollTimes*len;

  create_telegram(len+2);

  while (counter-- > 0) {          // will stop when counter drops to 0
    gotoxy(10,10);                 // positions cursor
    cout << s;
    s=s.substr(1,len-1)+s.substr(0,1);   //removes first character of s
                                         //and puts it at the end of s
    gotoxy(30,18);
    cout <<"Please wait "<< 1+counter/len;
    delay();
    }
  }

