Sharp OZ-707 Operation Manual - Page 34
Storing Programs in Memory, Data Files
UPC - 074000012141
View all Sharp OZ-707 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 34 highlights
Several new features are contained in this program. The WAIT command in 100 controls the time that displays are held before the program continues. The numbers and their factorials are displayed as they are computed. The time they appear on the display is set by the WAIT statement to approximately 2 seconds. Notice that there are two statements in line 100 separated by a colon (:). You may put as many statements as you wish on one line (separating each by a colon) up to a maximum of 254 characters including the IENTER I key. Multiple-statement lines can make a program hard to read and modify, so it is good programming practice to use them only where the statements are very simple or there is some special reason to want the statements on one line. In this program we have used the FOR command in line 120 and the NEXT command in line 150 to create a loop. In Example 3 you created an "infinite" loop that kept repeating the statements inside the loop until 0 0 you pressed the key. With this FOR. .. NEXT loop, the computer adds 1 to N each time execution reaches the NEXT command. It then tests to see if N is larger that the limit L. If N is less than or equal to L, execution returns to the top of the loop and the statements are executed again. If N is greater than L, execution continues to line 160 and the program stops. You may use any fixed numeric variable or single-precision simple numeric variable in a FOR. ..NEXT loop, you do not have to start counting at 1 and you can increment any amount at each step. See the BASIC COMMAND DICTIONARY for details. We have labeled this program with line numbers starting with 100. Labeling programs with different line numbers allows you to have several programs in memory at one time. To RUN this program instead of the one at line 10, change to the RUN mode and enter: I CeCE I RUN100 You could also give the program a name using a label and start the program with RUN *Iabel. 56 . ------- Notes on the PRINT command: If more than eight lines must be displayed, the first lines will scroll up off the dislay, and cannot be recalled. Use the PAUSE or WAIT command in the program to display data more slowly, or use the printer. (Refer to the PAUSE, WAIT or LPRINT command.) The WAIT command applies to every PRINT command. Break long PRINT commands into a number of shorter commands if the display scrolls too quickly. Example: 100 PRINT A, B, ..., P J, 100 PRINT A, B, ..., H: PRINT I, J, ..., P Since the WAIT command is not supported by many personal computers, a wait loop such as FOR J=1 TO 500:NEXT J can also be used to extend the display time. Storing Programs in Memory You will remember that settings and functions remain in the Card even ~fter it is turned .off. Programs also remain in memory after the power 0 0 IS turned off, or It undergoes an Auto OFF. Even if you use the or I C-CE I key, the programs will remain. Programs are lost from memory only when you: • Enter NEW before beginning programming in the PRO mode. • Create a new program using the SAME LINE NUMBERS as a program already in memory. Data Files Following are some programming examples which use data file storage. Creating a Sequential File Program 1 is a short program that creates a sequential file, DATA from information you input on the keyboard. ' 57