← Advanced Macintosh BASIC Programming

Advanced Macintosh BASIC Programming

From the originals

13 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

PDF page 12

0 N -E This program asks for the numbers 1 and 2 to be entered. This is done twice; the first time pressing the Return or Enter key generates a linefeed so that the next printed text appears on the line beneath the input. The second time the inputs are requested, pressing Return or Enter doesn't generate a linefeed due to the addition of a semicolon after the keyword INPUT. The cursor does not move down to the next line. After clearing the display (CLS), the second line displays prompts before trying to get keyboard input. After values for the variables A and B have been entered, a message (Thank you, let's do it again) appears. Finally, the fourth line requests that the values for A and B be entered again. The third form of INPUT differs from the first by the ad- dition of a prompt string which is separated from the variable list by a semicolon. This format displays the prompt just prior to the normal INPUT question mark. In effect, the prompt string takes the place of a PRINT statement prior to the IN- PUT. It would be logical to make the prompt a message which tells the user what input is required. Figure 1-2. Prompts can be included with INPUT to eliminate the need for a PRINT statement. D Program I 2 Enter 1 :? 1 Enter 2:7 2 Thank you, let's do it again . Enter 1 :? 1 Enter 2:7 2 Thank you. The fourth type of INPUT has a semicolon before the prompt string. This has the same effect as the semicolon before the variable list in the second form of INPUT. Try Pro- gram 1-2, and enter a 1 or 2 according to the prompt. Com- pare the resulting display with that of Program 1-1. Program 1-2. INPUT Semicolon Prompt CLS INPUT "Enter 1 :";A:INPUT .. Enter 2:";B PRINT .. Thank you, Jet's do it again." INPUT ;"Enter 1 :";A:INPUT ;" Enter 2:";B PR I NT • Thank you." 5

Reading notes: OCR garbling in program listing lines (e.g., 'Enter 2:7', 'Jet's do it') may not reflect exact characters Figure and program labels show spacing artifacts from extraction

Languages
English