Lecture 11. MAE 5, Tuesday

From the course outline we see the reading assignment this week is Chapter 7 on Writing Programs Using Procedures. You need to turn in modified versions of all the example programs in this chapter, and do Practice Programs 7.1 , 7.2 , 7.3, and 7.4. This is the first chapter in Part 2 Advanced Programming Techniques, and introduces the use of external functions and subroutines as well as libraries and modules. These are all methods to break a complex computer program into smaller, more easily understood pieces.

Some of the methods presented include:

All of these concepts are illustrated by the Example Programs which you will modify in your homework.

Practice Program 7.3 requires that you write an external function program Pred$ to return the predecessor in the ASCII table of a character parameter. Test the function for the strings "C", "A", "@", and "qed".

As part of the preliminary testing of the parts of the program, it was useful to write an auxilliary Practice Program 7.3.1. In this program, the "ord(A$)" function is tested.

See the Random Clown Face program . Random Clown for TB Bronze uses slightly different library commands.

See the BoxKeepMouseDraw program for saving your hand drawings in two colors using the mouse.

See the FlashCard program for Chapter 7 self-test questions.

Quiz 6a solution

Self Test Question Answers Chapter 6. Chapter 7. Study these in preparation for Quiz 8 (today, see version given previously)

 

Lecture 12. MAE 5, Thursday

Practice Program 7.6 uses an external function to cube a numerical parameter.

Practice Program 7.8.1 to fill the screen with dots (not using a subroutine).

Practice Program 7.8 to fill the screen with dots using a subroutine to draw the lines.

Practice Program 7.12 uses an external function to compare strings for equality.

Use the Modified Example Programs to practice your True Basic programming skills. Show that you understand the purpose of the example program in your modification, both by comment statements and by your changes. Try to make it easy for the user (your TA) to see what you have done rapidly. Thus, it is a good idea to have your data entered automatically in a do loop reading from a data statement rather than from an input prompt statement. You can show you know both methods by commenting out the other method, and noting that you are doing so. You can put in sound and color at critical points of calculations to assist in your demonstration and debugging. MEX7.3 to calculate a factorial function demonstrates some of these points. A factorial such as 4! means 1x2x3x4. This is calculated in an external function with name "Factorial". There is no meaning to a calculation of a negative number or a non-integer number, so the program traps these errors and gives the user another chance to enter a valid number. In your modified programs, assume the TA will simply run the program first before looking at it to see what it does, and then if the output is interesting he/she will look more carefully to see how you did it.

The same strategy applies to your projects. You should pick projects that interest you, and will be recognized as useful by the user (TA!). An obvious first project that will please everyone is a FlashCard program for True Basic. You could write a program that displays Self Test Questions of your own composition, and then provides correct answers, and perhaps a grade that accumulates as the user works through the questions.

Self Test Question Answers Chapter 6. Chapter 7. Study these in preparation for Quiz 9 (today, see version given previously)

Help