Lecture 1. MAE 5, Tuesday, Jan. 9, 2001

Welcome to MAE 5, Quantitative Computer Skills! Please look over the Course Outline to see the course description and what we will be doing this quarter. A hard copy of this document will be distributed in class, but you should check the webpage for updates that may occur during the quarter. Please make sure you have an email account that appears in StudentLink, since class announcements will be made through email as well as through this webpage. The primary purpose of this class is to teach you to program a personal computer in the True Basic language. BASIC is the most user friendly programming language (and most widely used) available and Macintosh True BASIC is the most user friendly version of BASIC. For these reasons, and since we have Macintosh computers in the MAE (AMES) 5 computer laboratory in Engineering Building II, room 205, the type of personal computer emphasized will be Macs, but you can also use True Basic with IBM PCs, Sun computers running UNIX, Commodore Amigas, Japanese computers in Japanese, and several other machines with different operating systems. Versions of True Basic and study guides for these different operating systems are available through the True Basic company but are not supported in this course. An IBM PC version of the software is available in the laboratory for you to copy and includes some minimal instructions. The textbook Let's Program It in True Basic, by Avery Catlin (which you should get in the bookstore) assumes that you have either type of computer and serves as the manual in either case, but you are not responsible for questions about the use of PCs, only Macs. The Student Edition Manual for Apple Macintosh computers is in the laboratory along with other reference books. If you have no personal computer of your own you should probably get one, but it is not necessary since you can get into the AMES 5 computer laboratory any time to use these machines. There are nearly 200 Macintosh computers on campus that you can use to work on your homework assignments in this course, listed in the Academic Computer Services webpage. You can do your MAE 5 work in any one of these MacLabs using the AppleShare network to access ACS-CLASS-SRV in zone ACSLAB of AppleShare...pick Chooser under the apple top left of Mac menu bar, enter with mae5 as username with no password in the the MAE-MacLab. Got to Chooser under the apple on the Mac menu bar and open AppleShare to find this and other resources.

Why should you want to know how to program a personal computer? Why use the True Basic programming language? Clearly the 21st century is the beginning of the information age, and computers are the primary tool for information manipulation. Most jobs students will spend their lives doing have not yet been invented, but nearly all these jobs will involve computers. All actions of computers are controlled by computer programs, or "applications". The UCSD site license for True Basic 2.72 permits you to create applications from programs you write in this class. In the past, computers were too expensive to be owned by individuals so programs were written to be extremely efficient in their use of computer time. Now computers so cheap that most people own one or more so that user time has become more valuable than computer time for most users. Rather than communicating with computers in efficient machine languages and assembly languages that are very labor intensive to write, it makes sense to use less efficient high level languages to save user time and so that users as well as specialists can write programs. BASIC was written in the 1960s to be reasonably efficient in computer time, but very efficient in user time. FORTRAN and C/C++ programs had been developed for engineering and scientific purposes, and COBAL programs for business purposes, but these were sufficiently tedious to learn that only specialists (or students!) learned them. Have a look at the lisp manual to see whether you would like to learn computer programming starting with this language. BASIC was designed to be user friendly but with sufficient power to make the computer do any task. True BASIC was developed as a commerical product in the 1980s to fulfill a need to put both computers and computer programming within the grasp of all users. Most users of personal computers rely on commercial programs to do their work, but these applications are becoming increasingly expensive and unwieldy. True BASIC occupies only 230 kbytes on a disk, and requires only 580 kbytes of memory. Why become dependent on applications that occupy gigabytes (1,000,000 kbytes) of space and require several megabytes (1,000 kbytes) of memory to run, when the same tasks can be done with your own TB program more rapidly? Learning to program will:

An important secondary purpose of the course is indicated by the course title; that is, to help you develop your quantitative computer skills. Since you are reading this lecture, apparently you already know a very useful computer skill, which is how to use the internet. You are able to access a huge amount of information this way, including lectures about this course and the various links provided to other sources of information which I have provided in the course webpage. You might want to explore the possibility of constructing your own webpage, since this is allowed using your course computer account which gives you email capability. Simply type "help www" at the command line when you are in your course computer account and follow directions (read all the help articles that appear about the world-wide-web). It takes about ten minutes to create your own webpage once you know how to do it. Then you can learn how to put useful information about yourself in the webpage, such as a resume when you are ready to get a job. You can learn everything about constructing webpages using the internet using the Beginners Guide to HTML.

