Machine problems, COM1201 W99, introduction and discussion. Prof. Futrelle, 1/21/99.

This document is available on the Web through my home page and the teaching gateway
accessed from my home page at
It is also available on the Ambassador server for the Macs as a CodeWarrior (CW)

There are three parts to this discussion:

  What the machine problem is about.
  How to set up your project and use Code Warrior.
  Source code and comments.


Open the CodeWarrior IDE 2.0.1 application on a Mac in 201CN or 229CN.
Choose new project.
Under the Mac OS and C/C++, I normally choose the ANSI C++ Console PPC project setup.
You will be asked to give the project a name and save it somewhere, and Create Folder
should be checked.  You must give the file a meaningful name.  I suggest the following,
using my initials, RPF, as the example name:  1201w99mp1rpf.   Be sure to follow the dot
by the Greek letter mu (by typing option-m).  This will cause CW to create the proper
folder and set of files.  Of course, DO NOT use my initials, use yours, or your last name.
This will open a working project, whose only source file is HelloWorld.cp.
Double click the source to open it and immediately do a Save-As as 1201w99mp1rpf.cp
This will change the name of the file in the project window automatically.
But the application you produce will still have the old name, so go to 
the ANSI C++ Console PPC Settings item on the edit menu, and in there, set the
PPC target file name to 1201w99mp1rpf
Do your work with the new source file, deleting all the Metrowerks header and replacing
it with your own.
You are to hand in a floppy disk containing the entire project and source files in
a form that runs on the Macintoshes -- if you do your work on Unix or Linux or Windows,
you must still put your work in the form of a Code Warrior project and hand it in in 
that form.  Leave plenty of time to do the conversion -- too often students try to
do this at the last minute and fail because they run out of time. (You've been warned.)
Your program should always contain code to test what you have done as well as having
the output of the test(s) pasted in as comments at the end of your file.
If you do a number of tests, you can paste in pairs of calls and outputs
For a header, the first few lines of the file, I suggest something like the following
14 line example.  Note that the date near 
the top is the last date on which the file was edited, not the first.  The history
takes care of the rest.

 *  1201 w99 class
 *  1/24/99   Jane K Renfrew
 *  File:  1201w99mp1rpf.cp
 *  First machine problem.
/* History
1-23-99	Started, 7:30pm.  Got search working for single characters OK,
          on tiny file.
1-24-99	Can find tags now. Have to work on comments.



In this machine problem and the ones to follow, we will be applying methods for string
searching, sorting, and storing and retrieving objects efficiently in special data
structures.  All of these techniques will be applied to web pages, documents written in 
the HTML (the Hypertext Markup Language).  You can get these web pages easily by saving
them in source (not text) format from a browser such as Netscape or Explorer.

We'll look at an example source document, that displays what's between START and END
in a browser:

********** START **********
A Document with bold and italics highlighting and a (hidden) comment.

This is another paragraph.
**********  END  **********

Here is one HTML source for such a display.  Note that only the material in
the body, between the body start tag  and the body end tag ,
is seen on the  screen in the browser.

********** START **********
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="GoLive CyberStudio3">
<title>Simple sample HTML file</title>
A Document with <b>bold</b> and <i>italics</i>highlighting and a (hidden) comment.
<p>This is another par<!-- this is <<<>a comment, can have brackets in it. -->agraph.
**********  END  **********

The structure of every HTML file is simple, especially within the body.  Every character
either belongs to a tag, between a '<' and a '>' inclusive (the tags are not displayed,
they're just markup), OR the text is between tags and is displayed, possibly modified 
in appearance or location by the surrounding tags.  The only exception to tag structure
are comments, enclosed by "".  They can even have unbalanced brackets
in them, as the example above shows. The  text appears as the browser window
name, in the title bar.  

This ends the general introduction, you may want to proceed to machine problem #1.