If more values are read than there are numbers in the DATA statements, an out of data (OD) error occurs. That is why in line 40 we check to see if -999999 was read. This is not one of the numbers to be matched, but is used as a flag to indicate that all of the data (possible correct guesses) has been read. Therefore, if -999999 was read, we know that the guess was incorrect.

Before going back to line 10 for another guess, we need to make the READ's begin with the first piece of data again. This is the function of the "RESTORE." After the RESTORE is encountered, the next piece of data read will be the first number in the first DATA statement again.

DATA

statements may be

placed anywhere within the program. Only READ statements make use

of the DATA statements

in a program, and any other time they are encountered during program

execution they will be

ignored.

212

STRINGS

 

A list of characters is referred to as a "String." Rockwell, R6500, and THIS IS A TEST are all strings. Like numeric variables, string variables can be assigned specific values. String variables are

distinguished from numeric variables by a "$" after the variable name.

For example, try the following:

A$="ROCKWELL R6500"

PRINT A$

ROCKWELL R6500

In this example, we set the string variable A$ to the string value "ROCKWELL R6500." Note that we also enclosed the character string so be assigned to A$ in quotes.

LEN FUNCTION

Now that we have set A$ to a string value, we can find out what the length of this value is (the number of characters it contains). We do this as follows:

PRINT LEN(A$),LEN("MICROCOMPUTER")

14 13

The "LEN" function returns an integer equal to the number of characters in a string.

A string expression may contain from 0 to 255 characters. A string containing 0 characters is called the "null" string. Before a string variable is set to a value in the program, it is initialized to the null

string. Printing a null string on the terminal will cause no characters to be printed, and the printer or cursor will not be advanced to the next column. Try the following:

PRINT LEN(Q$);Q$;3 0 3

Another way to create the null string is: Q$=""

Setting a string variable to the null string can be used to free up the string space used by a non-null string variable.

LEFT$ FUNCTION

It is often desirable to access parts of a string and manipulate them. Now that we have set A$ to "ROCKWELL R6500," we might want to print out only the first eight characters of A$. We would

do so like this:

PRINT LEFT$(A$,8)

ROCKWELL

"LEFT$" is a string function which returns a string composed of the leftmost N characters of its string argument. Here is another example:

FOR N=1 TO LEN(A$):PRINT LEFT$(A$,N):NEXT N

R

RO

ROC

ROCK

Page 229
Image 229
Apple II Strings, $=ROCKWELL R6500 Print A$ Rockwell R6500, LEN Function, Print LENA$,LENMICROCOMPUTER, LEFT$ Function

II specifications

The Apple II, launched in April 1977, was one of the first highly successful mass-produced microcomputer products. It marked a significant leap in personal computing, setting standards for future developments in the industry. Created by Steve Wozniak and Steve Jobs, the Apple II differentiated itself with its user-friendly design, appealing aesthetics, and robust capabilities.

One of the standout features of the Apple II was its open architecture, which allowed users to expand and enhance the computer's functionality. This design enabled hundreds of third-party hardware and software developers to contribute to its ecosystem, resulting in an array of peripherals, including printers, modems, and storage devices. The Apple II utilized a MOS Technology 6502 microprocessor running at a clock speed of 1 MHz. Initially equipped with 4 KB of RAM, the machine could be expanded to 48 KB, accommodating more complex applications and programs.

The Apple II was also notable for its colorful graphics. It was one of the first computers to support color display, offering a 6-color palette with a resolution of 280x192 pixels in 16 colors when using its Color Graphics Card. This feature significantly enhanced the visual appeal of games and educational software developed for the platform, making computing more accessible and entertaining for various audiences.

Apple's commitment to user experience was evident in the design of the machine. It featured an integrated keyboard and a plastic case, which was both durable and visually appealing. The self-contained design included drive bays for floppy disk drives, allowing for quicker data access than traditional tape drives. It also supported audio output, enabling sound effects and music, a novelty at the time.

The introduction of the Apple DOS operating system further underscored the machine's capabilities. DOS streamlined file management and made it easier for users to navigate and manage their data. The combination of hardware and software positioned the Apple II as an educational tool and a gaming platform, fostering a vibrant software ecosystem.

The Apple II family continued to evolve, with variations like the Apple II+, IIe, and IIgs being introduced over the years. These iterations brought enhancements in memory, processing power, and graphics capabilities. The legacy of the Apple II endures, not only as a foundational product in personal computing but also as a symbol of innovation that paved the way for future advancements in technology. Its impact is still felt today, as it inspired countless developers and shaped the trajectory of the computer industry.