During the first meeting of the class or your first laboratory session you will be given a piece of paper with information about your UNIX and Apple course accounts (e. g.: your username such as am5wab, including the password you will need to use the account, your StudentID). The MAE 5 course accounts (UNIX) are on a Sun or Hewlett Packard computer called iacs5. You will also get a pink handout titled "Mac Labs Step 1, Guidelines for users of ACS Mac Labs". Read both of these documents carefully. You will find directions for mac-lab logon procedures to open your AppleShare course account, where you can save and access your work from any MacLab. You should also buy a few computer disks (3 or more) to use to save your homework, plus your personal copies of True Basic (paid for by the UCSD Site License) and TB Ref (freeware by Prof. Richard Herz of AMES) which can be copied in the AMES 5 laboratory or downloaded from TB Ref freeware . You get a copy of all textbook program examples along with the textbook. Back up all of your homework on your floppy disks to be on the safe side. Please do not leave your homework in the Workspace portion of the computer hard disk, since it might be a temptation to others to make copies, which is forbidden. Quizzes will be given based on the assigned readings, the lectures, and the homework assigned. A source of quiz questions will be the self test questions at the end of each chapter, so you should review these and the answers which are included in the Catlin disk . For example, the answers for Chapter 1 are here. The self-test answers for Chapter 2 are here. The first quiz will be this Thursday, January 11, as indicated in the Course Outline schedule. Check the quizzes given previously eg:(AMES 5, W 1999) to see what to expect.

The schedule of reading, project stages, and homework for the course is given in the course outline, along with the quiz schedule and grading policy. Please bring a number 2 pencil and a scantron form (the green kind, #881-ES, $0.15 in the bookstore) to all lectures. You must submit your homework by placing a folder containing your program files in the one-way drop folder MAE 5 Drop Box in the GreenServer laboratory computer (server). The folder and files must be labeled so your TA can easily find it, know it is yours and what you have done; for example, "A02-HW1, Doe, S." would be an appropriate name for the folder containing the program files for Sally Doe's homework assignment number 1, for week number 1, due in the AMES 5 Drop Box before her section begins in week 2 (no later). In the program files, programs must be clearly labeled with REM statements (or ! statements) giving the same information, plus the due date, name and purpose of the program. For example,

First file, labeled MEX2-1:

! A02-HW1-MEX2-1, Doe, S. (everything following ! is a comment, ignored by the program)

!CodeWord FAWN

! Due: Jan. 18, 2000

! MEX2-1 means "modified example program 2-1" from p22 of the text.

! Modification: Change the greeting from Hello! to goodbye.

! Following is the program.

PRINT "goodbye." (note that commands are capitalized, by convention, and strings are enclosed in quotes)

END (required in all True BASIC programs)

Second file, labeled MEX2-2:

! A02-HW1-MEX-2, Doe, S.

!CodeWord FAWN

REM MEX2-2

! Change the number to be printed.

PRINT 35.6 ! print a different number

END

etc.

Another file, labeled PP2.2 (ie, Practice Program 2.2)

! A02-HW1-PP-2, Doe, S.

!CodeWord FAWN

! Display your name, local address, and telephone number on separate lines on the screen.

PRINT "Sally Doe"

Print "5566 La Jolla Farms Rd., La Jolla CA 92093"

Print "555-8312"

END

Grading will be 20% for homework (4% each for your best 5 sets), consisting of the Modified Example Programs (MEXs) and Practice Program problems (PPs). There are 9 sets, and your 4 lowest grades will be dropped. The purpose of the MEXs is to save you time typing, give you a chance to practice modifying a working program, and make sure you understand the point the author is making in the textbook using the example. Consider that your TA only has a few minutes to spend grading your homework, so it is likely that only spot checks can be made of what you have done. Try to make the grading easy for them by making sure your programs are clearly labeled, are correct, and run smoothly. You can practice advanced techniques (colors, graphics, sounds, matrix commands, procedures, modules, libraries etc.) in your modifications. Quizzes are about all aspects of the course (including the webpage and lectures). Read the Summary of Important Points, Common Errors, Self-Test Questions, and unassigned Practice Programs at the end of each chapter very carefully, since these sections will be a source of questions for the Quizzes. Quizzes in lectures and labs count 5% each for a total of 50%. The lowest scores of 4 of the 12 lecture quizzes will be dropped, but neither of the 2 lab quizzes. Two term projects count 30% (15% each). Projects are intended to give you a chance to read ahead and apply what you learn to solving programming problems that you find particularly interesting. Use your imagination. Consider how a first time viewer or user of your program will react. Student project demonstrations are scheduled for March 8, and have been a lot of fun to see in past years. Course grades tend to be high because learning to program even at the minimal levels required in this course is tough and time consuming for nonengineering students with no previous computer programming experience. Section grades are normalized, and overall grades are ranked. The top grades go to the top ranked students.

You should get started as soon as possible in this course. READ THE BOOK! Go to the lab (the lock combination will be given out in the first class and will get you in at off hours), get familiar with the equipment and start programming. Copy the True Basic and TB Ref files to your own disks so you can use them on your home computer, or at other computers around the campus for student use (Academic Computer Services ). The Catlin disk with answers to the self-test questions BK7022T is here if you lose the disk that came with your copy of the text. Send an email to your TA to let them know how glad you are that you're in their section. Type "pine" when you get into your UNIX account and follow directions to use the PINE email program. Note that you must use the control key rather than the Apple key to send your message. Go through the first part of the TB Ref HyperCard stack as a tutorial. Learn to use the Do Trace command described in Chapter 6 so you can step through the operation of programs. Try out the demonstration True Basic programs and look up the commands in the text that you don't recognize. Learn to use the Help menu items. Make changes in the demo programs to see how they work. Do your first few homework assignments early. Read ahead. Get started on your term projects, building in every trick in the book. Feel free to discuss the material with your fellow students (but don't copy or allow copying of homework, since this doesn't teach anything). Use your head first, but don't be shy about asking questions if you get hung up. Programming is fun once you get started and have built some confidence. True BASIC is available on all UCSD Macs, so you can practice anywhere on campus. The fastest computers are in the IMac labs. Run the DEMO programs (don't try this from a floppy) and examine these for advanced programming tricks you can show off in your MEXs and Projects. Practice makes perfect!

