c:\Download\thesis\unixsys.htm <HTML> <HEAD> <! Authors: Dr. Bonita McVey ...

advertisement
c:\Download\thesis\unixsys.htm
<HTML>
<HEAD>
<! Authors: Dr. Bonita McVey & Ryan wilson -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=IsO-8859-1">
<TITLE>The computer science UNIX system</TITLE>
<META NAME="GENERATOR" CONTENT="Internet Assistant for Microsoft word 2.04z">
</HEAD>
<BODY>
<P>
<CENTER><B>The Computer science UNIX system<BR>
</B></CENTER>
The unix computer system, known as <I>bsu-cS</I>, is a sunultra
server 170 computer connected to the university ethernet backbone,
has the internet address of 147.226.112.101 and a full domain
name of <I>bsu-cs.bsu.edu.
</1>
<P>
<U><B>How to Login to the <i>bsu-cs</i> system </B></U>
<P>
once you have an account and have connected to the <i>bsu-cs</i> system,
enter your login name and password at the appropriate prompts.
Your password will not appear on the screen as you enter it in
order to keep your password secure from others. The screen will
look similar to this:
<P>
<TT><FONT SIZE=3 FACE="courier New">unix(r) system V Release 4.0
(bsu-cs) </FONT></TT>
<P>
<TT><FONT SIZE=3 FACE="Courier New">lo~in: your_login_name<return></FONT></TT>
<BR><TT><FONT SIZE=3 FACE="Courier New >password: your_password<return>
</FONT></TT>
<P>
Once you have entered your login name and password correctly,
the system will display the login messages of the day. please
read these carefully. Any system changes, downtimes, notices,
etc., will be shown here.
<P>
<U><B>How to Connect to and Disconnect from <i>bsu-cs</i>
</B></U>
<P>YOU will be able to connect to <i>bsu-cs</i> from various locations including
RB 369, 355, 356, 134, the student modem pool, from your VAX account,
etc. The methods used in each location varies and are described
below. Be sure to gain experience with each of the cs lab rooms
as it is possible that RB 369 will be crowded when open.
<P>
<U><B>RB 369</B></U>: When you sit down at a machine in RB 369,
you should see a screen that says "<B>welcome to <I>machine-name</I></B>"
. Be sure to select (click on) <TT><B>session</B></TT>,
then select <TT><B>Default</B></TT>.
Enter your username and
password for your unix account. Press the right mouse button on the desktop
to activate a pop-up menu. From the menu, choose <TT><B>Add</B></TT>
then choose <TT><B>Terminal</B></TT>.
.
This will open a terminal window to the local workstation (the
one at which you are sitting). You may open additional windows
by again using the right mouse button and the same sequence of
steps. To connect to <I>bsu-cS</I>, you may enter either the
command <b><TT>rlogin bsu-CS</TT></b>
or the command <b><TT>telnet bSU-CS</TT> </b>.
<P>
To disconnect from <I>bsu-cS</I>, you need only enter the command
<TT>109out</TT>; however,
you stlll need to disconnect from the local workstation. To do
so, click on the <b>Gnome foot</b> in the lower
left hand corner of the screen and choose <b>Logout</b>. From
the window that opens, choose <b>Logout</b> and click <b>Yes</b>.
<p>
<U><B><FONT SIZE=3>oo NOT TURN OFF THE MACHINES IN RB355, RB356
or RB369!<BR>
</FONT></B></U>
<BR>
<U><B>RB 355/356</B></U>: When you sit down, you should be looking
at a screen with a box that has a <U><B>U</B></u><B>ser name</B>,
in which you should enter <TT><FONT FACE="courier New">RB355</FONT></TT>
1
c:\Download\thesis\unixsys.htm
or <TT><FONT FACE="Courier New">RB356,</FONT></TT> depending on
your location.
After doing so, simply click on <B>OK</B> or
type the return key. shortly there will appear several icons
and a button in lower left corner labeled <B>Start.</B> click
on this button and choose <B>programs</B> from the menu that appears.
Another menu will appear from which you choose <B>Telnet</B>.
Finally there are two options with Telnet, <I>bsu-cS</I> and
VAX. choose <I>bsu-cS.</I> You are now connected to <I>bsu-cS</I>.
<P>
To disconnect from bsu-cs, first be sure that you have logged
out. Then, go to the <B>Start</B> button, select <B>shutDown</B>.
Another menu will appear from which you should choose to <B>close
all programs and log on as a different user</B>. Then click on
<B>Yes.</B>
<br><U><B><FONT SIZE=3>DO NOT TURN OFF THE MACHINES IN RB355, RB356
or RB369!<BR>
</FONT></B></U>
<P>
<B>RB 134</B>: choose the option U for unix from the menu that
appears at the top of the screen and then type return. You may
now login. Logging out from your account will disconnect the
machine from <I>bsu-cs. </1>
<P>
<B>Dial-up:</B> Choose option 2, the unix system and then type
return.
<P>
<U><B>Mail </B></U>
<P>
Mail is one of the most commonly used applications on any multi-user
computer. The unix system currently has two mail applications,
<I>mail</I> and <I>elm</I>. <I>Mail</I> is the standard issue
for a unix system and <I>elm</I> is a public domain software package
that is menu driven and more screen oriented. This handout will
instruct you in the use of <I>elm</I>.
The mail utility <I>elm</I> on <I>bsu-cS</I> can be invoked by:
<P>
<TT>% elm</TT><return>
<P>
The first time you invoke <I>elm</I>, it will ask you to set up
a couple directories in your home directory. Once those directories
are created, it will then show a screen similar to the following:
<P>
<TT><FONT SIZE=2 FACE="courier New">Mailbox is '/var/mail/john
with 1 message [ELM 2.4 PL11]
</FONT></TT>
<P>
<TT><FONT SIZE=2 FACE="Courier New"> 1 Oct 21 Henry Markum (19)
HOW'S life?
</FONT></TT>
<P>
<TT><FONT SIZE=2 FACE="Courier New"> You can use any of the following
commands by pressing the first character:</FONT></TT>
<P>
<TT><FONT SIZE=2 FACE="Courier New">d)elete or u)ndelete mail,
m)ail a message, r)eply or f)orward mail, q)uit</FONT></TT>
<P>
<TT><FONT SIZE=2 FACE="Courier New"> To read a message, press
. j = move down, k = move up, ? = help
</FONT></TT>
<P>
<TT><FONT SIZE=2 FACE="Courier New">command:<BR>
</FONT></TT>
<P>
<I>Elm</I> sorts the mail file in the reverse order of time and
date and displays the latest mail messages first with the real
name and subject line of each message. The current mail message
is highlighted. TO change the current mail message to another
one, simply use the arrow keys to scroll through the list. The
paragraph at the bottom of the screen displays the most common
commands for <I>elm</I>. These commands use the letter before
the parenthesis to choose the command. The elm system uses <I><B>vi</B></I>
as the default editor for mail messages, but this can be changed
by choosing <1>0 (options)</I> and changing the editor line in
the options list.
2
C:\Download\thesis\unixsys.htm
<P>
TO send mail to someone at <I>bsu-cS</I>, you must only enter
the username for the address. To send mail to someone at another
site (VAX, another university, etc.) you must enter the host address
of the computer where the person has an account. The form for
a remote address is as follows: <TT><FONT SIZE=2 FACE="Courier New">remote_username@
hostaddress</FONT></TT>
For example, for a mythical account <TT><FONT SIZE=2 FACE="Courier New">john</FONT></TT>
on the <I>bsu-cS</I> system, the entire address would be: <TT><FONT SIZE=2 FACE="Courier
New">john@bsu-cs.bsu.edu</FoNT></TT>.
<P>
<u><B>printer Access
</B></U>
<P>
There are many printers that can be accessed from the unix system.
Printers are named by their location (building and room number).
For example, the printer in RB 369 is named prb369, those in
RB 355 are named prb355. It is usually best to send your printouts
to the room in which you are working. The command to print a document in RB369 is:
<TT> %lpr -prb369 filename </TT>.
<hr>
<br>
<p align="center">
<a href=''http://VNNJ.bsu.edu/home.html'' taraet="_top">
<img src="gifs/home.gif" border="O" WIDTH=tf72" HEIGHT="14">
<fa>
<a href="mailto:ASKBSu@bsu.edu" target="_top">
<img src="gifs/ask.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://VNNJ.bsu.edu/cgi-bin/guest'' taraet="_top">
<img src="gifs/guest.gif" border="O" WIDTH="72 ff HEIGHT="14">
<fa>
<a href=''http://VNNJ.bsu.edu/uP/about/bsu.html'' target="_t0p'''>
<img src="gifs/about.gif" border="O" WIDTH="72" HEIGHT="14'>
<fa>
<a href=''http://VNNJ.bsu.edu/uP/map'/indiana.html'' target="_top">
<img src="gifs/map.gif" border="O' WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://VNNJ.bsu.edu/htmls/search.html'' target="_top">
<img src="gifs/search.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://VNNJ.bsu.edu/home_help.html'' target="_top">
<img src="gifs/help.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<br>
<font size="-l">
<a href="mailto:rawilson@bsuvc.bsu.edu">Author</a> I
Last update: <SCRIPT>document.write(document.lastModified);</sCRIPT> I
<a href="mailto:rawilson@bsuvc.bsu.edu">Technical comments to the webmaster</a>
</font>
<br>
<font size="-4">
Ball state university practices equal opportunity in education and employment
and is strongly and actively committed to diversity within its community.
</font>
</p>
<p align="center">
<em>
<font size="-4">
Links contained in this file to information provided
by organizations other than Ball state university's computer Science
Department are presented as a service and neither constitute nor imply
endorsement or warranty.
</font>
</em>
</p>
<BODY>
</HTML>
3
~
~
Simple vi Commands
wysiwyg://fill. 98lhttp://www. cs.bsu.edul-raw/thesis/vicmds.htm
Simple vi (vim) Commands
(There are many more! Throughout this document vi may be replaced by vim)
opens the file named filename if it already exists; if not, a new file is created
with the specified name
% vi filename
WARNING! vi is case sensitive editor; that is,
J
and
j
have different meanings.
vi has two modes, insertion mode and command mode. From command mode, you can move around the
document, delete a character, word or line, save the file or quit the editor and return to a UnixlLinux
prompt. Some of these commands are:
h
moves cursor 1 space left
j
moves cursor I space down
k
moves cursor 1 space up
1
moves cursor 1 space right
moves cursor one screen backward
moves cursor one screen forward
:32
moves cursor to beginning of line 32
/ chars
moves cursor to the next occurrence of the pattern chars
n
when follows the command above, finds the next occurrence
of the pattern without typing in the pattern again
dd
deletes the current line (3 dd deletes the next 3 lines)
d spacebar
r
or x
deletes current character
replaces current character with the character specified by key
key
u
undo the last command
yy
copies current line onto pasteboard (3 yy copies 3 lines)
p
pastes the contents of pasteboard at location of cursor
:w
saves the file but does not close it
:q!
closes the file but does not save it
:wq
saves and closes the file
zz
saves and closes the file
: wq
filename
saves and closes file, giving it the specified name
To insert characters, you must be in insert mode. There are several ways to do this, but once you are
there, every keystroke will enter a character into the file until you enter command mode. To change from
insert mode to command mode, press the ESC key. To enter insert mode,
10f2
i
will allow you to insert characters in front of the cursor
a
will allow you to insert characters after the cursor
o
will allow you to insert characters on a new line following the current
line
A
will allow you to insert characters at the end of the current line
3125/00 6:41 PM
Simple vi Commands
wysiwyg:llfill.98Ihttp://www.cs.bsu.edul-raw/thesis/vicmds.htm
Author 1Last Update: Saturday, February 12,200020:23:421 Technical comments to the Webmaster
Ball State University practices equal opportunity in education and employment and is strongly and actively committed to diversity within its community.
Links contained in this file to information provided by organizations other than Ball State University's Computer Science Department are presented as a
service and neither constitute nor imply endorsement or warranty.
2of2
3/25100 6:41 PM
C:\Download\thesis\vicmds.htm
1
<HTML>
<HEAD>
<! Authors: Dr. Bonita Mcvey & Ryan wilson -->
<META HTTP-EQUlv="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<TITLE>simple vi commands </TITLE>
<META NAME="GENERATOR" CONTENT="Internet Assistant for Microsoft word 2.04z">
</HEAD>
<BODY>
<CENTER><B>simple vi (vim) commands</B> </CENTER>
<CENTER>(There are many more! Throughout this document <i>vi</i> may be replaced by <i>vim</i~
»</CENTER>
<TABLE>
<TR><TD VALIGN="TOP" WIDTH=133><TT>% vi filename</TT> </TD><TD VALIGN="TOP" WIDTH=510>opens ~
the file named filename if it already exists; if not, a new file is created with the
~
specified name
</TD></TR>
</TABLE>
<P>
<P>
<B>WARNING!</B> Vl lS case sensltlve editor; that is, <TT>J</TT>
and <TT>j</TT> have different meanings.
<P>
<I>vi</I> has two modes, <I>insertion</I> mode and <I>command</I> mode.
From command mode, you can move around the document, delete a
character, word or line, save the file or quit the editor and
return to a unix/Linux prompt. Some of these commands are:<BR>
<CENTER><TABLE ALIGN="CENTER">
<TR><TD WIDTH=121><TT>h</TT></TD><TD WIDTH=390>moves cursor 1 space left
</TD></TR>
<TR><TD WIDTH=121><TT>j</TT> </TD><TD WIDTH=390>moves cursor 1 space down
</TD></TR>
<TR><TD WIDTH=121><TT>k</TT> </TD><TD WIDTH=390>moves cursor 1 space up
</TD></TR>
<TR><TD WIDTH=121><TT>1</TT> </TD><TD WIDTH=390>moves cursor 1 space right
</TD></TR>
<TR><TD WIDTH=121><TT>CTRLAB</TT></TD><TD WIDTH=390>moves cursor one screen backward
</TD></TR>
<TR><TD WIDTH=121><TT>CTRLAF</TT></TD><TD WIDTH=390>moves cursor one screen forward
</TD></TR>
<TR><TD WIDTH=121><TT>:32</TT> </TD><TD WIDTH=390>moves cursor to beginning of line 32
</TD></TR>
<TR><TD WIDTH=121><TT>/<I><FONT SIZE=2 FACE="Courier New">chars</FONT></I></TT>
</TD><TD WIDTH=390>moves cursor to the next occurrence of the pattern <I>chars</I>
</TD></TR>
<TR><TD WIDTH=121><TT>n</TT> </TD><TD WIDTH=390>when follows the command above, finds the
~
next occurrence of the pattern without typing in the pattern again
</TD></TR>
<TR><TD WIDTH=121><TT>dd</TT> </TD><TD WIDTH=390>deletes the current line «TT>3dd</TT>
~
deletes
the next 3 lines)
</TD></TR>
<TR><TD WIDTH=121><TT>d <I><FONT SIZE=2 FACE="Courier New">spacebar</FoNT></I></TT> or <TT>x ~
</TT>
</TD><TD WIDTH=390>deletes current character</TD></TR>
<TR><TD WIDTH=121><TT>r <I><FONT SIZE=2 FACE="Courier New">key</FONT></I></TT>
</TD><TD WIDTH=390>replaces current character with the character specified by key
</TD></TR>
<TR><TD WIDTH=121><TT>U</TT> </TD><TD WIDTH=390>undo the last command
</TD></TR>
<TR><TD WIDTH=121><TT>yy</TT> </TD><TD WIDTH=390>copies current line onto pasteboard «TT>3yy~
</TT> copies 3 lines)</TD></TR>
<TR><TD WIDTH=121><TT>p</TT> </TD><TD WIDTH=390>pastes the contents of pasteboard at location~
of cursor</TD></TR>
<TR><TD WIDTH=121><TT>:W</TT> </TD><TD WIDTH=390>saves the file but does not close it
</TD></TR>
<TR><TD WIDTH=121><TT>:q!</TT></TD><TD WIDTH=390>closes the file but does not save it
</TD></TR>
<TR><TD WIDTH=121><TT>:wq</TT> </TD><TD WIDTH=390>saves and closes the file
</TD></TR>
<TR><TD WIDTH=121><TT>ZZ</TT> </TD><TD WIDTH=390>saves and closes the file
</TD></TR>
<TR><TD WIDTH=121><TT>:wq <I><FONT SIZE=2 FACE="Courier New">filename</FoNT></I></TT>
</TD><TD WIDTH=390>saves and closes file, giving it the specified name
</TD></TR>
c:\Download\thesis\vicmds.htm
2
</TABLE>
</CENTER>
To insert characters, you must be in insert mode. There are several
ways to do this, but once you are there, every keystroke will
enter a character into the file until you enter command mode.
TO change from insert mode to command mode, press the ESC key.
To enter insert mode, <BR>
<CENTER><TABLE ALIGN="CENTER">
<TR><TD WIDTH=78><TT><FONT FACE="courier">i</FONT></TT> </TD>
<TD WIDTH=456>will allow you to insert characters in front of the cursor
</TD></TR>
<TR><TD WIDTH=78><TT>a</TT> </TD><TD WIDTH=456>will allow you to insert characters after the ~
cursor
</TD></TR>
<TR><TD WIDTH=78><TT>0</TT> </TD><TD WIDTH=456>will allow you to insert characters on a new ~
line following the current line
</TD></TR>
<TR><TD WIDTH=78><TT>A</TT> </TD><TD WIDTH=456>will allow you to insert characters at the end~
of the current line
</TD></TR>
</TABLE>
</CENTER>
<hr>
<br>
<p align="center">
<a href=''http://www.bsu.edu/home.html'' taraet="_top">
<img src=" gifs/home.gif" border="O" WIDTH=rt72" HEIGHT="14">
<fa>
<a href="mailto:ASKBSu@bsu.edu" target="_top">
<img src="gifs/ask.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/cgi-bin/guest'' target="_top">
<img src="gifs/guest.gif" border="O" WIDTH="72 HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/uP/about/bsu.html'' target="_t0p'''>
<img src="gifs/about.gif" border="O" WIDTH="72" HEIGHT="14'>
<fa>
<a href=''http://www.bsu.edu/uP/map'/indiana.html'' target="_top">
<img src=" gifs/map.gif" border="O' WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/htmls/search.html'' target="_top">
<img src="gifs/search.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/home_help.html'' target="_top">
<img src="gifs/help.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<br>
<font size="-l">
<a href="mailto:rawilson@bsuvc.bsu.edu">Author</a> I
Last update: <SCRIPT>document.write(document.lastModified);</SCRIPT> I
<a href="mailto:rawilson@bsuvc.bsu.edu">Technical comments to the webmaster</a>
</font>
<br>
<font size="-4">
Ball State university practices equal opportunity in education and employment
and is strongly and actively committed to diversity within its community.
</font>
</p>
<p align="center">
<em>
<font size="-4">
Links contained in this file to information provided
by organizations other than Ball State university's Computer Science
Department are presented as a service and neither constitute nor imply
endorsement or warranty.
</font>
</em>
</p>
</BODY>
</HTML>
http://www.cs.bsu.edul-raw/thesislleftcode.html
CS 120 Resources
CS 120 Resources
Please select a link from the list below.
CS 120 Homepage
Change Color
C++ Keywords
C++ Glossary
C++ Operators
Code Examples
Downloads
Executables
Source Code
Programs
Hello World
Code Pieces
For Loop
Interactive For
While Loop
Interactive While
Do ... While Loop
Interactive Do While
Opening Page
Other Sites
Suggestions
Unix Commands
Unix Info
VI Commands
I of 1
3/25100 6:43 PM
C:\My DOcumentS\ .. \HOnOrS Related\Honors 499\thesis\leftcode.html
<html>
<head>
<!-- Author: Ryan wilson -->
<title>cs 120 Resources</title>
<script>
// This function displays the time in the status line.
// rnvoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new oate(); // Get current time
var h = d.getHours(); // Extract hours: 0 to 23
var m = d.getMinutes(); // Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; //rs it am or pm?
if (h > 12)
h-=12; //convert 24-hour format to 12-hour
if ( h == 0)
h = 12; // convert 0 o'clock to midnight
if (m < 10)
m = "0" + m; //convert 0 minutes to 00 minutes, etc.
var t = h + ':' + m +
+ ampm; // Put it all together
I
defaultstatus = t;
,
//oisplay it in the status line.
//Arrange to do it all again in 1 minute.
setTimeout("display_time_in_status_lineO", 60000); //60000 ms is 1 min.
}
var bcolor;
var allcookies = document. cookie;
var pos = allcookies.indexof("color=");
if (pos != -1)
{
var start = pos + 6;
var end = allcookies.indexof(";", start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
}
else
bcolor = "white";
function setbgcolor(bcolor)
{
document.bgColor = bcolor;
}
</SCRIPT>
</head>
<body text="#000F58" link="#760s10" alink="#544C51"
onLoad="display_time_in_status_lineO; setbgcolor(bcolor);">
<h1>CS 120 Resources</h1>
please select a link from the list below.
<br>
<hr>
<a href=''http://www.cs.bsu.edu/homepages/cs120/springOO/index.html" target="_blank">
cs 120 Homepage</a><br>
<a href="changecolor.html" target="fill">change color</a><br>
<a href="keywords.html" target="fill">c++ Keywords</a><br>
<a href="definitions.html" target="fill">c++ Glossary</A><br>
<a href="operators.html" target="fill">C++ operators</a><br>
<a href="leftcode.html">code Examples</a><br>
<center><b>oownloads</b></center>
<li><a href="executables.html" target="fill">Executables</a><br>
<li><a href="sourcelist.html" target="fill">source code</a><br>
<center><b>programs</b></center>
<li><a href="helloworld.html" target="fill">Hello world</a><br>
<center><b>code pieces</b></center>
<li><a href="forloop.html" target="fill">For Loop</a><br>
<li><a href="iforloop.html" target="fill">Interactive For</a><br>
<li><a href="whileloop.html" target="fill">while Loop</a><br>
<li><a href="iwhileloop.html" target="fill">Interactive while</a><br>
<li><a href="dowhileloop.html" target="fi 11 ">00 ... while Loop</a><br>
1
c:\Download\thesis\leftcode.html
<li><a href="idowhileloop.html" target="fill">Interactive Do while</a></br>
<a href="index.html" tar~et="_top">opening page</a><br>
<a href="otherlinks.html target="fill">other sites</a><br>
<a href="su9gestion.html" target="fill">suggestions</a><br>
<a href="unlxcmds.htm" target="fill">unix commands</a><br>
<a href="unixsys.htm" target="fill">unix Info</a><br>
<a href="vicmds.htm" target="fill">VI commands</a><br>
</body>
</html>
2
wysiwyg:1lfill.98/http://www .cs. bsu.edul-raw/thesis/executables.html
Here you can download executable programs. The source code for these programs can be found in the
source section. You will need to download these programs by clicking your right mouse button on the
file link and selecting save as. Remember where you save it on your computer. To run the program,
double-click on the file name on your computer.
args.exe
avg3.exe
circle3.exe
testfcns.exe
M;C1J 3'M____IIIiiIII. -_ _MCSII.'M__ :leJ". _ ...AAiI. .__. .1*+1i·· C1 . " •• ··_
Author I Last Update: Tuesday, February 15,2000 19:26:45 I Technical comments to the Webmaster
Ball State University practices equal opportunity in education and employment and is strongly and actively committed to diversity within its community.
Links contained in thisfile to iriformation provided by organizations other than Ball State University's Computer Science Department are presented as a
service and neither constitute nor imply endorsement or warranty.
1 of 1
3/25/00 6:44 PM
C:\My Documents\ .. \Honors Related\Honors 499\thesis\executables.html
<html>
<head>
<!-- Author: Ryan wilson -->
<script>
II This function displays the time in the status line.
II Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new Date(); II Get current time
var h = d.getHours(); II Extract hours: 0 to 23
var m = d.getMinutes(); II Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; Ills it am or pm?
if (h > 12)
h-=12; Ilconvert 24-hour format to 12-hour
if ( h == 0)
h 12; II convert 0 o'clock to midnight
if (m < 10)
m = "0" + m; Ilconvert 0 minutes to 00 minutes, etc.
var t = h + I:' + m + ' , + ampm; II Put it all together
defaultstatus = t;
IIDisplay it in the status line.
IIArrange to do it all again in 1 minute.
setTimeout("display_time_in_status_lineO", 60000); 1160000 ms is 1 min.
}
II A variable we use to ensure that each error window we create is unique.
var error_count = 0;
II Email address to send the report to.
var email = "rawilson@bsuvc.bsu.edu";
II
Define the error handler.
It generates an HTML form so the user
II can report the error to the author.
function report_error(msg, url, line)
{
var w = window.open("","error"+error_count++,"resizable,status,width=625,height=400");
II arguements ... url (none specified), Name (force it to be unique), Features
var d = w.document; II We use this variable to save typing.
II Output an HTML document, including a form, into the new window.
d.write('<Dlvalign=center>');
d.writeC'<FoNT SIZE=? FAcE="helvetica"><B>');
d.write('ooPs .... A JavaScript Error Has occurred! I);
d.write('</B></FoNT><BR><HR SIZE=4 WIDTH="80%">');
d.writeC'<FORM ACTION="mailto:' + email + ,,, METHOD=post');
d.writeC' ENCTYPE="text/plain">');
d.write('<FoNT SIZE=3>');
d.write(,<I>cLick the "Report Error" button to send a bug report.<I><BR>');
d. wri teC' <INPUT TYPE="submi t" VALuE="Report Error">&nbsp ;  ') ;
d .writeC' <INPUT TYPE="button" VALUE="Di smi ss" onCl i ck="self. closeO ">');
d.write('</DIV><DIvalign=right>');
d.write('<BR>YOUr name <I>(optional)</I>: I);
d.writeC'<INPUT SIZE=42 NAME="name" VALUE="">');
d.write('<BR>Error Message: I);
d. wri teC' <INPUT SIZE=42 NAME="message" VALUE=n, + msg + 'n>');
d.writeC' <BR>Document: <INPUT SIZE=42 NAME="url" VALUE='" + url + In>');
d. wri teC' <BR>L i ne Number: <INPUT SIZE=42 NAME=nl i ne" VALUE='" + 1 i ne +' ">') ;
d.write('<BR>Browser version: I);
d.writeC'<INPuT SIZE=42 NAME="version" VALuE=n'+navigator.userAgent + '''>');
d.write('</DIV></FONT>');
d.write('</FoRM>');
II Remember to close the document when we're done.
d.closeO;
II
Return true from this error handler, so that Javascript does not
II display it own error dialog.
return true;
}
II
II
Before the event handler can take effect, we have to register it
for a particular window.
self.onerror = report_error;
1
C:\Download\thesis\executables.html
var bcolor;
var allcookies = document. cookie;
var pos = allcookies.indexof("color=");
if (pos != -1)
{
var start = pos + 6;
var end = allcookies.indexof(";", start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
}
else
bcolor = "white";
function setbgcolor(bcolor)
{
}
document.bgcolor = bcolor;
</SCRIPT>
</head>
<body text="#ODOF58" link="#760s10" alink="#544C51"
onLoad="display_time_in_status_lineO; setbgcolor(bcolor);">
<p>Here you can download executable programs. The source code for these
programs can be found in the <a href="sourcelist.html">source</a> section.
You will need to download
these programs by clicking your right mouse button on the file link and
selecting save as. Remember where you save it on your computer. To run
the program, double-click on the file name on your computer.
</p>
<a
<a
<a
<a
href="code/args.exe">args.exe</a><br>
href="code/avg3.exe">avg3.exe</a><br>
href="code/circle3.exe">circle3.exe</a><br>
href="code/testfcns.exe">testfcns.exe</a><br>
<hr>
<br>
<p align="center">
<a href=''http://www.bsu.edu/home.html'' taraet="_top">
<img src="gifs/home.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href="mailto:ASKSSu@bsu.edu" target="_top">
<img src="gifs/ask.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/cgi-bin/guest'' taraet="_top">
<img src="gifs/guest.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/uP/about/bsu.html'' target="_t0p'''>
<img src="gifs/about.gif" border="O" WIDTH="72" HEIGHT="14'>
<fa>
<a href=''http://www.bsu.edu/uP/map'/indiana.html'' target="_top">
<img src="gifs/map.gif" border="O' WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/htmls/search.html'' target="_top">
<img src="gifs/search.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/home_help.html'' target="_top">
<img src="gifs/help.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<br>
<font size="-1">
<a href="mailto:rawilson@bsuvc.bsu.edu">Author</a> I
Last update: <SCRIPT>document.write(document.lastModified);</sCRIPT> I
<a href="mailto:rawilson@bsuvc.bsu.edu">Technical comments to the webmaster</a>
</font>
<br>
<font size="-4">
Ball State university practices equal opportunity in education and employment
and is strongly and actively committed to diversity within its community.
</font>
</p>
2
C:\Download\thesis\executables.html
<p align="center">
<em>
<font size="-4">
Links contained in this file to information provided
by organizations other than Ball State university's computer science
Department are presented as a service and neither constitute nor imply
endorsement or warranty.
</font>
</em>
</p>
</body>
</html>
3
wysiwyg:1Ifill. 98lhttp://www .cs. bsu.edul-raw/thesis/sourcelist.html
Here you can download all of the source code to the various programs and code segments discussed on
this web site. The source code files all have an extension of .cc which is the C++ file extension used on
bsu-cs. If you wish to use these files in Microsoft's Visual C++ then you need to change the file
extensions to .cpp for VC++ to recognize them as source code. If you find any errors or bugs on this
page or in the files contained on this page, then please use the suggestions feature on this web site to
inform the author of the errors. Clicking on the file links with your left mouse buttong will load the
source code as text in your browser. If you wish to download the source code file to your computer, click
on the file link with your right mouse button and select the save feature. Please note: compiled
executables for each of the full programs listed below can be downloaded from the executables page.
Segments
binsearch.cc Binary Search Function
bubsort.cc Bubble Sort Function
forloop.cc For Loop Example
insertsort.cc Insertion Sort Function
linsearch.cc Linear Search Function
se1sort.cc Selection Sort Function
whileloop.cc While Loop Example
Programs
args.cc
avg3.cc
circle3.cc
testfcns.cc
_:e'le'- __.....-__.ClII..,._.+'=[.,i••__
aY.I~_•. •
,I4;I.:'.n •• ·•
Author I Last Update: Tuesday, February 15,2000 19:25:33 I Technical comments to the Webmaster
Ball State University practices equal opportunity in education and employment and is strongly and actively committed to diversity within its community.
Links contained in this file to information provided by organizations other than Ball State University's Computer Science Department are presented as a
service and neither constitute nor imply endorsement or warranty.
1 of 1
3/25/00 6:45 PM
C:\My Documents\ .. \Honors Related\Honors 499\thesis\sourcelist.html
<html>
<head>
<!-- Author: Ryan wilson -->
<script>
II This function displays the time in the status line.
II Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new Date(); II Get current time
var h = d.getHours(); II Extract hours: 0 to 23
var m = d.getMinutes(); II Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; Ills it am or pm?
if (h > 12)
h-=12; Ilconvert 24-hour format to 12-hour
if ( h == 0)
h 12; II convert 0 o'clock to midnight
if (m < 10)
m "", "0" + m; Ilconvert 0 minutes to 00 minutes, etc.
var t = h + I:' + m + ' , + ampm; II Put it all together
defaultstatus = t;
IIDisplay it in the status line.
IIArrange to do it all again in 1 minute.
setT;meout("display_time_in_status_lineO", 60000); 1160000 ms is 1 min.
}
II A variable we use to ensure that each error window we create is unique.
var error_count = 0;
II Email address to send the report to.
var email . . . "rawilson@bsuvc.bsu.edu";
II
Define the error handler.
It generates an HTML form so the user
II can report the error to the author.
function report_error(msg, url, line)
{
var w = wi ndow.open('''' , "error"+error_count++, "res; zabl e, status ,width=625, hei ght=400");
II arguements ... url (none specified), Name (force it to be unique), Features
var d = w.document; II we use this variable to save typing.
II output an HTML document, including a form, into the new window.
d.write('<Dlvalign=center>');
d .write(' <FONT SIZE=? FACE="helveti ca"><B>');
d.write('oopS .... A Javascript Error Has occurred! I);
d. wri te(, </B></FONT><BR><HR SIZE=4 WIDTH="80%">');
d.write('<FORM ACTION="mailto:' + email + '" METHOD=post');
d.write(' ENCTYPE="text/plain">');
d.write('<FoNT SIZE=3>');
d.write(,<I>CLick the "Report Error" button to send a bug report.<I><BR>');
d.wr;te('<INPuT TYPE="submit" VALuE="Report Error">   ');
d.write('<INPuT TYPE="button" VALUE="Dismiss" onclick="self.close()">');
d.write('</DIV><DIvalign=right>');
d.write('<BR>YOUr name <I>(optional)</I>: I);
d.write('<INPuT SIZE"",42 NAME="name" VALUE"","">');
d.write('<BR>Error Message: I);
d.write('<INPUT SIZE=42 NAME"","message" VALUE='" + msg + '''>');
d.write('<BR>Document: <INPUT SIZE=42 NAME="url" VALUE='" + url + '''>');
d. wri te(, <BR>L i ne Number: <INPUT SIZE=42 NAME="l i ne" VALUE='" + 1i ne +' ">') ;
d.write('<BR>Browser version: I);
d.write('<INPuT SIZE=42 NAME="version" VALuE="'+nav;gator.userAgent + '''>');
d.write('</DIV></FONT>');
d.write('</FoRM>');
II Remember to close the document when we're done.
d. closeO;
II
Return true from this error handler, so that Javascript does not
II display it own error dialog.
return true;
}
II
II
Before the event handler can take effect, we have to register it
for a particular window.
self.onerror = report_error;
1
c:\oownload\thesis\sourcelist.html
var bcolor;
var allcookies = document. cookie;
var pos = allcookies.indexof("color=");
if (pos != -1)
{
var start = pos + 6;
var end = allcookies.indexof(";", start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
}
else
bcolor = "white";
function setbgcolor(bcolor)
{
}
document.bgColor = bcolor;
</SCRIPT>
</head>
<body text="#OoOF58" link="#760B10" alink="#544C51"
onLoad="display_time_in_status_lineO; setbgcolor(bcolor);">
<p>
Here you can download all of the source code to the various programs and
code segments discussed on this web site. The source code files all have an
extension of .cc which is the c++ file extension used on bsu-cs. If you wish
to use these files in Microsoft's visual c++ then you need to change the
file extensions to .cpp for VC++ to rec09nize them as source code. If you
find any errors or bugs on this page or ln the files contained on this page,
then please use the suggestions feature on this web site to inform the author
of the errors. clicking on the file links with your left mouse buttong will
load the source code as text in your browser. If you wish to download the
source code file to your computer, click on the file link with your right
mouse button and select the save feature.
<b>please note:</b> compiled executables for each of the
full pro~rams listed below can be downloaded from the
<a href= executables.html">executables</a> page.
</p>
<center><b>segments</b></center><br>
<a href="code/binsearch.cc">binsearch.cc</a> Binary search Funct;on<br>
<a href="code/bubsort.cc">bubsort.cc</a> Bubble Sort Function<br>
<a href="code/forloop.cc">forloop.cc</a> For LOOP Example<br>
<a href="code/insertsort.cc">insertsort.cc</a> Insertion Sort Function<br>
<a href="code/linsearch.cc">linsearch.cc</a> Linear search Function<br>
<a href="code/selsort.cc">selsort.cc</a> selection Sort Function<br>
<a href="code/whileloop.cc">whileloop.cc</a> while LOOP Example<br>
<br>
<center><b>programs</b></center><br>
<a href="code/args.cc">args.cc</a><br>
<a href="code/avg3.cc">avg3.cc</a><br>
<a href="code/circle3.cc">circle3.cc</a><br>
<a href="code/testfcns.cc">testfcns.cc</a><br>
<br>
<hr>
<br>
<p align="center">
<a href=''http://WNW.bsu.edu/home.html'' taraet="_top">
<img src="gifs/home.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href="mailto:ASKBSU@bsu.edu" target="_top">
<img src="gifs/ask.gif" border="O" WIOTH="72" HEIGHT="14">
<fa>
<a href=''http://WNW.bsu.edu/cgi-bin/guest'' taraet="_top">
<img src="gifs/guest.gif" border="O" WIOTH="72" HEIGHT="14">
<fa>
<a href=''http://WNW.bsu.edu/uP/about/bsu.html'' target="_t0p'''>
<img src="gifs/about.gif" border="O" WIOTH="72" HEIGHT="14'>
<fa>
2
C:\Download\thesis\sourcelist.html
<a href=''http://www.bsu.edu/UP/map'/indiana.html'' target="_top">
<img src="gifs/map.gif" border="O' WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/htmls/search.html'' target="_top">
<img src="gifs/search.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/home_help.html'' target="_top">
<img src="gifs/help.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<br>
<font size="-l">
<a href="mailto:rawilson@bsuvc.bsu.edu">Author</a> I
Last update: <SCRIPT>document.write(document.lastModified);</sCRIPT> I
<a href="mailto:rawilson@bsuvc.bsu.edu">Technical comments to the webmaster</a>
</font>
<br>
<font size="-4">
Ball State university practices equal opportunity in education and employment
and is strongly and actively committed to diversity within its community.
</font>
</p>
<p align="center">
<em>
<font size="-4">
Links contained in this file to information provided
by organizations other than Ball state university's computer science
Department are presented as a service and neither constitute nor imply
endorsement or warranty.
</font>
</em>
</p>
</body>
</html>
3
c:\Download\thesis\code\forloop.cc
II Author: Ryan wilson
II For LOOP segment
int count=O;
int i·
for ci = 1; i <= 10; i++)
{
}
count++;
cout « "The current value of count is: " « count « endl;
cout «
"After the loop is over, the final count is: " « count « endl;
1
C:\My Documents\Class work\ .. \Honors 499\thesis\code\whileloop.cc
II Author: Ryan wilson
II while LOOP Example
int count"",O;
while (count
{
<
10)
count++;
cout « "The current value of the count is: " « count « endl;
}
cout «
"After the loop is over, the final count is: " « count « endl;
1
wysiwyg:llfilI.55lhttp://www.cs.bsu.edul-raw/thesislhelloworId.html
Hello World is typically the first program a programmer writes when learning a new language. The
coding is very simple and demonstrates the main structure of the programming language as well as how
to do output to the screen. Below is the code for Hello World in C++. Code appears in red text and
comments appear in green text.
#include <iostream.h> //Required for input-output
int main ()
{
cout «
"Hello World!" «
endl;
return 0;
This program isn't very large but it demonstrates the very basic structure of all
c++ programs. At the top of the program are the include statements. The include
statements instruct the compiler to insert code into this c++ program from the files
found in the include files. This is an easy way to use code that has been
standardized and tested and enables common features. For instance, #include
<iostream.h> allows c++ programs to use cin and couto cin is used for reading in
information from the user and cout is used to print information to the screen.
In Hello World, the int main() function follows the include files. All C++ programs
have a main function that is usually declared as type into The body of the function
is the code that is found in between the brackets {} of the function. In this case,
the entire program is found in the body of main. The body of the program consists of
a single cout statement. This cout statement prints the words "Hello World!" to the
user's screen. The return 0; statement is necessary if main is declared an into So,
all programs that have an int main() function need to have a return 0; statement at
the end of the body of main.
To see what a user would see on his/her screen when Hello World is run, click on the
'Run' button below.
_IC.lt'.
Cd1l41• •
:n)...
',*4;,.,1to.11••·•
Author i Last Update: Tuesday, April 11, 2000 01:11:09 I Technical comments
the Webmaster
Ball State University practices equal opportunity in education and employment and is strongly and actively committed to
diversity within its community.
Links contained in this file to information provided by organizations other than Ball State University's Computer
Science Department are presented as a service and neither constitute nor imply endorsement or warranty.
1 of 1
4/111002:12 AM
C:\My Documents\ .. \Honors Related\Honors 499\thesis\helloworld.html
<html>
<head>
<!-- Author: Ryan wilson -->
<script>
II This function displays the time in the status line.
II Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new Date(); II Get current time
var h = d.getHours(); II Extract hours: 0 to 23
var m = d.getMinutes(); II Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; IllS it am or pm?
if (h > 12)
h-=12; Ilconvert 24-hour format to 12-hour
if ( h == 0)
h 12; II convert 0 o'clock to midnight
if (m < 10)
m = "0" + m; Ilconvert 0 minutes to 00 minutes, etc.
var t = h + I:' + m + ' , + ampm; II Put it all together
defaultstatus = t;
IIDisplay it in the status line.
IIArrange to do it all again in 1 minute.
setTimeout("display_time_in_status_lineO", 60000); 1160000 ms is 1 min.
}
II A variable we use to ensure that each error window we create is unique.
var error_count = 0;
II Email address to send the report to.
var email = "rawilson@bsuvc.bsu.edu";
II
Define the error handler.
It generates an HTML form so the user
II can report the error to the author.
function report_error(msg, url, line)
{
var w = window.open("","error"+error_count++,"resizable,status,width=625,height=400");
II arguements ... url (none specified), Name (force it to be unique), Features
var d = w.document; II We use this variable to save typing.
II output an HTML document, including a form, into the new window.
d.write('<Dlvalign=center>');
d.write('<FoNT SIZE=? FAcE="helvetica"><B>');
d.write('oopS .... A Javascript Error Has occurred! I);
d. wri te(, </B></FONT><BR><HR SIZE=4 WIDTH="80%">');
d.write('<FORM ACTION="mailto:' + email + '" METHOD=post');
d.write(, ENCTYPE="text/plain">');
d.write('<FoNT SIZE=3>');
d.write(,<I>CLick the "Report Error" button to send a bug report.<I><BR>');
d.writee<INPUT TYPE="submit" VALuE="Report Error">   ');
d.write('<INPuT TYPE="button" VALUE="Dismiss" onclick="self.closeO">');
d.write('</Dlv><Dlvalign=right>');
d.write('<BR>YOUr name <I>(optional)</I>: I);
d.write('<INPuT SIZE=42 NAME="name" VALUE="">');
d.write('<BR>Error Message: I);
d.write('<INPUT SIZE=42 NAME="message" VALUE='" + msg + III>');
d.write(, <BR>Document: <INPUT SIZE=42 NAME="url" VALUE='" + url + III>');
d.write(,<BR>Line Number: <INPUT SIZE=42 NAME="line" VALUE='" + line +'''>');
d.write('<BR>Browser version: I);
d.write('<INPuT SIZE=42 NAME="version" VALuE="'+navigator.userAgent + III>');
d.write('</DIV></FONT>');
d.write('</FoRM>');
II Remember to close the document when we're done.
d.closeO;
II
Return true from this error handler, so that Javascript does not
II display it own error dialog.
return true;
}
II
II
Before the event handler can take effect, we have to register it
for a particular window.
self.onerror = report_error;
1
C:\My Documents\ .. \Honors Related\Honors 499\thesis\helloworld.html
var bcolor;
var allcookies = document. cookie;
var pos = allcookies.indexof("color=");
if (pos ! = -1)
{
}
else
2
var start = pos + 6;
var end = allcookies.indexOf(";", start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
bcolor = "white";
function setbgcolor(bcolor)
{
}
document.bgcolor = bcolor;
</SCRIPT>
</head>
<body text="#ODOF58" link="#760B10" alink="#544C51"
onLoad="display_time_in_status_lineO; setbgcolor(bcolor);">
<p>Hello world is typically the first program a programmer writes when
learning a new language. The coding is very simple and demonstrates the
main structure of the programming language as well as how to do output to
the screen. Below is the code for Hello world in c++. code appears in
<font color="red">red</font> text and comments appear in <font color="green">
green</font> text.</p>
<J)re>
<font color="red">
#include &It;iostream.h> <font color="green">//Required for input-output</font>
int mainO
{
}
cout «
"Hello world!" «
endl;
return 0;
</pre>
<p>
This program isn't very large but it demonstrates the very basic structure of
all c++ programs. At the top of the program are the include statements. The
include statements instruct the compiler to insert code into this c++ program
from the files found in the include files. This is an easy way to use code
that has been standardized and tested and enables common features. For
instance, <font color="red">#include &It;iostream.h> </font>
allows c++ programs to use <font color="red">cin</font> and <font color="red">
cout</font>. <font color="red">cin</font>
is used for reading in information from the user and <font color="red">cout
</font> is used to print
information to the screen.
</p>
~~>Hello world, the <font color="red">int mainO</font> function follows the
include files. All c++ pro~rams
have a <font color="red">maln</font> function that is usually declared as type
<font color="red">int</font>. The body of the
function is the code that is found in between the brackets {} of the function.
In this case, the entire program is found in the body of
<font color="red">main</font>. The body of
the program consists of a single <font color="red">cout</font> statement.
This <font color="red">cout</font> statement prints
the words "Hello world!" to the user's screen. The <font color="red">return 0;
</font> statement is
necessary if <font color="red">main</font> is declared an
<font color="red">int</font>.
So, all programs that have an <font color="red">int mainO</font>
function need to have a <font color="red">return O;</font> statement at the end
.-~---.-- . . ~
--------------------------------------------~
c:\Download\thesis\helloworld.html
of the body of <font color="red">main</font>.
</P>
<p>TO see what a user would see on his/her screen when Hello world is run,
click on the 'Run' button below.</p>
<form name="hello">
<center>
<input type="button" value="Run" onclick='document.hello.screen.value="Hello world!''';>
<br>
<textarea name="screen" value="" rows=l cols=15 wrap=on></textarea>
</form>
<hr>
<br>
<p align="center">
<a href=''http://www.bsu.edu/home.html'' tar~et="_top">
<img src="gifs/home.gif" border="O" WIDTH= 72" HEIGHT="14">
<fa>
<a href="mailto:ASKBSu@bsu.edu" target="_top">
<img src="gifs/ask.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/cgi-bin/guest'' taraet="_top">
<img src="gifs/guest.gif" border="O" WIDTH="72 f1 HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/uP/about/bsu.html'' target="_top,">
<img src="gifs/about.gif" border="O" WIDTH="72" HEIGHT="14'>
<fa>
<a href=''http://www.bsu.edu/up/map,/indiana.html'' target="_top">
<img src="gifs/map.gif" border="O' WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/htmls/search.html'' target="_top">
<img src="gifs/search.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/home_help.html'' target="_top">
<img src="gifs/help.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<br>
<font size="-l">
<a href="mailto:rawilson@bsuvc.bsu.edu">Author</a> I
Last update: <SCRIPT>document.write(document.lastModified);</SCRIPT> I
<a href="mailto:rawilson@bsuvc.bsu.edu">Technical comments to the webmaster</a>
</font>
<br>
<font size="-4">
Ball state university practices equal opportunity in education and employment
and is strongly and actively committed to diversity within its community.
</font>
</p>
<p align="center">
<em>
<font size="-4">
Links contained in this file to information provided
by organizations other than Ball state university's computer science
Department are presented as a service and neither constitute nor imply
endorsement or warranty.
</font>
</em>
</p>
</body>
</html>
3
For Loop example
wysiwyg:llfill. 32lhttp://www. cs.bsu.edul-raw/thesis/forloop.html
Here is an example of a simple for loop. This for loop will count from 0 to 10 by adding 1 to the
previous count each time through the loop. The count begins at 0 and holds the value of 10 after the loop
runs 10 times. The current value of the count is printed from inside the loop just after the count is
updated for that run through the loop. Please note: code appears in red text, comments in the code appear
in green text, and screen output appears in blue text.
int count=O;
int i;
for
(i
1; i
<= 10; i++)
IIInitialize the count to zero
IIDeclare an integer variable to be used as the
I/incrementer for the for loop.
I/Initialize the beginning value of i to 1.
IITell the loop to run as long as the value of
I i i is less than or equal to 10.
IIIncrement the value of i by 1 at the end of
I/each time through the loop.
count++;
IIIncrement the count variable.
cout « "The current value of the count is: " « count «
cout «
"After the loop is over, the final count is:
" «
endl;
count «
endl;
The output that will be shown to the screen when the above code segment is run will be the following:
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
After the loop is
of the count is: 1
of the count is: 2
of the count is: 3
of the count is: 4
of the count is: 5
of the count is: 6
of the count is: 7
of the count is: 8
of the count is: 9
of the count is: 10
over, the final count is: 10
For a second example, check out the interactive for loop example.
MBiI.'._*4=i"". _... ..__"'+1;I.II_.II'I·'_
-;c.Jt •• _ ..~...__
~
Author 1Last Update: Tuesday, April 11, 2000 01:11:081 Technical comments to the Webmaster
Ball State University practices equal opportunity in education and employment and is strongly and actively committed to diversity within its community.
Links contained in thisfile to information prOVided by organizations other than Ball State University's Computer Science Department are presented as a
service and neither constitute nor imply endorsement or warranty.
1 of 1
4/11100 9:06 PM
C:\My Documents\ .. \Honors Related\Honors 499\thesis\forloop.html
<html>
<head>
<!-- Author: Ryan wilson -->
<Title>For LOOp example</title>
<!-- Begin common area -->
<script>
II This function displays the time in the status line.
II Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new Date(); II Get current time
var h = d.getHours(); II Extract hours: 0 to 23
var m = d.getMinutes(); II Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; IllS it am or pm?
if (h > 12)
h-=12; Ilconvert 24-hour format to 12-hour
if ( h == 0)
h 12; II convert 0 o'clock to midnight
if (m < 10)
m = "0" + m; Ilconvert 0 minutes to 00 minutes, etc.
var t = h + I:' + m + ' , + ampm; II Put it all together
defaultstatus = t;
IIDisplay it in the status line.
IIArrange to do it all again in 1 minute.
setTimeout("display_time_in_status_lineO", 60000); 1160000 ms is 1 min.
}
II A variable we use to ensure that each error window we create is unique.
var error_count = 0;
II Email address to send the report to.
var email = "rawilson@bsuvc.bsu.edu";
II
Define the error handler.
It generates an HTML form so the user
II can report the error to the author.
function report_error(msg, url, line)
{
var w = window.open("","error"+error_count++,"resizable,status,width=625,height=400");
II arguements ... url (none specified), Name (force it to be unique), Features
var d = w.document; II We use this variable to save typing.
II output an HTML document, including a form, into the new window.
d.write('<Dlvalign=center>');
d.write('<FoNT SIZE=? FAcE="helvetica"><B>');
d.write('oops .... A Javascript Error Has occurred!');
d. wri te(, </B></FONT><BR><HR SIZE=4 WIDTH="80%">');
d.write('<FoRM ACTION="mailto:' + email + III METHOD=post');
d.write(, ENCTYPE="text/plain">');
d.write('<FONT SIZE=3>');
d.write(,<I>CLick the "Report Error" button to send a bug report.<I><BR>');
d.write('<INPUT TYPE="submit" VALUE="Report Error">   ');
d. wri te(, <INPUT TYPE="button" VALUE="Di smi ss" onel i ck="self. closeO">');
d.write('</Dlv><Dlvalign=right>');
d.write('<BR>YOUr name <I>(optional)</I>: I);
d.write('<INPUT SIZE=42 NAME="name" VALUE="">');
d.write('<BR>Error Message: I);
d.write('<INPUT SIZE=42 NAME="message" VALUE='" + msg + III>');
d.write('<BR>Document: <INPUT SIZE=42 NAME="url" VALUE='" + url + "'>');
d. wri te (' <BR>L i ne Number: <INPUT SIZE=42 NAME="l i ne" VALUE='" + 1i ne + "'>') ;
d.write('<sR>srowser version: I);
d.write('<INPUT SIZE=42 NAME="version" VALUE="'+navigator.userAgent + "'>');
d.write('</DIV></FONT>');
d.write('</FoRM>');
II Remember to close the document when we're done.
d.closeO;
II
Return true from this error handler, so that Javascript does not
II display it own error dialog.
return true;
}
II
Before the event handler can take effect, we have to register it
1
C:\My oocuments\ .. \Honors Related\Honors 499\thesis\forloop.html
// for a particular window.
self.onerror = report_error;
2
var bcolor;
var allcookies = document.cookie;
var pos = allcookies. indexof("color=");
if (pos != -1)
{
var start = pos + 6;
var end = allcookies.indexof(";", start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
}
else
bcolor = "white";
function setbgcolor(bcolor)
{
document.bgcolor = bcolor;
}
</SCRIPT>
<!-- End common area -->
</head>
<body text="#OoOF58" link="#760BlO" alink="#544C51"
onLoad="display_time_in_status_lineO; setbgcolor(bcolor);">
<p>Here is an example of a simple <b>for</b> loop. This <b>for</b> ·loop will
count from 0 to 10 by adding 1 to the previous count each time through the
loop. The count begins at 0 and holds the value of 10 after the loop runs
10 times. The current value of the count is printed from inside the loop just
after the count is updated for that run through the loop. please note: code
appears in <font color="red">red text</font>, comments in the code appear in
<font color="green">green text</font>, and screen output appears in
<font color="blue">blue text.</font>
</p>
<font color="red">
<pre>
int count=O;
i nt i;
</font>
<font color="green">//Initialize the count to zero</font>
<font color="green">//oeclare an integer variable to be used as thelt
<font color="green">//incrementer for the <b>for</b> loop.</font>
for (i = 1; i <= 10; i++) <font color="green">//Initialize the beginning value of i to 1.</
font>
<font color="green">//Tell the loop to run as long as the value of It
</font>
<font color="green">//i is less than or equal to 10.</font>
<font color="green">//Increment the value of i by 1 at the end of</It
font>
<font color="green">//each time through the loop.</font>
{
count++;
<font color="green">//Increment the count variable.</font>
cout « "The current value of the count is: " « count « endl;
}
cout « "After the loop is over, the final count is: " « count « endl;
</pre>
</font>
<p>
The output that will be shown to the screen when the above code segment is
run will be the following:
</p>
<pre>
<font color="blue">The current
The current value of the count
The current value of the count
The current value of the count
The current value of the count
The current value of the count
The current value of the count
The current value of the count
value of the count is: 1
is: 2
is: 3
is: 4
is: 5
is: 6
is: 7
is: 8
c:\Download\thesis\forloop.html
The current value of the count is: 9
The current value of the count is: 10
After the loop is over, the final count is: 10</font>
</pre>
<p>
For a second example, check out the <a href="iforloop.html" target="fill">
interactive for loop</a> example.
</p>
<!-- Footer -->
<hr>
<br>
<p align="center">
<a href=''http://www.bsu.edu/home.html'' taroet="_top">
<img src="gifs/home.gif" border="O" WIDTH=1l72" HEIGHT="14">
<fa>
<a href="mailto:ASKBSU@bsu.edu" target="_top">
<img src="gifs/ask.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/cgi-bin/guest'' taroet="_top">
<img src="gifs/guest.gif" border="O" WIDTH="72 11 HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/uP/about/bsu.html'' target="_t0r.">
<img src="gifs/about.gif" border="O" WIDTH="72" HEIGHT="14'>
<fa>
<a href=''http://www.bsu.edu/uP/mar./indiana.html'' target="_top">
<img src="gifs/map.gif" border="O' WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/htmls/search.html'' target="_top">
<img src="gifs/search.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/home_help.html'' target="_top">
<img src="gifs/help.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<br>
<font size="-l">
<a href="mailto:rawilson@bsuvc.bsu.edu">Author</a> I
Last update: <SCRIPT>document.write(document.lastModified);</sCRIPT> I
<a href="mailto:rawilson@bsuvc.bsu.edu">Technical comments to the webmaster</a>
</font>
<br>
<font size="-4">
Ball state university practices equal opportunity in education and employment
and is strongly and actively committed to diversity within its community.
</font>
</p>
<p align="center">
<em>
<font size="-4">
Links contained in this file to information provided
by organizations other than Ball state university's computer science
Department are presented as a service and neither constitute nor imply
endorsement or warranty.
</font>
</em>
</p>
</body>
</html>
3
Interactive For Loop example
wysiwyg://top. fill. 98/http://www.cs. bsu.edul-raw/thesis/topifor.html
This interactive example of a for loop will help you to gain a better understanding of what happens
behind the code when a for loop is executing. Please enter your own values in the drop down boxes you
find in the code below. After entering values into all the boxes, please click on 'RUN' button below.
Please note: code appears in red text, comments in the code appear in green text, and screen output
appears in blue text in the bottom window segment. Also, if you encounter an infinite loop, the final
value for count will be jncorrect!
int count= __O__~~~
for(i= 0
R;
//Initialize the count variable
·_O_--IR
. "¥.... ; i. ++ R) //Set
i_<___R_"¥....
the loop parameters.
{
R;
count' ++
//Increment or decrement count.
cout « "The current value of the count is: " « count «
cout «
"After the loop is over, the final count is: " «
-ICe]3'-
_Mnll"'_ *4:,.".__
endl;
count «
endl;
..114;1111'.1,•• ·•
Author I Last Update: Friday, March 17,200001:04:30 I Technical comments to the Webmaster
Ball State University practices equal opportunity in education and employment and is strongly and actively committed to diversity within its community.
Links contained in this file to information prOVided by organizations other than Ball State University's Computer Science Department are presented as a
service and neither constitute nor imply endorsement or warranty.
1 of 1
3/25/00 6:50 PM
http://www .cs.bsu.edu/-raw/thesislbottomifor.html
1 of 1
3/25/006:51 PM
C:\Download\thesis\iforloop.html
<HTML>
<HEAD>
<!-- Author: Ryan wilson -->
</HEAD>
<FRAMESET rows="55%,45%">
<FRAME NAME="top" SRC="t0p'ifor.html" noresize>
<FRAME NAME="bottom" sRc='bottomifor.html" scrolling=no noresize>
</FRAMESET>
</HTML>
1
C:\My Documents\ .. \Honors Related\Honors 499\thesis\topifor.html
<html>
<head>
<!-- Author: Ryan wilson -->
<Title>Interactive For LOOp example</title>
<!-- Begin common area -->
<script>
II This function displays the time in the status line.
II Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new Date(); II Get current time
var h = d.getHours(); II Extract hours: 0 to 23
var m = d.getMinutes(); II Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; IllS it am or pm?
if (h > 12)
.
h-=12; IIConvert 24-hour format to 12-hour
if ( h == 0)
h 12; II convert 0 o'clock to midnight
if (m < 10)
m = "0" + m; Ilconvert 0 minutes to 00 minutes, etc.
var t = h + ':' + m + ' , + ampm; II Put it all together
defaultstatus = t;
IIDisplay it in the status line.
lIAr range to do it all again in 1 minute.
setTimeout("display_time_in_status_lineO", 60000); 1160000 ms is 1 min.
}
II A variable we use to ensure that each error window we create is unique.
var error_count = 0;
II Email address to send the report to.
var email = "rawilson@bsuvc.bsu.edu";
II
Define the error handler.
It generates an HTML form so the user
II can report the error to the author.
function report_error(msg, url, line)
{
var w = window.open("", "error"+error_count++, "resizable,status ,width=625,height=400");
arguements ... url (none specified), Name (force it to be unique), Features
var d = w.document; II we use this variable to save typing.
II
II Output an HTML document, including a form, into the new window.
d.write('<Dlvalign=center>');
d.write('<FONT SIZE=? FACE="helvetica"><B>');
d.write('oops .... A Javascript Error Has occurred! ');
d. wri te(, </B></FoNT><BR><HR SIZE=4 WIDTH="80%">');
d.write('<FoRM ACTION=" mail to: , + email + "' METHOD=post');
d.write(' ENCTYPE="text/plain">');
d.write('<FoNT SIZE=3>');
d.write(,<I>CLick the "Report Error" button to send a bug report.<I><BR>');
d.write('<INPuT TYPE="submit" VALUE="Report Error">   ');
d .write(' <INPUT TYPE="button" VALUE="Di smi ss" onel i ck="self. cl oseO ">');
d.write('</DIV><DIvalign=right>');
d.write('<BR>YOUr name <I>(optional)</I>: ');
d.write('<INPUT SIZE=42 NAME="name" VALUE="">');
d.write('<BR>Error Message: ');
d.write('<INPUT SIZE=42 NAME="message" VALUE='" + msg + '''>');
d.write('<BR>Document: <INPUT SIZE=42 NAME="url" VALUE='" + url + '''>');
d. wri te(, <BR>L i ne Number: <INPUT SIZE=42 NAME="l i ne" VALUE='" + 1i ne + "'>') ;
d.write('<BR>Browser version: ');
d.write('<INPuT SIZE=42 NAME="version" VALuE="'+navigator.userAgent + '''>');
d.write('</DIV></FONT>');
d.write('</FoRM>');
II Remember to close the document when we're done.
d. closeO;
II
Return true from this error handler, so that Javascript does not
II display it own error dialog.
}
II
return true;
Before the event handler can take effect, we have to register it
1
c:\oownload\thesis\topifor.html
// for a particular window.
self.onerror = report_error;
var bcolor;
var allcookies = document. cookie;
var pos = allcookies.indexof("color=");
if (pos != -1)
{
var start = pos + 6;
var end = allcookies.indexof(";", start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
}
else
bcolor = "white";
function setbgcolor(bcolor)
{
}
document.bgcolor = bcolor;
// End common area
</SCRIPT>
</head>
<body text="#OoOFS8" link="#760B10" alink="#S44CS1"
onLoad="display_time_in_status_line(); setbgcolor(bcolor);">
<p>This interactive example of a <b>for</b> loop will help you to gain a
better understanding of what happens behind the code when a <b>for</b> loop
is executing. please enter your own values in the drop down boxes you find
in the code below. After entering values into all the boxes, please click on
'RUN' button below.
please note: code
appears in <font color="red">red text</font>, comments in the code appear in
<font color="green">green text</font>, and screen output appears in
<font color="blue">blue text</font> in the bottom window segment. Also, if you
encounter an infinite loop, the final value for count will be incorrect!
</p>
<form name="forloop">
<font color="red">
<pre>
int count=<select name="initcount" id="initcount" size="l">
<option value="-S">-S</option>
<option value="-4">-4</option>
<option value="-3">-3</option>
<option value="-2">-2</option>
<option value="-l">-l</option>
<option selected value="O">O</option>
<option value="l">l</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="S">S</0p'tion>
</select>
<font color='9reen">//Initialize the count variable</font>
for(i=<select name="in;t;" ;d="in;t," s;ze="l">
<option value="-S">-S</option>
<option value="-4">-4</option>
<option value="-3">-3</option>
<option value="-2">-2</option>
<option value="-l">-l</option>
<option selected value="O">O</opt;on>
<option value="l">l</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="S">S</opt;on></select>; i<select name="op1" ;d="op1" size="l">
<option value=">">></0p'tion>
<option selected value="< '>&It;</opt;on>
<option value=">=">>=</option>
<option value="<"><=</opt;on>
<option value="!=">!=</option>
</select><select name="endval" id="endval" size="l">
2
c:\oownload\thesis\topifor.html
<option value="-S">-S</option>
<option value="-4">-4</option>
<option value="-3">-3</option>
<option value="-2">-2</option>
<option value="-l">-l</option>
<option selected value="O">O</option>
<option value="l">l</option>
<option value="2">2</option>
<option value="3">3</option>
<optlon value="4">4</option>
<option value="S">S</0p'tion>
</select>;i<select name='incdeci" id="incdeci" size="l">
<option selected value="++">++</option>
<option value="--">--</option></select»<font color="green">//set the loop
parameters.</font>
{
count<select name="incdeccnt" id="incdeccnt" size="l">
<option selected value="++">++</option>
<option value="--">--</option>
</select>;
<font color="green">//Increment or decrement count.</font>
cout « "The current value of the count is: " « count « endl;
}
cout « "After the loop is over, the final count is: " « count « endl;
</pre>
</font>
<center><input type="button" value="Run" name="run" onclick="runloopC);"></center>
</form>
<SCRIPT>
function runloop()
{
var initcnt = 0;
var initi = 0;
var decinci = 0;
var decinccnt = 0;
var op = 0;
var endvalue = 0;
for(var i=O; i < document.forloop.initcount.length; i++)
{
if (document.forloop.initcount[i].selected)
initcnt = document.forloop.initcount[i].value;
}
for(i = 0; i < document.forloop.initi.length; i++)
{
if (document.forloop.initi[i].selected)
initi = document.forloop.initi[i].value;
}
for(i = 0; i < document.forloop.opl.length; i++)
{
if (document.forloop.opl[i].selected)
op
document.forloop.opl[i].value;
}
for(i = 0; i < document.forloop.endval.length; i++)
{
if (document.forloop.endval[i].selected)
endvalue = document. forloop. endval [i].value;
}
.
for(i = 0; i < document.forloop.incdeci .length; i++)
{
.
if (document.forloop.incdeci[i].selected)
decinci = document.forloop.incdeci[i].value;
}
forei = 0; i < document.forloop.incdeccnt.length; i++)
{
if (document.forloop.incdeccnt[i].selected)
decinccnt = document.forloop.incdeccnt[i].value;
}
parent.frames[l].document.box.screen.value=";
switch(op)
{
case '!=':
if (decinci
{
'++')
3
c:\oownload\thesis\topifor.html
for(i=initi; i != endvalue; i++)
{
if (decinccnt == '++')
initcnt++;
else
initcnt--;
parent.frames[I].document.box.screen.value+=
'The current value of count is: ' + initcnt +'\n';
if (initcnt > 16 I I initcnt < -16)
{
parent.frames[I].document.box.screen.value+=
'You created an infinite loop! It has been stopped.\n';
i = endvalue - 1;
}
}
}
else
{
for(i=initi; i != endvalue; i--)
{
if (decinccnt == '++')
initcnt++;
else
initcnt--;
parent.frames[I].document.box.screen.value+=
'The current value of count is: ' + initcnt +'\n' ;
if (initcnt > 16 I I initcnt < -16)
{
parent.frames[I].document.box.screen.value+=
'You created an infinite loop! It has been stopped.\n';
i = endvalue + 1;
}
}
}
break;
case '<=':
if (decinci == '++')
{
for(i=initi; i <= endvalue; i++)
{
if (decinccnt == '++')
initcnt++;
else
initcnt--;
parent.frames[I].document.box.screen.value+=
'The current value of count is: ' + initcnt + '\n';
}
}
else
{
for(i=initi; i <= endvalue; i--)
{
if (decinccnt == '++')
initcnt++;
else
initcnt--;
parent.frames[I].document.box.screen.value+=
'The current value of count is: ' + initcnt +'\n' ;
if (initcnt > 16 I I initcnt < -16)
{
parent.frames[I].document.box.screen.value+=
'You created an infinite loop! It has been stopped.\n';
i = endvalue+l0;
}
}
}
break;
case '>=':
if (decinci == '++')
{
for(i=initi; i >= endvalue; i++)
{
if (decinccnt
initcnt++;
'++')
4
c:\Download\thesis\topifor.html
else
initcnt--;
parent.frames[l].document.box.screen.value+=
'The current value of count is: ' + initcnt +'\n';
if (initcnt > 16 I I initcnt < -16)
{
parent.frames[1].document.box.screen.value+=
'You created an infinite loop! It has been stopped.\n';
i = endvalue - 10;
}
}
}
else
{
for(i=initi; i >= endvalue; i--)
{
if (decinccnt == '++')
initcnt++;
else
initcnt--;
parent.frames[1].document.box.screen.value+=
'The current value of count is: ' + initcnt +'\n';
}
}
break;
case '>':
if (decinci == '++')
{
for(i=initi; i > endvalue; i++)
{
if (decinccnt == '++')
initcnt++;
else
initcnt--;
parent.frames[1].document.box.screen.value+=
'The current value of count is: ' + initcnt +'\n' ;
if (initcnt > 16 I I initcnt < -16)
{
parent.frames[1].document.box.screen.value+=
'You created an infinite loop! It has been stopped.\n';
i = endvalue - 10;
}
}
}
else
{
for(i=initi; i > endvalue; i--)
{
if (decinccnt == '++')
initcnt++;
else
initcnt--;
parent.frames[1].document.box.screen.value+=
'The current value of count is: ' + initcnt +'\n';
}
}
break;
case '<':
if (decinci == '++')
{
for(i=initi; i
{
<
endvalue; i++)
if (decinccnt == '++')
initcnt++;
else
initcnt--;
parent.frames[l].document.box.screen.value+=
'The current value of count is: ' + initcnt +'\n' ;
}
}
else
{
for(i=initi; i
<
endvalue; i--)
5
c:\Download\thesis\topifor.html
{
if (decinccnt
'++')
initcnt++;
else
initcnt--;
parent.frames[l].document.box.screen.value+=
'The current value of count is: ' + initcnt +'\n';
if (initcnt > 16 I I initcnt < -16)
{
}
parent.frames[l].document.box.screen.value+=
'YOU created an infinite loop!
It has been stopped.\n';
i = endvalue + 10;
}
}
}
break;
parent.frames[l].document.box.screen.value+=
'After the loop is over, the final count is: , + initcnt;
}
</SCRIPT>
<!-- Footer -->
<hr>
<br>
<p align="center">
<a href=''http://www.bsu.edu/home.html'' taraet="_top">
<img src="gifs/home.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href="mailto:ASKBSu@bsu.edu" target="_top">
<img src="gifs/ask.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/cgi-bin/guest'' taraet="_top">
<img src="gifs/guest.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/uP/about/bsu.html'' target="_top,">
<img src="gifs/about.gif" border="O" WIDTH="72" HEIGHT="14'>
<fa>
<a href=''http://www.bsu.edu/uP/map,/indiana.html'' target="_top">
<img src="gifs/map.gif" border="O' WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/htmls/search.html'' target="_top">
<img src="gifs/search.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/home_help.html'' target="_top">
<img src="gifs/help.gif" border="O" WIDTH="72" HEIGHT=,,14">
<fa>
<br>
<font size="-l">
<a href="mailto:rawilson@bsuvc.bsu.edu">Author</a> I
Last update: <SCRIPT>document.write(document.lastModified);</SCRIPT> I
<a href="mailto:rawilson@bsuvc.bsu.edu">Technical comments to the webmaster</a>
</font>
<br>
<font size="-4">
Ball State university practices equal opportunity in education and employment
and is strongly and actively committed to diversity within its community.
</font>
</p>
<p align="center">
<em>
<font size="-4">
Links contained in this file to information provided
by organizations other than Ball State university's computer science
Department are presented as a service and neither constitute nor imply
endorsement or warranty.
</font>
</em>
</p>
</body>
</html>
6
C:\My Documents\ .. \Honors Related\Honors 499\thesis\bottomifor.html
<html>
<head>
<!-- Author: Ryan wilson -->
<script>
II This function displays the time in the status line.
II Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new Date(); II Get current time
var h = d.getHours(); II Extract hours: 0 to 23
var m = d.getMinutes(); II Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; Ills it am or pm?
if (h > 12)
h-=12; Ilconvert 24-hour format to 12-hour
if ( h == 0)
h 12; II convert 0 o'clock to midnight
if (m < 10)
m "" "0" + m; Ilconvert 0 minutes to 00 minutes, etc.
var t = h + ':' + m + ' , + ampm; II Put it all together
defaultStatus = t;
IIDisplay it in the status line.
IIArrange to do it all again in 1 minute.
setTimeout("display_time_in_status_lineO", 60000); 1160000 ms is 1 min.
}
II A variable we use to ensure that each error window we create is unique.
var error_count = 0;
II Email address to send the report to.
var email .... "rawilson@bsuvc.bsu.edu";
II
Define the error handler.
It generates an HTML form so the user
II can report the error to the author.
function report_error(msg, url, line)
{
var w = window.open("" ,"error"+error_count++, "resizable,status ,width=625,height=400");
arguements ... url (none specified), Name (force it to be unique), Features
var d = w.document; II We use this variable to save typing.
II
II Output an HTML document, including a form, into the new window.
d.write('<Dlvalign=center>');
d .writeC' <FONT SIZE=? FACE="helveti ca"><B>');
d.write('ooPs .... A Javascript Error Has occurred!');
d. wri teC' </B></FONT><BR><HR SIZE=4 WIDTH="80%">');
d.writeC'<FORM ACTION="mailto:' + email + '" METHOD=post');
d .wri teC' ENCTYPE="text/plai n">');
d.write('<FoNT SIZE=3>');
d.writeC'<I>cLick the "Report Error" button to send a bug report.<I><BR>');
d.writeC'<INPuT TYPE="submit" VALuE="Report Error">   ');
d.writeC'<INPuT TYPE="button" VALUE="Dismiss" onclick="self.closeO">');
d.write('</Dlv><Dlvalign=right>');
d.write('<BR>YOUr name <I>(optional)</I>: ');
d.writeC'<INPuT SIZE",,42 NAME",,"name" VALUE",,"">');
d.write('<BR>Error Message: ');
d.write('<INPUT SIZE=42 NAME="message" VALUE='" + msg + '''>');
d.writeC'<BR>Document: <INPUT SIZE=42 NAME="url" VALUE='" + url + "'>');
d.writeC'<BR>Line Number: <INPUT SIZE=42 NAME="line" VALUE=", + line +'''>');
d.write('<BR>Browser version: ');
d.writeC'<INPuT SIZE=42 NAME="version" VALuE="'+navigator.userAgent + '''>');
d.write('</DIV></FONT>');
d.write('</FoRM>');
II Remember to close the document when we're done.
d.closeO;
II
II
}
Return true from this error handler, so that Javascript does not
display it own error dialog.
return true;
II Before the event handler can take effect, we have to register it
II
for a particular window.
self.onerror = report_error;
1
c:\oownload\thesis\bottomifor.html
var bcolor;
var allcookies = document. cookie;
var pos = allcookies.indexof("color=");
if (pos != -1)
{
var start = pos + 6;
var end = allcookies.indexof("; " , start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
}
else
bcolor = "white";
function setbgcolor(bcolor)
{
document.bgcolor = bcolor;
}
</SCRIPT>
</head>
<body text="#OoOF58" link="#760s10" alink="#544C51"
onLoad="display_time_in_status_lineO; setbgcolor(bcolor);">
<form name="box">
<textarea name="screen" value="" rows=10 cols=70 wrap=on></textarea>
</form>
</body>
</html>
2
While Loop example
wysiwyg:llfil1.98lhttp://www.cs.bsu.edul-raw/thesis/whileloop.html
Here is an example of a simple while loop. This while loop will count from 0 to 10 by adding 1 to the
previous count each time through the loop. The count begins at 0 and holds the value of 10 after the loop
runs 10 times. The current value of the count is printed from inside the loop just after the count is
updated for that run through the loop. Please note: code appears in red text, comments in the code appear
in green text, and screen output appears in blue text.
int count=O;
while(count < 10)
//Initialize the count to zero
//Instruct the loop to continue looping as
//long as the count is less than 10.
//This is the test case.
count++;
//Increment the count variable.
cout « "The current value of the count is: " « count «
cout «
"After the loop is over, the final count is: " «
endl;
count «
endl;
The output that will be shown to the screen when the above code segment is run will be the following:
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
After the loop is
of the count is: 1
of the count is: 2
of the count is: 3
of the count is: 4
of the count is: 5
of the count is: 6
of the count is: 7
of the count is: 8
of the count is: 9
of the count is: 10
over, the final count is: 10
For a second example, check out the interactive while loop example.
_:CIlt'-
__011 ..,
*4:'11,.-
__
~114;"':I.II"·'_
Author 1Last Update: Monday, November 08, 199921:16:381 Technical comments to the Webmaster
Ball State University practices equal opportunity in education and employment and is strongly and actively committed to diversity within its community.
Links contained in this file to information provided by organizations other than Ball State University's Computer Science Department are presented as a
service and neither constitute nor imply endorsement or warranty.
1 of 1
3125/00 6:51 PM
C:\My Documents\ .. \Honors Related\Honors 499\thesis\whileloop.html
<html>
<head>
<!-- Author: Ryan wilson -->
<Title>while LOOp example</title>
<!-- Begin common area -->
<script>
II This function displays the time in the status line.
II Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new Date(); II Get current time
var h = d.getHours(); II Extract hours: 0 to 23
var m = d.getMinutes(); II Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; IllS it am or pm?
if (h > 12)
h-=12; Ilconvert 24-hour format to 12-hour
if ( h == 0)
h 12; II convert 0 o'clock to midnight
if (m < 10)
m = "0" + m; Ilconvert 0 minutes to 00 minutes, etc.
var t = h + I:' + m + ' , + ampm; II Put it all together
defaultstatus = t;
IIDisplay it in the status line.
IIArrange to do it all again in 1 minute.
setTimeout("display_time_in_status_lineO", 60000); 1160000 ms is 1 min.
}
II A variable we use to ensure that each error window we create is unique.
var error_count = 0;
II Email address to send the report to.
var email = "rawilson@bsuvc.bsu.edu";
II
Define the error handler.
It generates an HTML form so the user
II can report the error to the author.
function report_error(msg, url, line)
{
var w = window.open("" , "error"+error_count++, "resizable,status ,width=625,height=400");
arguements ... url (none specified), Name (force it to be unique), Features
var d = w.document; II we use this variable to save typing.
II
II Output an HTML document, including a form, into the new window.
d.write('<Dlvalign=center>');
d.write('<FoNT SIZE=7 FACE="helvetica"><B>');
d.write('oops .... A Javascript Error Has occurred!');
d. wri te(, </B></FONT><BR><HR SIZE=4 WIDTH="80%">');
d . wri te (' <FORM ACTION= "ma i 1to:' + email + '" METHOD=post');
d.write(' ENCTYPE="text/plain">');
d.write('<FoNT SIZE=3>');
d.write(,<I>CLick the "Report Error" button to send a bug report.<I><BR>');
d.write('<INPuT TYPE="submit" VALUE="Report Error">   ');
d .wri te(, <INPUT TYPE="button" VALUE="Di smi ss" oncl i ck="self. closeO ">');
d.write('</Dlv><Dlvalign=right>');
d.write('<BR>YOUr name <I>(optional)</I>: I);
d.write('<INPuT SIZE=42 NAME="name" VALUE="">');
d.write('<BR>Error Message: I);
d.write('<INPUT SIZE=42 NAME="message" VALUE='" + msg + '''>');
d.write('<BR>Document: <INPUT SIZE=42 NAME="url" VALUE='" + url + '''>');
d.write('<BR>Line Number: <INPUT SIZE=42 NAME="line" VALUE=", + line +'''>');
d.write('<BR>Browser version: I);
d. wri te (' <INPUT SIZE=42 NAME="versi on" VALUE='" +navi gator. userAgent + '''>');
d.write('</DIV></FONT>');
d.write('</FoRM>');
II Remember to close the document when we're done.
d.closeO;
II
Return true from this error handler, so that Javascript does not
II display it own error dialog.
}
II
return true;
Before the event handler can take effect, we have to register it
1
c:\Oownload\thesis\whileloop.html
// for a particular window.
self.onerror = report_error;
2
var bcolor;
var allcookies = document. cookie;
var pos = allcookies.indexof("color=");
if (pos != -1)
{
var start = pos + 6;
var end = allcookies.indexof(";", start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
}
else
bcolor = "white";
function setbgcolor(bcolor)
{
document.bgcolor = bcolor;
}
</SCRIPT>
<!-- End common area -->
</head>
<body text="#OOOF58" link="#760BI0" alink="#544C51"
onLoad="display_time_in_status_lineO; setbgcolor(bcolor);">
<p>Here is an example of a simple <b>while</b> loop. This <b>while</b> loop
will count from 0 to 10 by adding 1 to the previous count each time through the
loop. The count begins at 0 and holds the value of 10 after the loop runs
10 times. The current value of the count is printed from inside the loop just
after the count is updated for that run through the loop. please note: code
appears in <font color="red">red text</font>, comments in the code appear in
<font color="green">green text</font>, and screen output appears in
<font color="blue">blue text.</font>
</p>
<font color="red">
<pre>
int count=O;
while(count < 10)
font>
{
<font color="green">//Initialize the count to zero</font>
<font color="green">//Instruct the loop to continue looping as</
<font color="green">//long as the count is less than 10.</font>
<font color="green">//This is the test case.</font>
count++;
<font color="green">//Increment the count variable.</font>
cout « "The current value of the count is: " « count « endl;
}
cout « "After the loop is over, the final count is: " «
</pre>
</font>
count «
endl;
<p>
The output that will be shown to the screen when the above code segment is
run will be the following:
</p>
<font color="blue">
<~re>
T e current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
After the loop is
</pre>
</font>
of the count is: 1
of the count is: 2
of the count is: 3
of the count is: 4
of the count is: 5
of the count is: 6
of the count is: 7
of the count is: 8
of the count is: 9
of the count is: 10
over, the final count is: 10
c:\Download\thesis\whileloop.html
<p>
For a second example, check out the <a href="iwhileloop.html" target="fill">
interactive while loop</a> example.
</p>
<!-- Footer -->
<hr>
<br>
<p align="center">
<a href=''http://www.bsu.edu/home.html'' taraet="_top">
<img src="gifs/home.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href="mailto:ASKBSu@bsu.edu" target="_tQP">
<img src="gifs/ask.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/cgi-bin/guest'' taraet="_top">
<img src="gifs/guest.gif" border="O" WIDTH=" 72 i'f HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/uP/about/bsu.html'' target="_top,">
<img src="gifs/about.gif" border="O" WIDTH="72" HEIGHT="14'>
<fa>
<a href=''http://www.bsu.edu/uP/map,/indiana.html'' target="_top">
<img src="gifs/map.gif" border="O' WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/htmls/search.html'' target="_top">
<img src="gifs/search.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/home_help.html'' target="_top">
<img src="gifs/help.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<br>
<font size="-l">
<a href="mailto:rawilson@bsuvc.bsu.edu">Author</a> I
Last update: <SCRIPT>document.write(document.lastModified);</SCRIPT> I
<a href="mailto:rawilson@bsuvc.bsu.edu">Technical comments to the webmaster</a>
</font>
<br>
<font size="-4">
Ball State university practices equal opportunity in education and employment
and is strongly and actively committed to diversity within its community.
</font>
</p>
<p align="center">
<em>
<font size="-4">
Links contained in this file to information provided
by organizations other than Ball State university's computer Science
Department are presented as a service and neither constitute nor imply
endorsement or warranty.
</font>
</em>
</p>
</body>
</html>
3
Interactive While Loop example
wysiwyg://top.fiII. 98/http://www.cs. bsu.edul-raw/thesis/topiwhile.html
This interactive example of a while loop will help you to gain a better understanding of what happens
behind the code when a while loop is executing. Please enter your own values in the drop down boxes
you find in the code below. After entering values into all the boxes, please click on 'RUN' button below.
Please note: code appears in red text, comments in the code appear in green text, and screen output
appears in blue text in the bottom window segment. Also, if you encounter an infinite loop, the final
value for count will be incorrect!
IIInitialize the count variable
____~~_____r1~T~)
IISet the loop to continue as long
lias the condition evaluates as true.
cout «
cout «
IIIncrement or decrement count.
"The current value of the count is: " « count «
"After the loop is over, the final count is: " «
.:Celt'.
_"'''1.' __*4:1.,•• __
endl;
count «
endl;
_..114;01: 1_.11 ••.•_
Author I Last Update: Friday, March 17, 2000 01:02:45 I Technical comments to the Webmaster
Ball State University practices equal opportunity in education and employment and is strongly and actively committed to diversity within its community.
Links contained in thisfile to information provided by organizations other than Ball State University's Computer Science Department are presented as a
service and neither constitute nor imply endorsement or warranty.
1 of 1
3/25/00 6:53 PM
http://www.es. bsu.edul-raw/thesislbottomiwhile.html
1 of 1
3/25/00 6:54 PM
c:\Download\thesis\iwhileloop.html
<HTML>
<HEAD>
<!-- Author: Ryan wilson -->
</HEAD>
<FRAMESET rows="55%,45%">
<FRAME NAME="top" SRC="t0p'iwhile.html" noresize>
<FRAME NAME="bottom" sRc='bottomiwhile.html" scrolling=no noresize>
</FRAMESET>
</HTML>
1
C:\My Documents\ .. \Honors Related\Honors 499\thesis\topiwhile.html
<html>
<head>
<!-- Author: Ryan wilson -->
<Title>Interactive while LOOP example</title>
<!-- Begin common area -->
<script>
II This function displays the time in the status line.
II Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new Date(); II Get current time
var h = d.getHours(); II Extract hours: 0 to 23
var m = d.getMinutes(); II Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; IllS it am or pm?
if (h > 12)
h-=12; Ilconvert 24-hour format to 12-hour
if ( h == 0)
h 12; II convert 0 o'clock to midnight
if (m < 10)
m = "0" + m; Ilconvert 0 minutes to 00 minutes, etc.
var t = h + ':' + m + ' , + ampm; II Put it all together
defaultstatus = t;
IIDisplay it in the status line.
liAr range to do it all again in 1 minute.
setTimeout(ltdisplay_time_in_status_lineO", 60000); 1160000 ms is 1 min.
}
II A variable we use to ensure that each error window we create is unique.
var error_count = 0;
II Email address to send the report to.
var email = "rawilson@bsuvc.bsu.edu";
II Define the error handler. It generates an HTML form so the user
II can report the error to the author.
function report_error(msg, url, line)
{
var w = window.open("", "error"+error_count++, "resizable,status ,width=625,height=400");
arguements ... url (none specified), Name (force it to be unique), Features
var d = w.document; II We use this variable to save typing.
II
II Output an HTML document, including a form, into the new window.
d.write('<Dlvalign=center>');
d.write('<FONT SIZE=7 FAcE="helvetica"><B>');
d.write('oops .... A Javascript Error Has Occurred! I);
d. wri te(, </B></FONT><BR><HR SIZE=4 WIDTH="80%">');
d.write('<FORM ACTION="mailto:' + email + '" METHOD=post');
d.write(' ENCTYPE="text/plain">');
d.write('<FoNT SIZE=3>');
d.write(,<I>CLick the "Report Error" button to send a bug report.<I><BR>');
d.write('<INPUT TYPE="submit" VALUE="Report Error">   ');
d .wri te(, <INPUT TYPE="button" VALUE="Di smi ss" oncl i ck="self. closeO ">');
d.write('</Dlv><Dlvalign=right>');
d.write('<BR>YOUr name <I>(optional)</I>: I);
d.write('<INPuT SIZE=42 NAME="name" VALUE=''''>');
d.write('<BR>Error Message: I);
d.write('<INPUT SIZE=42 NAME="message" VALUE='" + msg + '''>');
d.write('<BR>Document: <INPUT SIZE=42 NAME="url" VALUE='" + url + '''>');
d. wri te(, <BR>L i ne Number: <INPUT SIZE=42 NAME="l i ne" VALUE='" + 1 i ne + "'>');
d.write('<BR>Browser version: I);
d. wri te(, <INPUT SIZE=42 NAME="versi on" VALUE='" +navi gator. userAgent + "'>');
d.write('</oIV></FONT>');
d.write('</FORM>');
II Remember to close the document when we're done.
d.closeO;
II Return true from this error handler, so that JavaScript does not
II
display it own error dialog.
return true;
}
II
Before the event handler can take effect, we have to register it
1
c:\oownload\thesis\topiwhile.html
1/ for a particular window.
self.onerror = report_error;
var bcolor;
var allcookies = document. cookie;
var pos = allcookies.indexof("color=");
if (pos != -1)
{
var start = pos + 6;
var end = allcookies.indexof(";", start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
}
else
bcolor = "white";
function setbgcolor(bcolor)
{
}
document.bgcolor = bcolor;
// End common area
</SCRIPT>
</head>
<body text="#OoOFS8" link="#760B10" alink="#S44CS1"
onLoad="display_time_in_status_lineO; setbgcolor(bcolor);">
<p>This interactive example of a <b>while</b> loop will help you to gain a
better understanding of what happens behind the code when a <b>while</b> loop
is executing. please enter your own values in the drop down boxes you find
in the code below. After entering values into all the boxes, please click on
'RUN' button below.
please note: code
appears in <font color="red">red text</font>, comments in the code appear in
<font color="green">green text</font>, and screen output appears in
<font color="blue">blue text</font> in the bottom window segment. Also, if you
encounter an infinite loop, the final value for count will be incorrect!
</p>
<form name="whileloop">
<font color="red">
<pre>
int count=<select name="initcount" id="initcount" size="l">
<option value="-S">-S</option>
<option value="-4">-4</option>
<option value="-3">-3</option>
<option value="-2">-2</option>
<option value="-l">-l</option>
<option selected value="O">O</option>
<option value="l">l</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="S">S</0p'tion>
</select>
<font color='green">//Initialize the count variable</font>
while(count <select name="op1" id="op1" size="l">
<option value=">">></0p'tion>
<option selected value="< '>&It;</option>
<option value=">=">>=</option>
<option value="<"><=</option>
<option value="!=">!=</option>
</select><select name="endval" id="endval" size="l">
<option value="-S">-S</option>
·<option value="-4">-4</option>
<option value="-3">-3</option>
<option value="-2">-2</option>
<option value="-l">-l</option>
<option selected value="O">O</option>
<option value="l">l</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="S">S</option>
2
c:\oownload\thesis\topiwhile.html
</select» <font color="green">//set the loop to continue as long</font>
<font color="green">//as the condition evaluates as true.</font>
{
}
count<select name="incdec" id="incdec" size="l">
<option selected value="++">++</option>
<option value="--">--</option>
</select>;
<font color="green">//Increment or decrement count.</font>
cout « "The current value of the count is: " « count « endl;
cout « "After the loop is over, the final count is:
« count « endl;
</pre>
</font>
<center><input type="button" value="Run" name="run" onclick="runloopC);"></center>
</form>
II
<SCRIPT>
function runloop()
{
var initcnt = 0;
var decincnt = 0;
var op = 0;
var endvalue = 0;
for(var i = 0; i < document.whileloop.initcount.length; i++)
{
if (document.whileloop.initcount[i].selected)
initcnt = document.whileloop.initcount[i].value;
}
for(i=O; i < document.whileloop.opl.length; i++)
{
if (document.whileloop.opl[i].selected)
op = document.whileloop.opl[i].value;
}
for(i=O; i < document.whileloop.endval.length; i++)
{
if (document.whileloop.endval[i].selected)
endval = document.whileloop.endval[i].value;
}
for(i=O; i < document.whileloop.incdec.length; i++)
{
if (document.whileloop.incdec[i].selected)
decincnt = document.whileloop.incdec[i].value;
}
parent.frames[l].document.box.screen.value=";
switch(op)
{
case' !=':
while (initcnt != endval)
{
if (decincnt == '++')
initcnt++;
else
initcnt--;
parent.frames[l].document.box.screen.value+=
'The current value of count is: ' + initcnt + '\n';
if (initcnt > 5 II initcnt < -5)
{
}
parent.frames[l].document.box.screen.value+=
'YOU created an infinite loop! It has been stopped.\n';
initcnt = endval;
}
break;
case '<=':
while (initcnt <= endval)
{
if (decincnt == '--')
initcnt--;
else
initcnt++;
parent.frames[l].document.box.screen.value+=
'The current value of count is: ' + initcnt + '\n';
if (initcnt > 5 I I initcnt < -5)
{
3
C:\Download\thesis\topiwhile.html
parent.frames[1].document.box.screen.value+=
'YOU created an infinite loop! It has been stopped.\n';
initcnt = endval + 1;
}
}
break;
case '>=':
while (initcnt >= endval)
{
if (decincnt == '++')
initcnt++;
else
initcnt--;
parent.frames[1].document.box.screen.value+=
'The current value of count is: ' + initcnt + '\n';
if (initcnt > 5 I I initcnt < -5)
{
}
parent.frames[1].document.box.screen.value+=
'You created an infinite loop! It has been stopped.\n';
initcnt = endval - 1;
}
break;
case '>':
while (initcnt > endval)
{
if (decincnt == '++')
initcnt++;
else
initcnt--;
parent.frames[1].document.box.screen.value+=
'The current value of count is: ' + initcnt + '\n';
if (initcnt > 5 I I initcnt < -5)
{
parent.frames[1].document.box.screen.value+=
'You created an infinite loop! It has been stopped.\n';
initcnt = endval;
}
}
break;
case '<':
while (initcnt < endval)
{
if (decincnt == '++')
initcnt++;
else
initcnt--;
parent.frames[1].document.box.screen.value+=
'The current value of count is: ' + initcnt + '\n';
if (initcnt > 5 II initcnt < -5)
{
}
parent.frames[1].document.box.screen.value+=
'You created an infinite loop! It has been stopped.\n';
initcnt = endval;
}
break;
}
parent.frames[1].document.box.screen.value+=
'After the loop is over, the final count is: ' + initcnt;
}
</SCRIPT>
<!-- Footer -->
<hr>
<br>
<p align="center">
<a href=''http://www.bsu.edu/home.html'' tar~et="_top">
<img src="gifs/home.gif" border="O" WIDTH= 72" HEIGHT="14">
<fa>
<a href="mailto:ASKBSu@bsu.edu" target="_top">
<img src="gifs/ask.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://VNIW.bsu.edu/cgi-bin/guest'' target="_top">
4
c:\Download\thesis\topiwhile.html
<img src="gifs/guest.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/up/about/bsu.html'' target="_t0p'''>,
<img src="gifs/about.gif" border="O" WIDTH="72" HEIGHT="14'>
<fa>
<a href=''http://www.bsu.edu/uP/map'/indiana.html'' target="_top">
<img src="gifs/map.gif" border="O' WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/htmls/search.html'' target="_top">
<img src="gifs/search.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/home_help.html'' target="_top">
<img src="gifs/help.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<br>
<font size="-l">
<a href="mailto:rawilson@bsuvc.bsu.edu">Author</a> I
last update: <SCRIPT>document.write(document.lastModified);</sCRIPT> I
<a href="mailto:rawilson@bsuvc.bsu.edu">Technical comments to the webmaster</a>
</font>
<br>
<font size="-4">
Ball State university practices equal opportunity in education and employment
and is strongly and actively committed to diversity within its community.
</font>
</p>
<p align="center">
<em>
<font size="-4">
links contained in this file to information provided
by organizations other than Ball State university's computer science
Department are presented as a service and neither constitute nor imply
endorsement or warranty.
</font>
</em>
</p>
</body>
</html>
5
C:\My Documents\ .. \Honors Related\Honors 499\thesis\bottomiwhile.html
<html>
<head>
<!-- Author: Ryan wilson -->
<script>
II This function displays the time in the status line.
II Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new Date(); II Get current time
var h = d.getHours(); II Extract hours: 0 to 23
var m = d.getMinutes(); II Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; Ills it am or pm?
if (h > 12)
h-=12; Ilconvert 24-hour format to 12-hour
if ( h == 0)
h 12; II convert 0 o'clock to midnight
if (m < 10)
m = "0" + m; Ilconvert 0 minutes to 00 minutes, etc.
var t = h + I:' + m + ' , + ampm; II Put it all together
defaultStatus = t;
IIDisplay it in the status line.
IIArrange to do it all again in 1 minute.
setTimeout("display_time_in_status_lineO", 60000); 1160000 ms is 1 min.
}
II A variable we use to ensure that each error window we create is unique.
var error_count = 0;
II Email address to send the report to.
var email = "rawilson@bsuvc.bsu.edu";
II
Define the error handler.
It generates an HTML form so the user
II can report the error to the author.
function report_error(msg, url, line)
{
var w = wi ndow. open('''' , "error"+error_count++, "resi zabl e, status ,wi dth=625, hei ght=400") ;
II arguements ... url (none specified), Name (force it to be unique), Features
var d = w.document; II We use this variable to save typing.
II Output an HTML document, including a form, into the new window.
d.write('<DIvalign=center>');
d.write('<FoNT SIZE=? FAcE="helvetica"><B>');
d.write('oopS .... A JavaScript Error Has occurred!');
d.write('</B></FoNT><BR><HR SIZE=4 WIDTH="80%">');
d.writeC'<FORM ACTION="mailto:' + email + ,II METHOD=post');
d.write(' ENCTYPE="text/plain">');
d.write('<FoNT SIZE=3>');
d.write(,<I>cLick the "Report Error" button to send a bug report.<I><BR>');
d.writeC'<INPuT TYPE="submit" VALuE="Report Error">   I);
d.write('<INPuT TYPE="button" VALUE="Dismiss" onclick="self.closeO">');
d.write('<IDlv><DIvalign=right>');
d.wr;te('<BR>YOUr name <I>(opt;onal)</I>: I);
d.write('<INPuT SIZE=42 NAME="name" VALUE="">');
d.write('<BR>Error Message: I);
d.write('<INPUT SIZE=42 NAME="message" VALUE='" + msg + '''>');
d.write('<BR>Document: <INPUT SIZE=42 NAME="url" VALUE='" + url + '''>');
d. wri te (' <BR>L i ne Number: <INPUT SIZE=42 NAME="l i ne" VALUE='" + 1i ne +' ">') ;
d.write('<BR>Browser version: I);
d.write('<INPuT SIZE=42 NAME="version" VALUE="'+navigator.userAgent + '''>');
d.write('<IDIV></FONT>');
d.write('</FoRM>');
II Remember to close the document when we're done.
d.closeO;
II
Return true from this error handler, so that Javascript does not
II display it own error dialog.
}
II
II
return true;
Before the event handler can take effect, we have to register it
for a particular window.
self.onerror = report_error;
1
c:\Download\thesis\bottomiwhile.html
var bcolor;
var allcookies = document. cookie;
var pos = allcookies.indexof("color=");
if (pos != -1)
{
var start = pos + 6;
var end = allcookies.indexof(";" , start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
}
else
bcolor = "white";
function setbgcolor(bcolor)
{
document.bgcolor = bcolor;
}
</SCRIPT>
</head>
<body text="#OoOF58" link="#760B10" alink="#544C51"
onLoad="display_time_in_status_lineO; setbgcolor(bcolor);">
<form name="box">
<textarea name="screen" value="" rows=10 cols=70 wrap=on></textarea>
</form>
</body>
</html>
2
Do ... While Loop example
wysiwyg:1Ifill. 98/http://www.cs. bsu.edu/-rawIthesis/dowhileloop.html
Here is an example of a simple do ...while loop. This do ...while loop will count from 0 to 10 by adding 1
to the previous count each time through the loop. Keep in mind that do ... while loops perform the loop
body before checking the loop test case. The count begins at 0 and holds the value of 10 after the loop
runs 10 times. The current value of the count is printed from inside the loop just after the count is
updated for that run through the loop. Please note: code appears in red text, comments in the code appear
in green text, and screen output appears in blue text.
int count=O;
do
//Initialize the count to zero
//start the loop
{
count++;
//Increment the count variable.
cout « "The current value of the count is: " « count « endl;
while(count < 10 )i
//Perform the test.
cout « "After the loop is over, the final count is: " « count « endli
The output that will be shown to the screen when the above code segment is run will be the following:
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
After the loop is
of the count is: 1
of the count is: 2
of the count is: 3
of the count is: 4
of the count is: 5
of the count is: 6
of the count is: 7
of the count is: 8
of the count is: 9
of the count is: 10
over, the final count is: 10
For a second example, check out the interactive do ... while loop example.
.C1i1.,._..,:[ul··__. . .
··[·Jtl.__.......___
••,••.•_
~_._.,'4;11I.1_
Author 1Last Update: Monday, November 08,199921:20:431 Technical comments to the Webmaster
Ball State University practices equal opportunity in education and employment and is strongly and actively committed to diversity within its community.
Links contained in this file to information provided by organizations other than Ball State University's Computer Science Department are presented as a
service and neither constitute nor imply endorsement or warranty.
1 of 1
3/25/00 6:54 PM
C:\My Documents\ .. \Honors Related\Honors 499\thesis\dowhileloop.html
<html>
<head>
<!-- Author: Ryan wilson -->
<Title>Do ... while LOOP example</title>
<!-- Begin common area -->
<script>
II This function displays the time in the status line.
II Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new Date(); II Get current time
var h = d.getHours(); II Extract hours: 0 to 23
var m = d.getMinutes(); II Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; IllS it am or pm?
if (h > 12)
h-=12; Ilconvert 24-hour format to 12-hour
if ( h == 0)
h 12; II convert 0 o'clock to midnight
if (m < 10)
m = "0" + m; Ilconvert 0 minutes to 00 minutes, etc.
var t = h + ':' + m + ' , + ampm; II Put it all together
defaultStatus = t;
IIDisplay it in the status line.
IIArrange to do it all again in 1 minute.
setTimeout("display_time_in_status_lineO", 60000); 1160000 ms is 1 min.
}
II A variable we use to ensure that each error window we create is unique.
var error_count = 0;
II Email address to send the report to.
var email = "rawilson@bsuvc.bsu.edu";
II
Define the error handler.
It generates an HTML form so the user
II can report the error to the author.
function report_error(msg, url, line)
{
var w = window.open('''',''error''+error_count++,''resizable,status,width=625,height=400");
II arguements ... url (none specified), Name (force it to be unique), Features
var d = w.document; II we use this variable to save typing.
II output an HTML document, including a form, into the new window.
d.write('<DIvalign=center>');
d.write('<FONT SIZE=7 FACE="helvetica"><B>');
d.write('OOPS .... A JavaScript Error Has Occurred! ');
d.write('</B></FoNT><BR><HR SIZE=4 WIDTH="80%">');
d. wri te(, <FORM ACTION="mai 1 to:' + email + ,,, METHOD=post');
d.write(' ENCTYPE="text/plain">');
d.write('<FONT SIZE=3>');
d.write(,<I>CLick the "Report Error" button to send a bug report.<I><BR>');
d.write('<INPUT TYPE="submit" VALUE="Report Error">   ');
d .write(' <INPUT TYPE="button" VALUE="Di smi ss" oncl i ck="self. closeO ">');
d.write('<IDIV><DIvalign=right>');
d.write('<BR>YOUr name <I>(optional)</I>: ');
d.write('<INPUT SIZE=42 NAME="name" VALUE=''''>');
d.write('<BR>Error Message: ');
d.write('<INPUT SIZE=42 NAME="message" VALUE='" + msg + '''>');
d.write('<BR>oocument: <INPUT SIZE=42 NAME="url" VALUE='" + url + '''>');
d. wri te(, <BR>L i ne Number: <INPUT SIZE=42 NAME="l i ne" VALUE='" + 1i ne +' ">');
d.write('<BR>Browser version: I);
d. wri te(, <INPUT SIZE=42 NAME="versi on" VALUE='" +navi gator. userAgent + '''>');
d.write('<IDIV></FONT>');
d.write('</FORM>');
II Remember to close the document when we're done.
d.closeO;
II
Return true from this error handler, so that JavaScript does not
II display it own error dialog.
}
II
return true;
Before the event handler can take effect, we have to register it
1
c:\Download\thesis\dowhileloop.html
// for a particular window.
self.onerror = report_error;
var bcolor;
var allcookies = document. cookie;
var pos = allcookies.indexof("color=");
if (pos 1= -1)
{
}
else
var start = pos + 6;
var end = allcookies.indexof(";", start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
bcolor = "white";
function setbgcolor(bcolor)
{
document.bgcolor = bcolor;
}
</SCRIPT>
<1-- End common area -->
</head>
<body text="#ODOF58" link="#760B10" alink="#544C51"
onLoad="display_time_in_status_lineO; setbgcolor(bcolor);">
<p>Here is an example of a simple <b>do ... while</b> loop. This <b>do ... while
</b> loop will count from 0 to 10 by adding 1 to the previous count each time
through the loop. Keep in mind that do ... while loops perform the loop body
before checking the loop test case.
The count begins at 0 and holds the value of 10 after the loop runs
10 times. The current value of the count is printed from inside the loop just
after the count is updated for that run through the loop. please note: code
appears in <font color="red">red text</font>, comments in the code appear in
<font color="green">green text</font>, and screen output appears in
<font color="blue">blue text.</font>
</p>
<font color="red">
<pre>
;nt count=O;
do
<font color="green">//Initialize the count to zero</font>
<font color="green">//start the loop</font>
{
count++;
<font color="green">//Increment the count variable.</font>
cout « "The current value of the count ;5: " « count « endl;
} while(count < 10 );
<font color="green">//perform the test.</font>
cout « "After the loop ;5 over, the final count is: " « count « endl;
</pre>
</font>
<p>
The output that will be shown to the screen when the above code segment is
run will be the following:
</p>
<font color="blue">
<~re>
T e current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
The current value
After the loop ;5
</pre>
</font>
<p>
of the count is: 1
of the count is: 2
of the count is: 3
of the count is: 4
of the count is: 5
of the count is: 6
of the count ; 5: 7
of the count is: 8
of the count ; 5: 9
of the count is: 10
over, the final count ;5: 10
2
C:\Download\thesis\dowhileloop.html
For a second example, check out the <a href="idowhileloop.html" target="fill">
interactive do ... while loop</a> example.
</p>
<!-- Footer -->
<hr>
<br>
<p align="center">
<a href=''http://www.bsu.edu/home.html'' taraet="_top">
<img src="gifs/home.gif" border="O" WIDTH=i172 " HEIGHT="14">
<fa>
<a href="mailto:ASKBSu@bsu.edu" target="_top">
<img src="gifs/ask.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/cgi-bin/guest'' taraet="_top">
<img src="gifs/guest.gif" border="O" WIDTH="72 i1 HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/uP/about/bsu.html'' target="_t0p'''>
<img src="gifs/about.gif" border="O" WIDTH="72" HEIGHT="14'>
<fa>
<a href=''http://www.bsu.edu/uP/map'/indiana.html'' target="_top">
<img src="gifs/map.gif" border="O' WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/htmls/search.html'' target="_top">
<img src="gifs/search.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/home_help.html'' target="_top">
<img src="gifs/help.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<br>
<font size="-l">
<a href="mailto:rawilson@bsuvc.bsu.edu">Author</a> I
Last update: <SCRIPT>document.write(document.lastModified);</SCRIPT> I
<a href="mailto:rawilson@bsuvc.bsu.edu">Technical comments to the webmaster</a>
</font>
<br>
<font size="-4">
Ball state university practices equal opportunity in education and employment
and is strongly and actively committed to diversity within its community.
</font>
</p>
<p align="center">
<em>
<font size="-4">
Links contained in this file to information provided
by organizations other than Ball State university's computer science
Department are presented as a service and neither constitute nor imply
endorsement or warranty.
</font>
</em>
</p>
</body>
</html>
3
Interactive Do ... While Loop example
wysiwyg://top.fill.98lhttp://www.cs.bsu.edul-raw/thesis/topidowhile.html
This interactive example of a do...while loop will help you to gain a better understanding of what
happens behind the code when a do ...while loop is executing. Please enter your own values in the drop
down boxes you find in the code below. After entering values into all the boxes, please click on 'RUN'
button below. Please note: code appears in red text, comments in the code appear in green text, and
screen output appears in blue text in the bottom window segment. Also, if you encounter an infinite
loop, the final value for count will be incorrect!
int count=_:_O__~~_
do
IIInitialize the count variable
{
count ++ ~;
IIIncrement or decrement count.
cout « "The current value of the count is: " « count «
endl;
while (count __<__~rJ_T~·_O__~~~T_)
cout «
//Set the loop to continue as long
lias the condition evaluates as true.
"After the loop is over, the final count is: " « count «
endl;
M:CI't' •._ .......-_ ..,11.'. *4:1." • • _-.yt..r-1iI1...·_._ .''4;'.:1.''•• ··_
Author 1Last Update: Friday, March 17,200001:03:421 Technical comments to the Webmaster
Ball State University practices equal opportunity in education and employment and is strongly and actively committed to diversity within its community.
Links contained in this file to information provided by organizations other than Ball State University's Computer Science Department are presented as a
service and neither constitute nor imply endorsement or warranty.
loft
3/25/00 6:56 PM
http://www.cs.bsu.edul-raw/thesislbottomidowhile.html
1 of 1
3/25/00 6:57 PM
C:\Download\thesis\idowhileloop.html
<HTML>
<HEAD>
<!-- Author: Ryan wilson -->
</HEAD>
<FRAMESET rows="55%,45%">
<FRAME NAME="top" SRC="t0p'idowhile.html" noresize>
<FRAME NAME="bottom" sRc='bottomidowhile.html" scrolling=no noresize>
</FRAMESET>
</HTML>
1
C:\My Documents\ .. \Honors Related\Honors 499\thesis\topidowhile.html
<html>
<head>
<!-- Author: Ryan Wilson -->
<Title>Interactive Do ... while LOOP example</title>
<!-- Begin common area -->
<script>
II This function displays the time in the status line.
II Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new Date(); II Get current time
var h = d.getHours(); II Extract hours: 0 to 23
var m = d.getMinutes(); II Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; Ills it am or pm?
if (h > 12)
h-=12; Ilconvert 24-hour format to 12-hour
if ( h == 0)
h 12; II convert 0 o'clock to midnight
if (m < 10)
m = "0" + m; Ilconvert 0 minutes to 00 minutes, etc.
var t = h + I:' + m + ' , + ampm; II Put it all together
defaultstatus = t;
IIDisplay it in the status line.
liAr range to do it all again in 1 minute.
setTimeout("display_time_in_status_lineO", 60000); 1160000 ms is 1 min.
}
II A variable we use to ensure that each error window we create is unique.
var error_count = 0;
II Email address to send the report to.
var email = "rawilson@bsuvc.bsu.edu";
II Define the error handler.
It generates an HTML form so the user
can report the error to the author.
function report_error(msg, url, line)
II
{
var w = window.open("","error"+error_count++,"resizable,status,width=625,height=400");
arguements ... url (none specified), Name (force it to be unique), Features
var d = w.document; II We use this variable to save typing.
II
II Output an HTML document, including a form, into the new window.
d.write('<Dlvalign=center>');
d.write('<FONT SIZE=? FAcE="helvetica"><B>');
d.write('oops .... A Javascript Error Has occurred! I);
d. wri te(, </B></FONT><BR><HR SIZE=4 WIDTH="80%">');
d.write('<FORM ACTION="mailto:' + email + "' METHOD=post');
d.write(' ENCTYPE="text/plain">');
d.write('<FoNT SIZE=3>');
d.write(,<I>CLick the "Report Error" button to send a bug report.<I><BR>');
d.write('<INPuT TYPE="submit" VALuE="Report Error">   ');
d.write('<INPuT TYPE="button" VALUE="Dismiss" onclick="self.closeO">');
d.write('</Dlv><Dlvalign=right>');
d.write('<BR>YOUr name <I>(optional)</I>: I);
d.write('<INPUT SIZE=42 NAME="name" VALUE="">');
d.write('<BR>Error Message: I);
d. wri te(, <INPUT SIZE=42 NAME="message" VALUE='" + msg + '''>');
d.write('<BR>Document: <INPUT SIZE=42 NAME="url" VALUE='" + url + '''>');
d. wri te(, <BR>L i ne Number: <INPUT SIZE=42 NAME="l i ne" VALUE='" + 1 i ne +' ">') ;
d.write('<BR>Browser version: I);
d.write('<INPuT SIZE=42 NAME="version" VALuE="'+navigator.userAgent + '">');
d.write('</Dlv></FoNT>');
d.write('</FoRM>');
II Remember to close the document when we're done.
d.closeO;
II Return true from this error handler, so that Javascript does not
II
}
II
display it own error dialog.
return true;
Before the event handler can take effect, we have to register it
1
c:\oownload\thesis\topidowhile.html
// for a particular window.
self.onerror = report_error;
var bcolor;
var allcookies = document. cookie;
var pos = allcookies.indexof("color=");
if (pos != -1)
{
var start = pos + 6;
var end = allcookies.indexof(";", start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
}
else
bcolor = "white";
function setbgcolor(bcolor)
{
document.bgcolor = bcolor;
}
// End common area
</SCRIPT>
</head>
<body text="#OoOFS8" link="#760B10" alink="#S44cS1"
onLoad="display_time_in_status_lineO; setbgcolor(bcolor);">
<p>This interactive example of a <b>do ... while</b> loop will help you to gain a
better understanding of what happens behind the code when a <b>do ... while</b> loop
is executing. please enter your own values in the drop down boxes you find
in the code below. After entering values into all the boxes, please click on
'RUN' button below.
please note: code
appears in <font color="red">red text</font>, comments in the code appear in
<font color="green">green text</font>, and screen output appears in
<font color="blue">blue text</font> in the bottom window se~ment. Also, if
you encounter an infinite loop, the final value for count wlll be incorrect!
</p>
<form name="dowhileloop">
<font color="red">
<pre>
int count=<select name="initcnt" id="initcnt" size="l">
<option value="-S">-S</option>
<option value="-4">-4</option>
<option value="-3">-3</option>
<option value="-2">-2</option>
<option value="-l">-l</option>
<option selected value="O">O</option>
<option value="l">l</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="S">S</0p,tion>
</select>
<font color='green">//Initialize the count variable</font>
do
{
}
count<select name="incdec" id="incdec" size="l">
<option selected value="++">++</option>
<option value="--">--</option>
</select>;
<font color="green">//Increment or decrement count.</font>
cout « "The current value of the count is: " « count « endl;
while(count <select name="op1" id="op1" size="l">
<option value=">">></0p,tion>
<option selected value="< '>&It;</option>
<option value=">=">>=</option>
<option value="<"><=</option>
<option value="!=">!=</option>
</select><select name="endval" id="endval" size="l">
<option value="-S">-S</option>
<option value="-4">-4</option>
<option value="-3">-3</option>
2
c:\Download\thesis\topidowhile.html
<option value="-2">-2</option>
<option value="-l">-l</option>
<option selected value="O">O</option>
<option value="l">l</option>
<option value="2">2</option>
<opt1on value="3">3</option>
<optlon value="4">4</option>
<option value="5">5</option>
</select» <font color="green">//set the loop to continue as long</font>
<font color="green">//as the condition evaluates as true.</font>
cout « "After the loop is over, the final count is: " « count « endl;
</pre>
</font>
<center><input type="button" value="Run" name="run" onclick="runloopO;"></center>
</form>
<SCRIPT>
function runloop()
{
var
var
var
var
for
{
initcnt = 0;
decincnt = 0;
op =0;
endvalue = 0;
(var i = 0; i < document.dowhileloop.initcnt.length; i++)
if (document.dowhileloop.initcnt[i].selected)
initcnt = document.dowhileloop.initcnt[i].value;
}
for (i=O; i < document.dowhileloop.opl.length; i++)
{
if (document.dowhileloop.opl[i].selected)
op = document.dowhileloop.opl[i].value;
}
for (i=O; i < document.dowhileloop.endval.length; i++)
{
if (document.dowhileloop.endval[i].selected)
endval = document.dowhileloop.endval[i].value;
}
for (i=O; i < document.dowhileloop.incdec.length; i++)
{
if (document.dowhileloop.incdec[i].selected)
decincnt = document.dowhileloop.incdec[i].value;
}
parent.frames[l].document.box.screen.value=";
switch(op)
{
case '!=':
do
{
if (decincnt == '++')
initcnt++;
else
initcnt--;
parent.frames[l].document.box.screen.value+=
'The current value of count is: ' + initcnt + '\n';
if (initcnt > 5 I I initcnt < -5)
{
}
parent.frames[l].document.box.screen.value+=
'YOU created an infinite loop! It has been stopped.\n';
initcnt = endval;
} while (initcnt != endval);
break;
case '<=':
do
{
if (decincnt == '++')
initcnt++;
else
initcnt--;
parent.frames[l].document.box.screen.value+=
'The current value of count is: ' + initcnt + '\n';
if (initcnt > 5 I I initcnt < -5)
3
C:\Download\thesis\topidowhile.html
{
}
parent.frames[1].document.box.screen.value+=
'YOU created an infinite loop! It has been stopped.\n';
initcnt = endval + 1;
} while (initcnt <= endval);
break;
case '>=':
do
{
if (decincnt == '++')
initcnt++;
else
initcnt--;
parent.frames[1].document.box.screen.value+=
'The current value of count is: ' + initcnt + '\n';
if (initcnt > 5 I I initcnt < -5)
{
parent.frames[1].document.box.screen.value+=
'You created an infinite loop! It has been stopped.\n';
initcnt = endval - 1;
}
} while (initcnt >= endval);
break;
case '>':
do
{
if (decincnt == '++')
initcnt++;
else
initcnt--;
parent.frames[1].document.box.screen.value+=
'The current value of count is: ' + initcnt + '\n';
if (initcnt > 5 I I initcnt < -5)
{
}
parent.frames[1].document.box.screen.value+=
'YOU created an infinite loop! It has been stopped.\n';
initcnt = endval;
} while (initcnt > endval);
break;
case '<':
do
{
if (decincnt == '++')
initcnt++;
else
initcnt--;
parent.frames[1].document.box.screen.value+=
'The current value of count is: ' + initcnt + '\n';
if (initcnt > 5 I I initcnt < -5)
{
parent.frames[1].document.box.screen.value+=
'YOU created an infinite loop! It has been stopped.\n';
initcnt = endval;
}
}
}
} while (initcnt < endval);
break;
parent.frames[1].document.box.screen.value+=
'After the loop is over, the final count is: ' + initcnt;
</SCRIPT>
<!-- Footer -->
<hr>
<br>
<p align="center">
<a href=''http://VMW.bsu.edu/home.html'' taraet="_top">
<img src="gifs/home.gif" border="O" WIDTH=ff72 " HEIGHT="14">
<fa>
<a href="mailto:ASKBSu@bsu.edu" target="_top">
<img src="gifs/ask.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
4
c:\Download\thesis\topidowhile.html
<a href=''http://www.bsu.edu/cgi-bin/guest'' taraet="_top">
<img src="gifs/guest.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/uP/about/bsu.html'' target="_t0r.">
<img src="gifs/about.gif" border="O" WIDTH="72" HEIGHT="14'>
<fa>
<a href=''http://www.bsu.edu/uP/mar./indiana.html'' target="_top">
<img src="gifs/map.gif" border="O' WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/htmls/search.html'' target="_top">
<img src="gifs/search.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<a href=''http://www.bsu.edu/home_help.html'' target="_top">
<img src="gifs/help.gif" border="O" WIDTH="72" HEIGHT="14">
<fa>
<br>
<font size="-l">
<a href="mailto:rawilson@bsuvc.bsu.edu">Author</a> I
Last update: <SCRIPT>document.write(document.lastModified);</SCRIPT> I
<a href="mailto:rawilson@bsuvc.bsu.edu">Technical comments to the webmaster</a>
</font>
<br>
<font size="-4">
Ball State university practices equal opportunity in education and employment
and is strongly and actively committed to diversity within its community.
</font>
</p>
<p align="center">
<em>
<font size="-4">
Links contained in this file to information provided
by organizations other than Ball State university'S computer Science
Department are presented as a service and neither constitute nor imply
endorsement or warranty.
</font>
</em>
</p>
</body>
</html>
5
C:\My Documents\ .. \Honors 499\thesis\bottomidowhile.html
<html>
<head>
<!-- Author: Ryan wilson -->
<script>
II This function displays the time in the status line.
II Invoke it once to activate the clock; it will call itself from then on.
function display_time_in_status_line()
{
var d = new Date(); II Get current time
var h = d.getHours(); II Extract hours: 0 to 23
var m = d.getMinutes(); II Extract minutes: 0 to 59
var ampm = ( h >= 12)?"PM":"AM"; Ills it am or pm?
if (h > 12)
h-=12; Ilconvert 24-hour format to 12-hour
if ( h == 0)
h 12; II convert 0 o'clock to midnight
if (m < 10)
m = "0" + m; Ilconvert 0 minutes to 00 minutes, etc.
var t = h + ':' + m + ' , + ampm; II Put it all together
defaultstatus = t;
IIDisplay it in the status line.
IIArrange to do it all again in 1 minute.
setT;meout("d;splay_time_in_status_lineO", 60000); 1160000 ms is 1 min.
}
II A variable we use to ensure that each error window we create is unique.
var error_count = 0;
II Email address to send the report to.
var email = "rawilson@bsuvc.bsu.edu";
II
Define the error handler.
It generates an HTML form so the user
II can report the error to the author.
function report_error(msg, url, line)
{
var w = window.open("","error"+error_count++,"res;zable,status,width=625,height=400");
II arguements ... url (none specified), Name (force it to be unique), Features
var d = w.document; II We use this variable to save typing.
II output an HTML document, including a form, into the new window.
d.write('<Dlvalign=center>');
d. wri te(, <FONT SIZE=7 FACE="helveti ca"><B>') ;
d.write('oops .... A Javascript Error Has occurred!');
d. wri te(, </B></FONT><BR><HR SIZE=4 WIDTH="80%">');
d.write('<FORM ACTION="mailto:' + email + '" METHOD=post');
d.write(' ENCTYPE="text/plain">');
d.write('<FONT SIZE=3>');
d.write(,<I>cLick the "Report Error" button to send a bug report.<I><BR>');
d.write('<INPuT TYPE="submit" VALuE="Report Error">   ');
d.write('<INPuT TYPE="button" VALUE="Dismiss" onclick="self.closeO">');
d.write('</Dlv><Dlvalign=right>');
d.write('<BR>YOUr name <I>(optional)</I>: ');
d.write('<INPuT SIZE=42 NAME="name" VALUE="">');
d.write('<BR>Error Message: ');
d.write('<INPUT SIZE=42 NAME="message" VALUE='" + msg + '''>');
d.write('<BR>Document: <INPUT SIZE=42 NAME="url" VALUE='" + url + "'>');
d. wri te(, <BR>L i ne Number: <INPUT SIZE=42 NAME="l i ne" VALUE='" + 1 i ne + '''>');
d.write('<BR>Browser version: ');
d.write('<INPUT SIZE=42 NAME="version" VALuE="'+navigator.userAgent + '''>');
d.write('</DIV></FONT>');
d.write('</FoRM>');
II Remember to close the document when we're done.
d.closeO;
II
Return true from this error handler, so that Javascript does not
II display it own error dialog.
}
II
II
return true;
Before the event handler can take effect, we have to register it
for a particular window.
self.onerror = report_error;
1
c:\Download\thesis\bottomidowhile.html
var bcolor;
var allcookies = document. cookie;
var pos = allcookies.indexof("color=");
if (pos ! = -1)
{
var start = pos + 6;
var end = allcookies.indexof(";", start);
if (end == -1)
end = allcookies.length;
var bcolor = allcookies.substring(start, end);
}
else
bcolor = "white";
function setbgcolor(bcolor)
{
document.bgcolor = bcolor;
}
</SCRIPT>
</head>
<body text="#ODOF58" link="#760s10" alink="#544C51"
onLoad="display_time_in_status_lineO; setbgcolor(bcolor);">
<form name="box">
<textarea name="screen" value="" rows=10 cols=70 wrap=on></textarea>
</form>
</body>
</html>
2
Section III - Dr. McVey's Code
1
C:\My Documents\Class work\ .. \Honors 499\thesis\code\args.cc
II Author: Dr. Mcvey
II used with permission.
1* This program uses command line arguments as below
prog.exe filel file2
The names and ages are read from filel, ages updated, and
then ages and names are written to file2.
*1
#include <iostream.h>
#include <fstream.h>
#include <string>
int main(int argc, 'char * argv[])
{
if (argc != 3)
{
cout « " INCORRECT NUMBER OF ARGUMENTS ON COMMAND LINE" «
return 0;
}
II either method of opening files works with argv as well
ifstream fin(argv[l]);
if (!fin.is_open())
{
cout « " unable to open file" «
return 0;
argv[l] «
endl;
}
of stream fout;
string name;
int age;
fout.open(argv[2]);
if (!fout.is_open())
{
cout « " unable to open file" «
return 0;
}
while(fin »
{
}
fi n. closeO;
fout.closeO;
return 0;
}
argv[2] « endl;
name)
fin » age;
age++;
fout « age « "
endl;
"«
name « endl;
Download