The Beginner's PageC. RegenaThe RESTORE StatementLast month we talked about READand DATA statements. A oftenused associated statement is RESTORE, which can be used withREAD and DATA. RESTORE forcesthe computer to start READing thevery first item in the first DATAstatement in the program. You thuscan reuse DATA statements if necessary. Here is a simple example:10 READ A,B,C20 DATA 2,4,3,8,2,730 PRINT A + B+C40 READ D,E50 PRINT D'E60 ENDWhen this program is run, line10 reads data (from line 20) for thevariables A, B, and C. A will equal2, B will be 4, and C will have thevalue 3. Line 30 prints the sum.Line 40 is another READ statementwhich reads the next two data itemsfor D and E. D will have the value 8and E will be 2. Line 50 prints theproduct. (Remember that you canput the DATA statement of line 20anywhere in the program and theresults will be the same.)Now add a line:35 RESTOREThis line says to restore the data, orto start the list of data items overagain with the very next READstatement. This time the values forD and E will be 2 and 4 because thedata pointer starts with the veryfirst data item in the program.Restoring DATA LinesMany versions of BASIC evenallow you to RESTORE a certaindata line. For example, RESTORE200 means "With the very nextREAD statement encountered, startthe data with the DATA statementin line 200." This feature makesprogramming with DATA statements much easier because you canmake sure the READ statementsstart with certain DATA statements. It's particularly helpful inlong programs with many DATAstatements.The RESTORE statement neednot appear right next to the READstatement. It simply resets the datapointer.Here is a way you can makeuse of DATA, READ, and RESTORE. Write a short program toread numbers for musical note values, and then play those notes.Place this in a subroutine at line900. An example for the Atari STmight be:900 FOR C = l TO X910 READ NOTE,OCTAVE920 SOUND 1,15,NOTE,OCTAVE,10930 NEXT C940 RETURNNow in your main programyou can have DATA statementscontaining numbers for musicalphrases. The variable X in this example is the number of notes in thephrase. Using RESTORE you canplay phrases more than once without retyping DATA statements. Forexample:100 X=35110 GOSUB 900120 DATA ...(numbers for music)130 DATA ...(more note numbers)140 DATA ...(more note numbers)150X = I4160 RESTORE 130170 GOSUB 9001<strong>80</strong> X=7190 RESTORE 140200 GOSUB 900210 RESTORE220 GOSUB 900230 ENDFirst, X is set to 35, and thesubroutine will read and play 35notes from the data starting at line120. Line 160 says to start the dataover beginning with line 130. Fourteen notes will be played—a chorus,for example. Line 190 then says tostart the data over with line 140 andplay 7 notes—repeating a musicalphrase. Line 210 says to restore thedata completely, or to start with thevery first line of data. The value ofX is still 7, so 7 notes will be playedand the rest of the data will beignored.Selecting Items FromA List<strong>Computer</strong>s which use line labelspermit a RESTORE to target a particular label. For example, RESTORE UTAH tells the computerthat with the very next READ statement start the data with the linelabeled UTAH. The data might beinformation used by the program todraw the state using numbers forgraphic coordinates.RESTORE is also used if youhave lots of information and thecomputer is supposed to select particular items from a list. Supposeyou have names, addresses, phonenumbers, and codes in data statements for a list of clients. You canfirst read each item and print onlythose with a certain zip code. Next,you can RESTORE the data, thenread each item, and print only thosewith a certain phone prefix. Another time you could RESTORE thedata, then read each item, and printonly those with a certain code. Youcan let the computer do the work ofsearching through information inone data list and save your havingto write several different programs.This should get you started onunderstanding programs withDATA, READ, and RESTOREstatements. You might not evenconsider yourself a beginner anymore if you can manipulate DATAstatements, but I hope to see youagain next month. ®<strong>80</strong> COMPUTEI February 1987
RUSH POSTAGE-PAID CARDFOR YOUR FREE CATALOGCOMPUTER ELECTRONICS iraining prepares youto service all computers as you build your own 16-bitIBM PC compatible computer. Toial system praoiamincludes disk drive, lest equipment, bundled software, and NR! Discovery Lab.TV/VIDEO/AUDIO SERVICING Includes trainingwith a state-of-the-art 27" high resolution broadcastsjereo TV (or leaning troubleshooting and professional bench techniques.SATELLITE ELECTRONICS training gives youthe skills to service both consumer and commercialsatellite earth station equipment as you assembleyour own home satellite TV system.ROBOTICS training features remote-controlled,mobile, fully programmable robot you build, experiment with, and keep along witb other test equipment.NameStreet(Please Print)AgeCHECK&ONESend me your free catalogon NRI Training in:D□□<strong>Computer</strong> ElectronicsTV/Video/Audio ServicingRoboticsD Satellite ElectronicsD Digital Electronics ServicingD Data CommunicationsDElectronic DesignTechnologyG Industrial Electronicsn Communications ElectronicsD Basic ElectronicsD Building Construction andRemodeling□Automotive Servicing□ Small Engine Servicing□Electrician□ Air Conditioning, Heating,and RefrigerationD Locksmithing and ElectronicSecurity□D□nTelephone ServicingAppliance ServicingPhotographyBookkeeping and AccountingCityStateZipAccredited by the National Home Study Council 198-027For career courses approvedunder G.I. Bill f. Chock lor details.
- Page 2 and 3:
We just did something only the best
- Page 4 and 5:
icate Maker!Because accomplishments
- Page 6 and 7:
Editor'sNotesThis is the 81st issue
- Page 8 and 9:
PublisherFounder/Editor in ChlelSen
- Page 10 and 11:
Selby BatemanFeatures Editor....
- Page 12 and 13:
, ■■-■■'■ ;-.-..■■■
- Page 14 and 15:
The new Compaq Deskpro 386 is among
- Page 16 and 17:
Selby Bateman, Features Editoricrop
- Page 18 and 19:
68030 chip, which should be readyfo
- Page 20 and 21:
computer are often called proprieta
- Page 22 and 23:
Tom R. Halfhill, Staff Editorore By
- Page 24 and 25:
Selby Bateman, Features Editorasers
- Page 26 and 27:
MicroscopeSheldonLeemonThe new Appl
- Page 29 and 30:
Fly to Florida!Scenery Disk # 7 cov
- Page 31 and 32: contains twice as many vertical pix
- Page 33 and 34: And you don't even have toleave you
- Page 35 and 36: Increase your knowledge about all a
- Page 37 and 38: BEST SERVICE IN THE USA • ONEDAY
- Page 39 and 40: BATTERIES Sg? INCLUDEDTHE FOUR LETT
- Page 41 and 42: LYCOCOMPUTERMARKETING & CONSULTANTS
- Page 43 and 44: ATARIJKLYCOCOMPUTERMARKETING & CONS
- Page 45 and 46: QuickProDOSCatalog For AppleLarrySh
- Page 47 and 48: Behaved Batch FilesCOPY CON: YESNO.
- Page 49 and 50: ASC II ExpressBalance of PowerBally
- Page 51 and 52: END**Beap:*SOUND 800,1,100,0:SOUND
- Page 53 and 54: COMMODOREAPPLEC64 COMPUTER C-128COM
- Page 55 and 56: FileCompressorChrisRogersThis Commo
- Page 57 and 58: character n. Whenever File Compress
- Page 59 and 60: \Make Your ChoiceC-64 or C-128BASIC
- Page 61 and 62: RP0A71i4C0A79:1B0A81:0A0A89:1F0A91i
- Page 63 and 64: ACCOLADEHardball 24.95Mean 18 31.95
- Page 65 and 66: Ibefore a move is made. Each compar
- Page 67 and 68: PH 1390 IF P$="C" AND T0>=7 THEN .1
- Page 69 and 70: 5D 2310 DATA 30,34,34,30,2,2,2,0FE
- Page 71 and 72: I10 630 P$="C"BC 640 REM tt PICK BE
- Page 73 and 74: ,——■———U-J>G>Player■p
- Page 75 and 76: INSIGHT:AtariBillWilkinsonNumber-Ba
- Page 77 and 78: EMPX,TEMPY,MASKBH 9140 TEMPX-X1TEMP
- Page 79 and 80: AmigaViewSheldonLeemonThe Latest Am
- Page 81: Computers and SocietyDavid D. Thorn
- Page 85 and 86: Train with NRI for a high payingcar
- Page 87 and 88: PersonalComputingDonald B. irivette
- Page 89 and 90: 3M DiskettesICEI has an outstanding
- Page 91 and 92: key (Atari logo key on 400/800 mode
- Page 93 and 94: MLXMachine Language Entry ProgramFo
- Page 95 and 96: THEN PRINT IN?iPRINTM{UP][5 RIGHT}"
- Page 97 and 98: When you want to talk price.AmdekMO
- Page 99 and 100: THE LOWESTTHE BESTPRICESSERVICEELEC
- Page 101 and 102: fNOWAVAILABLE AT24$O>!00The Mew Car
- Page 103 and 104: COMPUTERSFREE Reader Information Se
- Page 105 and 106: STARGLIDERJJtarglider — is an all