A True BASIC program consists of statements. Each statement occupies one line and starts with a keyword. Keywords are part of the True BASIC language, and indicate the purpose of the statement. They are usually capitalized, but the programs work even if they aren't. Spaces and extra lines are ignored. Following is a simple program illustrating the keywords LET, PRINT, and END.

LET x=17

LET y=9

LET answer=2*x-3*y

PRINT answer

END

The output of the program appears on the screen when the program is run, and is 7.

The program illustrates several important aspects of True BASIC:

A powerful editor examines your programs and suggests corrections if errors are detected. For example, if t is substituted for 17 the program returns -27 (t is interpreted as another numerical variable, and all numerical variables are initially zero), but if t$ is used a "wrong type" message appears because t$ is a string variable. Experiment with such programs and learn to think like a computer. Underbars are allowed in numerical variable names like x_1. Capitals have meaning for string names, so T$ is a different memory location than t$. Numerical expressions use operators + - * / ^ and (). The order is left to right, ^ first, then * and /, and then + and -. Use () to control the order of evaluation.

A string constant is any list of characters enclosed in quotation marks. String variables end with $. Substrings are extracted from string by following the string with [a:b]. Thus "abcdefg"[3:5] = "cde". Negative a values are interpreted as 1. b less than a gives a null "" string. Substrings are inserted in strings as follows:

If b<a in an assignment statement, then the substring is inserted to the left of a.

LET x$="hose"

LET x$[3:2]="u"

LET x$[1:0]="The "

PRINT x$

END


gives The house as output. Try it!

 

Lecture 2. MAE 5, Thurs., Jan. 11, 2000: Quiz 1 today!

Next week the first Sections begin, but you can go to the MAE 5 laboratory in EBU205 anytime to get familiar with the equipment and software. This first week of sections you want to make sure you know how to use the Macs to produce True Basic programs, copy the free software to your disks (True Basic and TB Ref), produce a backup copy of Catlin's disk that came with your textbook, and prepare a homework disk containing files so you can download these to the MAE 5 Drop Box before the first homework sets are due.

Codeword file:

