Lecture 3. AMES 5, Tues. 18 Jan. 2000
From the course outline we see the reading assignment this week is Chapter 3 on Assigning Values to Variables, and you will be working on modified versions of all the example programs in this chapter (ie.: MEX3 means MEX3-1, MEX3-2, etc.), and you must do Practice Programs 3.1,2,4,5. It is lots more fun if you work as far ahead as you can, pulling out new commands from the advanced chapters which you can use to dress up your modified programs (MEXs) and Practice Programs (PPs), and start working into your Projects. Surf the True Basic website for ideas about what you could consider for a project. Run the Demo Programs in the True Basic folder to see how more advanced coding works, and to find where you can read about it in the textbook. Make modifications to the Demo programs to see their effects on the program operation. Learn to run the Do Trace debugging programs described in Chapter 6. This is illustrated in TB Ref. Read ahead and work ahead.
Before or during your next Section Meeting, you must turn in your first homework folder (labeled A02-HW1 Doe, Sally for example) by dropping the folder (containing your CODEWORD file, MEX2-1, MEX2-2, etc., PP2.1, PP2.1) into the Drop Box folder that appears automatically in the laboratory, or which you can use by logging on as mae5 with no password in the ACSLAB ACS-LAB-SERVER MAE5 folder using AppleShare. This is a one-way operation for students, but TAs and I can open the folder to see who has turned in their homework, and so the TAs can grade it. As you saw in the last lecture, a series of mysterious statements appear when you try to submit your homework. You can't submit anything to the dropbox if you log in as a Guest. Watch for the copying bar as evidence that it made it. If you discover later that you made an error you want to correct, you can submit a revised homework folder (eg.: A02-HW1 Doe, Sally). It will not overwrite the original folder and files, even if they have the same names, so you should change the name so your TA will know to trash the original (eg.: Revision.A02-HW1 Doe, Sally [!trash original please!]). Be sure to have backup copies of your homework on your homework disk and elsewhere.
The easy way to do your homework is to first create a new homework folder on your homework disk (this week it would be labeled A02-HW2 Doe, Sally for our fictitious student Sally Doe in section A02) and copy in all the example programs from Chapter 3 from the Catlin disk. Then go through the example programs one by one, reading the material from the textbook to see what points the programs illustrate, running the programs to see how they work. Then save the program to a modified program file (MEX3-1 SD, for example) and make modifications and remarks as you change it to be sure you know what points it is supposed to illustrate. Catlin Example Program 3-5 is intended to illustrate exponentiation. After modification MEX3-5 might be very different. When you finish with the modified programs, then "unsave" the originals before you turn in your homework folder.
Projects: As mentioned previously, it is a good idea for you to read ahead and do as many homework sets in advance as possible. You should also be using the hypercard stack TB Ref regularly to get advice about good True Basic programming procedures, and to run the illustrative programs included. Just open the stack (it's on the AMES 5 laboratory machines...use the finder to find it) and follow directions. Copy it from the laboratory machines or from Prof. Herz' homepage to use on your home Mac (it won't work on IBM clones) or in the campus MacLabs. As your skills progress beyond the reading assignments you can test them by working on your two projects, which are True Basic programs of your own creation. Try to come up with programs that shows off your programming skills as you apply them to solve interesting problems you have or might encounter in your future work, or perhaps just use for fun. Game programs are allowed. Have lots of remark statements at the beginning to show the purpose and operation of your project programs. Include remarks in the body to show the TA that you know what you are doing, and to remind yourself when you read it later. When you have a project program ready to show off, let me know, and if there is time I'll run it in class.
At the end of Chapter 3 you should read the Summary of Important Points, Common Errors, Self-Test Questions, and work as many of the unassigned Practice Programs as you can. See PP3.3 for example. Be prepared for Quiz 2 by reading Chapter 3 carefully before class, testing yourself with the self test questions and answers, plus Quiz 2 from Winter 1999 given here.
Bounty on cheaters: TA Pak-Tao Leung and his Deputy Marshals are authorized to distribute a cheater's points on quizzes, HWs, and Projects to students and witnesses that convincingly identify the cheater. An email from one student and one witness describing the same cheating act by an individual is considered convincing. One strike costs you points, two strikes and you're out. Let's not play this game. Our apologies to the class for any undetected cheating.
Lecture 4. AMES 5, Thurs. , Jan. 20, 2000
Congratulations! Grades for Quiz 2 were quite good. Several students scored 100%, and the average was an impressive 89% compared to only 78% for Quiz 1 (75% before correction). In your preparation for Quiz 3, go over the self test questions for Chapter 3 carefully to be sure you understand all the answers. Quiz 3a from Winter 1999 is given here.
Input statements:
The INPUT statement can be used to read in data from the keyboard in the form:
INPUT var1, var2, ...
where the variables can be either numeric or string. For example, you could input the first names and ages of your best friends with the statement:
INPUT name1$, age1, name2$, age2, ...
as long as you remember to have just the right number of best friends and don't forget to include all ages, separated by commas. Such True Basic statements are best tested by experimenting with the statement in a program.
If you want to input a string variable value that includes a comma, you need the LINE INPUT statement:
LINE INPUT prompt "Type in your prompt here ...": StringVariableHere$
and the StringVariableHere$ that you type in after the prompt can contain whatever you like, even without quotes. If you attempt to use a numeric variable you get an error.
The DATA statement permits storage of string and numeric values in memory for use in a program. The values are stored first, and in order from top to bottom, just like a sequential file, so if you reverse the order of your data statements you affect where the values are stored. Experiment with DATA and READ statements to be sure how they work.
New concepts in Chapter 3:
Many new programming concepts and True Basic statements are introduced in Chapter 3. You can best learn these by reading the material in the text as you modify the Example Programs for your homework. These concepts include:
All of these topics are illustrated by Example Programs.
You might consider making up self-test programs as a means of study for the quizzes, or as one of your projects. Such programs can be posted by the TAs in the laboratory for review by the rest of the class. For fun, try fancy calculations such as the force of gravity on the surface of the Earth, calculate the Planck length, mass, time and temperature scales that describe conditions at the time of the Big Bang, or concoct music programs such as "Old Smokey".
Solve as many additional Practice Programs as possible, and experiment with debugging techniques. You can get started by copying (select, ^C) and pasting (^V) the solution for Practice Program 4.3 on p112 of the text. Another programming example that was shown in class is Practice Program 5.2 from p145 (this is one of your homework problems).
Advanced concepts: Try this mat plot demo program. Write a sequential text file.
Help