We need your codeword! Please provide a four letter codeword (all caps) on your Quiz 1 scantron so we can use this to identify you on grade lists.

TB Ref:

The hypercard stack TB Ref is a good place to start learning True Basic and the associated computer skills you will need to maximize your rate of progress in MAE 5. Open the stack (click on the program) and follow directions. Read from the top of the Topics list and try out each option. Open up True Basic so you can copy the programs given and try them out. Use of Do Trace (the debugging program for True Basic) is nicely demonstrated by copying and using the program included in the topic "elements of programs" (the bullet shows there is a program available to copy). It's a good idea to know how to use this early so you can follow the sophisticated Demonstration Programs included in the True Basic folder, and be thinking about your Final Project.

Projects:

The Projects are original programs constructed by you to show off all your True Basic skills accumulated during the quarter. Pick something that you are interested in doing, and that you'd like to demonstrate to others. A good Project might be a computer game, a flashcard program for True Basic commands, a graphics program...whatever. Be creative (within limits: virus programs are not permitted or given credit)!.

Homework 1:

We'll go through the first homework set in class, as time allows. Work with the Catlin book and the computer disk that comes with it. Start by making a folder (A02-HW1, Doe, S.) for your homework files, and save your MEX and PP files into this folder. When you are done, drag the folder to the (one way!) MAE 5 drop box. Type the problem or a summary into the first part of a PP problem and comment it out, so you and the TA know what you are doing.

Email:

Try out the course account you are assigned for AMES 5 on the computer iacs5 using the information about your username and password included in the account slip you get from your TA during your first Section. Your username is in the format am5wab , where am5 refers to the course, w means Winter Quarter, and ab is you. Type "pine" once you get in your account and follow directions.

As mentioned previously, you should test all of your Modified Example Programs (eg.: MEX2-2) and Practice Programs (eg.: PP2.1) using the PowerMacs in the MAE 5 laboratory before you submit your folder (eg.: A07-HW1, Roe, R.) by dragging it to the AMES 5 Drop Box folder (or the alias of the folder you'll see when you open the PowerMac hard disc, and follow the directions). There is a conversion program called "Mac _-_ PC file conversion" which you can use if you do your homework using an IBM clone PC. This program can be copied, so you can put it on your disks for use on other machines. You can use it to convert the Catlin example programs to PC format for use on IBM clone machines.

Quiz # 1 (1999)

AMES 5

Quantitative Computer Skills

Quiz 1, January 7, 1999

(closed book, closed notes)

1. True BASIC is one of the first commercial versions of the Full BASIC programming language conforming to ANS BASIC standards. BASIC is one of the most widely used programming languages, and was first developed at Dartmouth College in:

(a) 1946 (b) 1996 (c) 1974 (d) 1964 (e) 1994.

2. Computers store information in bits and bytes. A bit is either 0 or 1 (false or true, off or on). If the bit is off, it represents the number zero. If it is on, it represents the number one. Thus it stores numbers in the range zero to 2^1 - 1 = 1. A byte is 8 bits, and can store numbers in the range zero to 2^8 -1. Therefore the largest number that can be stored in a byte is zero to:

(a) 8 (b) 28 (c) 204 (d) 255 (e) 127.

3. There is a difference between a text file and a binary file:

(a) true (b) false.

4. True BASIC is case sensitive. It is important to give the command PRINT instead of the command print. The numeric variable M is different from the numeric variable m:

(a) true (b) false.

5. The output of the program PRINT hello! (with an END statement following) is:

(a) hello! (b) 0 (c) hello (d) an error message (e) disaster.

6. The output of the program PRINT "hello!" ! print a line (with an END statement following) is:

(a) hello! (b) 0 (c) hello (d) an error message (e) disaster.

7. The output of the program PRINT "hello!" REM print a line (with an END statement following) is:

(a) hello! (b) 0 (c) hello (d) an error message (e) disaster.

8. The output of the program REM print a line (next line) PRINT "hello!" (next line) END is:

(a) hello! (b) 0 (c) hello (d) an error message (e) disaster.

9. All programs must contain the following command or they won't run:

(a) hello! (b) PRINT (c) END (d) REM (e) SudentID.

10. The command INPUT name$ produces a question mark and expects you to type in a value for name$. What is name$?

(a) a numeric variable (b) a string variable (c) a numeric constant (d) a string constant (e) George.