"Thisequipmentgeneratesand usesradio frequencyenergy. If itisnot ^properlyinstalledand used instrict accordancewiththe manufacturer’sinstructions,this equipmentmayinterfere withradio and television^reception. Thismachinehas beentestedand found to complywiththelimitsfor aClass Bcomputingdevice inaccordancewiththespecificationsinSubpart Jof Part 15ofFCCRules, whichare designedtoprovidereasonable^protectionagainstsuch interferenceina residential installation. Ifyoususpectinterference, you can testthis equipmentbyturning itoffand on.If ^you determinethat there isinterferencewithradio or televisionreception, tryoneormore ofthe followingmeasurestocorrectit:«,
•reorient the receivingantenna
•move the computerawayfromthe receiver ^
•change the relative positions ofthecomputerequipmentand thereceiver ^
•plugthe computerintoadifferentoutletsothatthecomputerand thereceiver are ondifferentbranchcircuits. ^
Ifnecessary, consultyour Commodoredealeror an experiencedradio/televisiontechnicianforadditionalsuggestions.Youmayalsowishto ^consultthe followingbooklet, whichwasprepared bythe FederalCommunicationsCommission:**
isavailablefrom the U.S. GovernmentPrinting Office,Washington, D.C.^20402, StockNo. 004-000-00345-4.
II
Page 3
INTRODUCTION
YOU’LL ADOREYOURCOMMODORE264!Welcometo the Commodorefamily! Whetheryou’reabeginner or anexpert,
you'll be surprisedhoweasyit istouse your Commodore264 computer.TheCommodore264 iseasy to program ...but you don’thavetobe aprogrammer to use it.You don'teven haveto knowhowto type!Commodore’sfull selectionofCOMMODORE264 softwaremakesit easy touse your computerforbusiness, homeand educational applications. (Anddon’tforget the games!)
YouBoughtTheBestComputer
Thesespecial built-in featuresmakeyour COMMODORE264 the best homecomputeryou canbuy:
•64KRAM(60K availablefor BASICprogramming)
•Full TypewriterStyleKeyboard
•Optional BuiltinSoftware
•ScreenWindowCapability
•HELPKey
•8Programmed, ReprogrammableFunctionKeys
•FourSeparateCursor Keys
•UsesMostCOMMODORE64and VIC-20Peripherals
•128Colors(16primary colors, 8luminancelevels)
•Over 75 BASICCommands
•HighResolutionGraphicsPlotting
•Split-ScreenTextWithHigh-ResGraphics
•GraphicCharacterSetOnKeyboard
•KeyboardColorControls
•320x200 Pixel ScreenResolution
•Reverse and FlashingCharacters
•2ToneGenerators
•Built-In MachineLanguage Monitor(13 commands)
WhatYou CanDoWithYourCommodore264
Thekey to any computerisSOFTWARE,and Commodorehas a full“menu”
of softwareavailablefromyour Commodoredealer.SpecificapplicationsIncludewordprocessing, financial calculations, learningactivities, mail lists,projectplanning, recordkeeping, homebudget, investmentanalysisandmuchmore. Somesoftwareproducts combineseveral differentfunctions,suchas “Triology,” whichprovides wordprocessing, anelectronicspreadsheet,databaseANDgraphics!
Manymodelsofthe Commodore264havesoftwarebuiltintothemachine.Youcan alsobuy Commodoresoftwareonplug-in cartridges,floppydiskettesand cassettetapes. And ofcourse,you can learn to program yourcomputerinBASIC, whichcomesbuiltintoyour computer,or inotherpopular computerlanguagessuch asLOGO.
Page 4
Built-in Software
Youmay havepurchasedyour Commodore264 withone of several built-insoftwarepackagesthat are readyto useassoon asyouturn onyourcomputer.Ifyour computerhasbuilt-insoftware,aseparate manualdescribinghowto use the softwareisincluded. Built-in softwareon theCommodore264 isaCommodorefirst!
CommodoreSoftwareonCartridge
For along time, videogameswere theonly softwareprograms availableoncartridge. NowCommodorebrings youlargeapplicationprograms suchaswordprocessingand business programs oncartridge...atpricesyoucanafford. Cartridgesareconvenientbecauseall you havetodoisplug theminand start computing;you don’tneedany additional equipment. Thereareotheradvantagesaswell...forexampie, an electronicspreadsheetoncartridge gives youmoreworkingspacethan an electronicspreadsheetondisk.
SoftwareonDisk and Tape
Commodoresoftwarealsocornes on floppy diskettesand on cassettetape.TheCommodoreDisk Drive lets yourunCommodoredisk-based softwareand the CommodoreModel 1531Datassetteletsyou runtape-basedsoftware.
ProgramminginBASIC— Over 50NewCommands
It’seasy to program your COMMODORE264. Startbyworkingthroughtheexercisesincludedinthis manual, and ifyou want to getmoreinvolved inprogramming, Commodoreoffersseveral self-teachingcoursessuchasINTRODUCTIONTOBASICand our BOOKWARE™seriesof booksandtutoriais.
TheBASICon your Commodore264 isthe mostpowerful BASICeverbuiltinto anyCommodorehomecomputer...itincludesMORETHANFIFTYNEWBASICCOMMANDSincludingfullGRAPHICSPLOTTINGand PROGRAMEDITING.
ProgramminginLOGO—TurtleGraphicsandMore
Manynewcomputeristsprefer tolearn programmingwithLOGO, an easycomputerlanguage createdforbeginners,whichfeatures the use of a“turtle”to drawpictures andcreategraphs and charts. LOGOisrisingrapidly inpopularity, especiallyinschools, and Commodorehasastrongcommitmentto this "friendly”programminglanguage.
Page 5
TheMAGICDESK
If you’reanewcomputeristand you wanttouse your computerforwordprocessing, calculationsand otherfunctions,but youreallydon’twanttolearn any special commandsorinstructions...tryMAGICDESK. Thisunique CommodoresoftwaresystemusesPICTURESoffamiliarobjectsinsteadofwrittencommands, and uses the computerKeyboardlike atypewriter.Thesoftwareisautomaticallylinked toyour diskdrive and printerso,forexample, all youhavetodo is“point”at the pictureofthe printer toprint out a papercopy of somethingyou’vetyped. Ask your dealerfor ademonstration.
CreatingACompleteComputerSystem
Asyoudevelopyour completecomputerSYSTEM, you’llfind thatCommodoreperipherals are pricedsoyou can affordthem, and designedwithsuperior features. Hereare the major peripherals includedinmost
Nowthatyou’veopenedthe boxcontainingyour newC-264 boxand foundthis manual, thefirst thingthat you should doischecktomakesure thatyouhaveail theitemson thislist. Youshouldhave:
1.YourCommodore264
2.Thepowersupply
Thisisa biackbox withalinecordcomingout ofoneend, and around plugcomingout the other. TheroundpluggoesintothebackoftheC-264.Theotherend has astandardthree-prong line plug thatgoesintoaregular
Thisisthe silver and blackbox thatconnectstoyourantennajackonthebackofyour TV. Youdon’tneedtheswitchboxif youplan toconnectyourC-264 toamonitor.
4.TheRFcable
Thisisathin blackcable, withasingleprong jackat eachend, usedtoconnecttheTVswitchboxtotheRFoutputjackon the sideof the C-264. You don’t needthis cableif youareplanningtoconnectyour C-264 to amonitor.
Before you connectanything, you should look over thesedrawings ofyour
computer.Thesedrawingsidentifyallthe outietssoyoucan set up yourcomputersystemquicklyand easily.
Page 9
GETTINGTO KNOWTHESWITCHESANDSOCKETS
THERIGHTSIDEOFYOURC-264
THEON/OFFSWITCH
YourC-264shouldbeturnedoffwhenyouInstallor removecartridgesoranyperipheral devicesuchas aprinter or diskdrive. TheOFFpositionismarkedsoyou canbesure whenyour machineisoff.
THERESETBUTTON
TherearetwowaystousetheRESETbutton:
1.You can use theRESETbuttontoclear your screenandreset your computerasIf you'djustturnediton. Justpressthereset buttononce. Be careful: whenyou pressthereset button,youwill loseany BASICprogramcurrentlyinmemory.*
2.Ifyouwant toreset your Commodore264andKEEPyour BASICprogram, hold downtheRUN/STOPkeyandthenpresstheRESETbutton.Whenyou dothis, your C-264goestothebuiltinmachinelanguagemonitor.TypeanXandpress theRETURNkeytogetbacktoBASIC. Your programisstillcompletelyintactintheC-264 memory. JusttypeLISTtodisplaytheprogramonyour screen.
NOTE:Ifyourantennaisconnectedto your TVbyasingleround-endedcable(the 75-ohmco-axtype),youwill needeitherthe 3CX)ohmto 75 ohmadapter,whichcamewithyour TV, or you must getareplacement75ohmto75ohmswitchbox.Theadapterisa small plastic part withaco-axconnectoron oneside and twoscrewson the other.If youdonot haveorie, itisavailableat mostelectronicsstores. Onceyouattachthe adapterto thecoaxconnectoron your set, youcan followthe rest ofthese instructions.
STEP1.Disconnectthe antennafrom your TV: use ascrewdriver to loosen
were:use ascrewdriver to attachthe leadsonthe boxtotheantennaInput screws on your TV.
STEP3.Connectthe antennato the switchbox:use ascrewdriver to
attachthe leads from theantennato the screws onthe switchbox.
If youhavethe roundcoax type antennaconnectiononyour TV, and youhaveareplacement75-ohmTVswitchbox:
STEP1.Disconnecttheantennafromyour TV: unscrew the antennawire.
Justunthreaditbyhand.
STEP2.
STEP3.
Oncethe switchboxisinplace,getthe RF cable(the thin, jack-endedcable)that camewithyour C-264. Plug oneend into the socketinthe top of theswitchbox. Connectthe otherinto the socketmarkedRF on the left side ofyour computer.
Connectthe switchboxtothe TV:hand turnitontothe antennainput post on your TV.
Connectthe antennatothe switchbox:hand turning the antennacableinto the switchbox.
*
5
Page 12
Onceyou’veattachedthe switchboxto the TV,you never haveto doitagain. Whenyouwant touse the computer,just move the switchtoCOMPUTER. Whenyouwant to watchTV, justmove the switchto the TVposition. Theswitchboxwillnot interferewithvour TVreception.
SELECTINGACHANNELONYOURTV
Aswe explainedearlier, your TVshouldbe set on eitherchannel3or 4whenyou are using your computer. Don'tchooseachannelthatbroadcasts inyour area. If youuse channel3,setthe H/Lswitchon the sideof thecomputer to L.Ifyou use channel4,set thisswitchtoH.
CONNECTINGYOURCOMMODORE264 TOAMONITOR
If you’reconnectingyour computertoa monitorinsteadof aTV, followtheinstructions inthe manualthat comeswiththe monitor. Hookingup amonitorlike the Commodore1703ColorMonitorissimple. It requires onlyone cablethat goes directlyfromyour monitorto the VIDEOsocketonthebackofyour computer.
FINALSTEPS
1.Attachthe powersupplycablewiththe powerboxto your C-264. Plugthe round end ofthe cableintothe POWERsocketonthe backofthecomputer;plug the powersupplyinto thewall socket.
2.Ifyouare usinga TV, makesure that the settingon the modulator (H/L),and the channelonyour TV(3or 4)are inagreement. Makesure that theswitchboxissetto the COMPUTERsetting.
Ifyou are using a1702or 1703 monitor, use therear jacks,and checkthat the back/front switchisset to BACK.
4.Ifall wentwell,thismessagewill appear on your screen:
COMMODOREBASIC3.5 60671BYTES FREE
READY.
The flashingcursor under theREADY messagetellsyou that theC-264 iswaitingfor youtostart typing. The backgroundcolor will be white, whiletheletters will be printed inblack.
NOTE: SomeTVsetscannot displaytheentireC264screen. Instead,their picturecropsofftheleftmostand rightmostcolumnof theC 264 screendisplay. Werecommendyou use a differentTV set or amonitorsuchas theCommodore1702 or 1703color monitor.
If thisisnot possibleyou canremedythisproblemby pressingtheESCapeandNkeys. This
reducesthe computerscreendisplaysize sotheentirepicturecan appear. You rnust repeat thiseachtimeyou turn on your computer.
Manyofthe keys onthe C-264 keyboard are like the keysonatypewriter, but
every key candomore thanatypewriter can. Inthis section, we’llshow you
how to usethe special keys,like the^]keyand the cursor arrow keys.
And we’llshow youthe extrapowers ofevery key, includinghowtoprint thegraphicsymbols on the fronts ofmany ofthe keys.
Whileweguideyou on thetour of the C-264 keyboard, youshould find thekeys and practiceusing them.
THESPECIALKEYS
RETURN
You havetopress the RETURNkey attheend of eachline of instructionsyou enteron your Commodore264keyboard. Youmight think of this key asanENTERkey becauseRETURNactuallyentersinformationand instructionsinto thecomputer.
SHIfT
Thiskey workslike the shiftkey on aregular typewriter. Your C-264 hastwo
SHIFTkeysand aSHIFTLOCK, whichworkslike the shift lock on atypewriter.
WiththeSHIFTkey, youcangetthegraphic symbol onthe right side on
eachgraphics key whenyou are inuppercase/graphics mode.
Your C-264isautomaticallyinuppercase/graphics modewhenyou turn it on.Inuppercase/graphics mode, all the lettersappear uppercasewhentypedwithoutthe SHIFTkey.
9
Page 16
TheSHIFTkey getsupper caseletterswhenyou are inupper/lowercasetextmode.You cantell you’reinthis modewhenthe lettersyou type are inlowercaseexceptwhenyouuse the SHIFTkey. Youcan go back and forthbetweenuppercase/graphics and upper/lowercasetextmodesbypressingtheSHIFTand @5]keyat thesametime.
RUN
STOP
Press this keyto tell your C-264to STOPwhat itisdoing and givecontrolbacktoyou. Whenthe C-264 isrunningaBASICprogram, youcan stoptheprogram withthis key.
WhenyouholddowntheSHIFTkey and typethiskey, RUNtellsthe C-264 tofc>adandrunthe first program on adisk inthe diskdrive.
✓^\
THECURSORKEYS ^]|\
It’seasy to move the cursor quickly around the screeninany direction. Justpressthe cursor arrow key that pointsinthe directionyou wantto go. Like
ail keyson the C-264keyboard, eachcursor key has aREPEATfeature. This
automaticrepeat keeps the cursor moving until you releasethe key.
NOTE:You can move thecursor over lettersand numberson thescreenwithoutaffectingthose characters.
'iN5T/W
Youcan INSERTand DELETE charactersfrom theline you are typingbypressing this key.Whenyou press DEL, thatcharacterimmediatelytotheleftof the cursor disappears, and the cursor movesover to wherethemissingcharacter was. Youcan use thecursor keys to goback to themiddleofaline and then use DELto DELetealetter. Whenyoudo this, theletterto the leftisdeleted, andthe rest of the letterson the line moveoverone space to the left toclosethe gapleftbythe deletedletter.
Youcan openupspace toinsert lettersand numbersbyusingthe SHIFTand INSTkeys.Space openstothe right of the cursor; thecursor itselfdoesnot move. Whenyouinsert space inthemiddleofaline ofletters, the rest ofthe line movesto the right.
Whenyou pressthiskey, the cursor immediatelymoves tothe topleftcorner ofthe screen. ThisiscalledtheHOMEposition. Your screenstaysthesame. If youholddownthe SHIFTkeyand pressCLR/HOME,not onlydoesthe cursor move toHOME, but the screenclears. All that remains onthe screenistheblinkingcursor atthetop leftcornerofthe screen. PressHOMEtwiceto cancel ascreenwindowand return the cursor totheHOMEposition.
3.Whenyouwanttochangethe color ofthe screencharactersto one ofthe 8colors listedon theBOTTOMrowonthe faceofthe color keys,press §ijand thecolor keyyouwant.
4.Whenyou want to slow downascrollingprogram display, holddownthe
jQt|key.Thedisplay scrollingspeedslows downconsiderably. When
you releasethe key, the displayresumesnormal speed.
•If you want oneofthe8colorslistedon the TOProw on the front ofthecolor keys (likeBLacK), justholddownthe CTRLkey and thenpress thecolor key withthe coloryou want.
•If youwantone ofthe 8colors listedon theBOTTOMrow onthe front ofthe color keys(like ORaNGe), justhold downthe@keyand thenpress the color key withthe color youwant.
Afteryou changethe color, every character typedAFTERWARDSisinthecoloryoulast chose.
Your C-264 lets youprint the reverse imageofany character. Inother words,ifyou are usingblackletterson ayellowbackground, youcan usethereverseimagekeystoprintyellowletterson ablackbackground.
Here’sallyoudotogetreversedimages: presstheCTRLkey and the RVSONkey.Noweverything you type will bedisplayedinreverse until you pressthe CTRLand RVS OFF,theRETURNkey, or theESCapekey. Thiswillreturnyoutotyping normal (non-reversed) characters.
uraftiTTOTk
iNEEHk^EXuwk
Youcan makethe charactersonyour screenflash continuously.JustpressCTRLand the FLASHONkeyto makewhatever youtype flash. TypingCTRLand FLASHOFF,RETURN, or ESCapelets youtype normal (non-flashing)charactersagain.
12
Page 19
ESCAPE
Use the ESCape keytoperformmanyspecial screeneditingfunctions,suchassettingthe top and bottomof adisplaywindow.
Pressthe ESCape key and oneofthe letterkeys listedbelow:
AAutomaticinsertmode
BSetthe bottomof the screenwindowCCancel automaticinsert modeDDeletecurrent line
IInsert aline
JMoveto the start of thecurrentline
KMove to the end of the currentline
LTurn onscrolling
MTurn off scrollingN Return tonormal screendisplay size0Cancel insert, quote, and reversemodes
PEraseeverythingup tothe start ofthe current line
Q Eraseeverythingupto the endofthecurrentlineRReducescreendisplay
TSetthe topof thescreenwindowVScroll up
WScroll down
XCancel the escapefunction
SETTINGSCREENWINDOWS
Windowslet you defineanareaof thescreenasyour work area. Everythingyoutype aftersettinga windowwill takeplacewithinthe window(thelinesyou type, LISTs ofyour programs, etc.) withoutaffectingthe rest of thescreen. Youcan put awindowanywhere onthe screen.
Toset a window, followthesesteps:
1.Move the cursor to the screenpositionyouwantasthe top left cornerof
the window.
2.Type the ESCape key, thentype T.
3.Move the cursor tothescreenpositionyouwant as the bottomright
cornerof thewindow.
4.Type the ESCape key, thentype B.
All screenoutputisconfinedtothe windowarea you defined. Cancel thewindowbypressingtheHOMEkey twice. The cursor will go to the HOME
position.
THEGRAPHICSKEYS
Aswementionedbefore, whenyou turnon theC-264, it isinuppercase/
graphicmode. Whenyou’reinthis mode,youcan type the full set of more
than60graphicsyousee on the fronts of manyof the keys,as well asa!l
13
Page 20
uppercaseletters withoutusing the SHIFTkey. TheSHIFTkey lets youtypegraphics,not uppercase letters.
Thereare twographic symbolsoneachgraphics key:
•Toprint the graphic symbol ontheright, holddownthe SHIFTkey while
youpress the key.
•To print the graphic symbol on theleft, holddownthe fC*jkeywhile
youpress the key.
Youcan createpictures,charts, and designsbyprinting graphicsside bysideoron topof eachother, like buildingblocks.Chapter6explains moreaboutgraphics.
Youcan switchbetweenuppercase/graphics modeand upper/lowercasemodebypressing the SHIFTand jC*fkeysatthe sametime. Ineither
Inupper/lowercasetextmode,you cantypeupperand lowercaseletters, justlike aregular typewriter. Otouwill haveto shiftfor uppercaseletters.) Youalsocan use all the graphics on the leftside ofthe graphics keys,whichyoutype the samewayas inuppercase/graphics mode: hold down§£]andpress the graphicskey. Theleftside graphicsare ideal forcreatingcharts,graphs, and business forms.
SPECIALSYMBOLS
TheC-264keyboard alsocontainsspecial symbolsnot foundon manytypewriters, or evenon mostcomputers. Thesespecial symbolsincludetheEnglish Pound sign(£),pi (n),greater and lessthansigns (<>),brackets(fJ),and arrows(t—).Thesespecial symbolskeys are usedinprogrammingyour C-264.
PROGRAMMABLEFUNCTIONKEYS
Thefour keys atthe top ofyour keyboard are special functionkeys that letyousavetimebyperformingrepetitivetaskswiththe strokeofjustonekey.
You can displaywhateachkey doesbytypingKEY and pressingRETURN.
Touse one ofthesefunctions, justpress the functionkey.You need to usetheSHIFTkey for keys 4,5,6, and 7.
Youcan redefineanyofthesekeystoperform afunctionthat suits yourneeds. Redefiningissimple: just use the KEYcommand, whichisexplainedinChapter8and inAppendixB.Youcan redefine thekeysfrom BASICprograms, or changethemat anytimeindirect mode.CThenewdefinitionsare erasedwhenyouturnoffyour C-264.) Youcan redefine asmany keys asyouwant and asmanytimesasyouwant.
THEHELPKEY
Whenyoumakean error Ina program, the C-264 displays an error messageto tell youwhatyoudidwrong. Theseerror messagesare explainedinAppendixA.
You can getmoreassistancewitherrors InBASICprograms byusing theHELPkey.Afteranerror message, pressHELPto locateyourerror exactly.Whenyoupress HELP,the line withtheerror isdisplayedon the screenwiththeerror printedinreverse.For example:
Press the RUN/STOPkey tostoptheprogram. Whydid your C-264print itsnamesomany times?GOTOtellsyour computerto goback toline 1andPRINTC-264 again and again.Thisrepetitioniscalledaloop^,
Nowtype this:
Thistimethere’snoGOTOloop intheprogram, so the orders are carried outjustonce.
Here’sanothershort program thatgivesyouahint of how easy itistodrawgraphics on your C-264:
Ifyou makeamistakewhenyou’retyping something, there are severalways tomakechanges.
1.YOU CANRETYPE ALINEanytime, evenafteryou'veRUNthe program.TheC-264 automaticallyreplacesthe old line withthe newone. TheC-264doesn’tput the newline inthesameplaceasthe old one, and theoldonestill appears onthescreen, but the C-264ignoresit.Whenyouhavetwostatementswiththe sameline number, the C-264 onlyacknowledgesthe last one entered. For example, if your program lookslike this:^—^
10COkftR03~~~20 PRINT“C-264”V
-------------
^mistake)
_____
/
Press the RETURNkey to gettoafresh line, and just retype line 10correctly:
10COLOR0,3
RETURN
Nowthe first line 10isreplacedbythe secondline 10.Youcan check thisbytyping LIST, whichdisplaysafresh copy of your program. Whenyou LISTaprogram, all lines appear incorrectorder andthe replacedlines don’tappear:
computer.Whenyoureplacealine, the newone doesn’thavetobe anything
like the old line. For example, insteadofcorrectingthe spellingof COLOR,
youcan typethis:
10PRINT"I LOVE MY”
RETURN
NowRUNthe program and see whathappens.
2.YOUCANERASE ANUNWANTEDLINEjustbytyping the numberof theline and pressingRETURN. Thecomputerignores theline eventhoughitmight still appear on the screen. TypeLISTto makesurethe line isgonefromthe program.
10PRINT“ILOVEMY”
20 PRINT“C-264”
10
LIST20 PRINT“C-264”
RETURN
RETURN
RETURNRETURN
RETURN
19
Page 26
YOU CANEDITA LINE. Use thecursor keys to move to the placeinthe
3.
line that youwantto change. Nowjusttype over what you want tochange. Press RETURNwhenyou finish.
/\
MP
4'r
^;'V
NOTE:Youdon’thaveto beat the end of the line topress RETURN.Your C-264 will rememberthe wholeiineeven if youpress RETURNinthe middleof the line.
10PRINT"SARAHISMYNAME”
If youwanttochangethe name to GLENN,movethe cursor to theSinSARAH. _
10PRINT“0ARAHISMYNAME”
RETURN
___
'
Andnowjust typeGLENNover SARAHandpress
10PRINT“GLENNISMYNAME”
NOTE:Whenyou type aquotationmark aftera PRINTstatement, you enterQUOTEMODE. Inquotemode, somekeysworkdifferently. For example, ifyoupressa cursor-down arrow whileyou’reinquotemode,the cursor won’tmove andyou’llsee areverseQ printedonthescreen. WhenthePRINTstatementexecutes, the reverseQ isn’tPRINTed; insteadthe cursor movesdown. Inquotemode,the computerassumesthat everything youtype is
somethingyou want todisplay or dolater whenthe PRINTstatement
STEP2:Clearout old programsby typingNEW. Press theRETURNkey.
STEP3:Type this program exactlyas itappears. Rememberto type the
line numbers and all punctuationmarks. Use the tips forcorrectingmistakes(turn to the precedingpages to find them) ifyoutype somethingincorrectly. Don’tforget to pressRETURNaftereachline.
AfteryouSTOPthe program (usetheRUN/STOPkey),type LIST. Whenthe
program isdisplayedonyour screen, lookat the tips forcorrectingerrors
and changethis program sothat afriend’snameappears intheprogram.
TIP: Wantto slow downthis program withoutstoppingit?Justhold downthe £3key.
22
Page 29
INTRODUCTIONTOTHEC-264TEXTSCREEN
Try typing this program:
RETURN
RETURN
RETURN
RETURN
^pmssSHIFTand^S?f
NEW1PRINT“|>”;
2GOTO1
RUN
Nowyour screenfills withhearts. Whenthe entirescreeniscovered withhearts, press the RUN/STOPkeyto end the program. This program showsyouhow big yourC-264'sscreenis.
Nowtypethis program:
NEW^1PRINTMQ”2 FORX=1TO40
3PRINT“V;4NEXTRUN
WhenyouRUNthis program, the firstrowonyour screenfillscompletely
withhearts. Thereare 40hearts altogether.Sincethe rowisfull, youcan seethatthere are 40positions across the screen. Each positionacross thescreeniscalledaCOLUMN.
Nowtype this program:
press SHIFTanc
kCLR/HOME.
^prespress SHIFTand Z.
NEW
lT^Q'
1PRINT2 FORX=1TO253PRINT"m'4 NEXTRUN
RETURN
RETURN
RETURNRETURN
RETURN
RETURN
WhenyouRUNthis program, the firstcolumnon your screenfills withdiamonds.Thereare25diamondsprinted, but the first three disappear at the
topof the screenbecausethe word READY surroundedbytwoblank lines
alwaysappears at the end ofthe program. There are, then, 25 rows. SoyourC-264 has40columnsand 25rows.
23
Page 30
TheC-264 has 1000differentpositions on the screenforletters,numbers,graphicsymbols,etc.
NOTE: Sometimesyou'lltype aparticularlylongline onyour C-264, such asthis:
You’llnoticethatas you type this, yourunout ofroom on onerow.But keeptyping;the C-264 automaticallymovesontothe next row and continuesprintingthere until your lineisfinished.
NowtryRUNningthis onelineprogram. Themessageisprintedontwo■rows. If your line islonger than onerow, the C-264 lets itspill over to the
next row.TheC-264considers thelineendedwhenyoupress the RETURN
key, not whenyoutype to theend ofthe row.You’llgetused to this asyouuse your C-264.
Nowtypethis program:
NEW
1PRINT
2GOTO
RUN
RETURN
RETURN
RETURN
RETURN
Whenyou RUNthis program, you can see thatit’spossibleto tell the C-264exactlywhere toPRINTsomethingonthe screen.
24
Page 31
MOREABOUTPRINTINGONTHESCREEN
Try typing this program:
NEWREADY.1PRINT“A’V'B"2 PRINT“A”;“B”RUN
RETURN
RETURN
RETURN
RETURN
AAB <r
Ifline 1and line2seemssomuchalike, whyisthere such adifferenceinwhattheyPRINTon the screen?Thedifferenceisinthe punctuationbetweenthe itemsthis program PRINTs.
Whenyou use acommatoseparate itemsinaPRINTstatement, the itemsare PRINTedseveral spacesapart. Whenyou use asemicolon, the itemsarePRINTedright next to eachother.
As you recall, theC-264's screenhas 40columnsacross. Thesecolumnsaredividedinto four10space areas, calledPRINTZONES. Whenyouuse acommatoseparatePRINTeditems,the C-264 PRINTsthe first iteminthefirstprint zone, the seconditeminthe secondprint zone, etc. Thecommasworkliketabs onatypewriter.
STEP6. HolddowntheCTRLkeyand press one of the color keys(nota
color that’salreadyonyour screen). Assoon asyou dothis, thecursor will be the color ofthekeyyoupressed.
STEP7.Holdthe space bar downagain. Nowyour C-264 will draw a line in
the newcolor. Continuechangingcolorswiththe CTRLor^]keys and the color keys.Thenhold downthe space bar to makedifferentcoloredlines.
STEP8.Turn offreverseprint byholdingdownCTRLand pressing the RVS
OFFkey. If youpress the RETURNkey,reversewill alsobe turnedoff.
27
Page 34
Try typing someletterinreverse. Justhold downCTRLand RVS ONtoturnonreverse, and then type whatever you want.Reverse lettersmakeexcellent
headlines. Youcan alsouse themtohighlightspecial words and numbers.
Try this:
NEW*
10PRINT“0
20 GOTO10
RUN
Nowpress RUN/STOPand replaceline 20 withthisline to makelettersflashonyour screen:
20PRINT"H264"fpress CTRLandFLASHONRUNV
Page 35
CHAPTER
USINGSOFTWARE
•Introduction.
•Howtouse built-in software.
•Howto load cartridges.
•Howto load cassettetapes.
•Howto saveprograms on cassette
tapes.
•Howto load programs from diskette.
•Howto headera diskette.
•Howto saveprograms on diskette.
•Howto find out whatprograms areona
diskette.
•Gettingsoftware through
telecommunications.
29
Page 36
INTRODUCTION
Thefamilyofsoftwareavailable foryour C-264 isgrowingquickly. Yourdealer can keepyouup-to-date on newproducts and informyouaboutthefeaturesofsoftware that'scurrently available.
YourCommodore264can use softwarethatisbuilt-in or thatisrecordedonCARTRIDGES, CASSETTETAPES,and DISKETTESthat are availablefromyour Commodoredealer.All you doisload theminto your C-264. And you •can createand store your ownprogramson cassettetapesor floppy disks.
HOWTOUSE BUILT-IN SOFTWARE
Your C-264 can be equippedwithawidevarietyoffunctionkeysoftware
packages.Theseare programs builtinto the C-264, whichyou call bypressingthe appropriateFUNCTIONkey.Theprograms range fromLogo to
turned on your C-264, bothBASICand thefunctionkeysoftwarepackagesannouncethemselvesthroughtheirpower-on messages.Also, youcan usethe KEYcommandto see thefunctionkey definitions. Ifthere isfunctionkeysoftwarebuiltIntoyour C-264, the definitionforKEY 1will be:
SYSXXXX:package name. Just pressfunctionkey f1and hit RETURNtoenter the built-in program.
Functionkey software packagesare alsoavailableon cartridge. If you have
pluggedina functionkey cartridgeinto your C-264, start the program bypressingfunctionkey f2.
HOWTOLOADCARTRIDGES
Youcanuse avarietyof business and personal programs, as well asexciting, arcade-style gamesavailableoncartridge foryour C-264.
Followthesestepstoload cartridges:
30
Page 37
STEP1TURNOFFyour C-264.
IMPORTANT:YOUMUSTTURNOFFYOURCOMPUTERBEFOREYOUINSERTOR REMOVECARTRIDGES. IFYOUDON’T, YOU MAYDAMAGE
THECARTRIDGEANDTHECOMPUTER.
STEP2.Holdingthe cartridge withthe nameplatefacingUP, insert the
cartridgefirmly inthe cartridge slot on the back ofyour computer.
Plug cartridge
inhere.
STEP3.Turnon your C-264.
STEP4.Beginthe gameor program accordingto the instructions that
STEP3.Rewindthe tapeto the beginning. Thescreenwill go blank. Justi
press theREWINDbuttononthecassetterecorder.
STEP4.Whenthe tape isrewoundtothe beginning, press the PLAY
buttonon thedatassette.
Whenthe program isfound, the screendisplaysthis message:
FOUNDprogram name
STEP5.Pressthe Commodorekey to load this program. If there Ismore
thanoneprogram on the tape, and the program the C-264 foundisn’tthe oneyouwant, pressthespacebarto keepsearching.
Whenthe program isloaded, the word READYappears. Ifyou wanttostop
theloadingbeforeit’scomplete, press theRUN/STOPkey. After thesoftware isloaded, typeRUNtostartthe program. YoucanalsoLISTit or
changeit,assumingitisa BASICprogram.
ToLOADaspecificprogram on the tape, use the LOAD“program name"
formof the LOADcommand.
32
Page 39
HOWTOSAVE PROGRAMS ON CASSETTE TAPES
Whenyouwriteaprogram and want to saveiton cassettetape, followthese
steps:
STEP1.Type:
SAVE“programname”
Theprogram nameyouuse canbe anythingyou want,but can be nomore
than16letters and/or numbers long.
STEP2.Press the RETURNkey.Thecomputerdisplays this message:
PRESSRECORDANDPLAY ONTAPE
STEP3.Press the RECORDandPLAY buttons on your cassetterecorder.
Thescreengoesblank. Whenyour program issaved,the wordREADYappears on the screen.
Examples ofSAVECommandsfor CassetteTape:
SAVE“MYJOB”SAVE“3TEST”
Page 40
HOWTOLOAD PROGRAMS FROM DISKETTE
Disks arefast and easy to use. Besure to handleyour disksand your diskdrivecarefully.
Thesteps arethe sameforloading all disks:
STEP1.Makesure thatyour disk drive isON.
STEP2.Insert the disk intothe disk drive. Thelabel sideofthe disk must
faceup. Put the disk inso that the labelledendgoesinlast whiletheend withthe exposedoval goesinfirst. Look fora littlenotchon the disk (it mightbe covered withalittlesticker). ThisnotchIson the left side as youput inthe disk, assumingthatyou’refacingyour disk drive. Besure thedisk isInall theway.
STEP3.Closetheprotective door onthe disk drive afteryouinsert the
disk.
STEP4.Type:
DLOAD"programname”
STEP5.Press the RETURNkey. Thedisk spins and your screensays:
SEARCHINGFORPROGRAMNAMELOADING
READY.
■
STEP6. Your softwareisreadytouse.
Type RUNand RETURNtostart theprogram.
If the redlightonthe disk driveblinksafterthe DLOADisfinished,somethingwentwrong. Youcan find out whathappenedbytyping:
RETURN
Examples ofDLOADcommands:
DLOAD"*"LOADs the 1stprogram onthe disk.DLOAD“MYFILE”LOADs adisk programcalledMYFILE.DLOAD"SET*”LOADsthefirst programon the diskthatbegins
WhenyoureSAVEaprogram, you are replacingtheold version withthe newone. If youwant tokeepboththe old and the changedversions, youhavetogive the newoneadifferentnamewhenyou SAVEit.
Followthesesimplestepstosaveaprogram on disk:
STEP1.TypeDSAVE‘‘programname”
STEP2.PressRETURN. The diskdrive makesanoise, and the computer
displaysthis message whenthe programissaved:
SAVING“program name”OK
READY.
Example: DSAVE“MYPROG5”
If the redlight onthe disk drive blinksaftertheDSAVEisfinished,somethingwentwrong. Tofind outwhathappened, type:
programs are available onthe Commodoreuserdatabases.
36
Page 43
CHAPTER
BEGINNINGBASIC
•Doingcalculationson your C-264.
•Immediatemode.
•Using var|ables.
•Inputtinginformation.
•Using loops: FOR...NEXT
37
Page 44
DOINGCALCULATIONSONYOURC-264
Youcan use PRINTto domore than justdisplay whatyouput inquotation
marks. Youcan use your C-264 like asimplecalculator. Besidesthe standard
+and -signs, yourC-264 uses the *sign for multiplicationand the / signfor division andfractions. (Computersuse the *sign insteadof anXformultiplicationbecausea computercan’ttell the differencebetweentheletterXandthe mathematical symbol X.)
Sincelhecalculationinline 1isinquotes,theC-264 just PRINTsthe
problemas if itwere any text:exactly as it appearsbetweenthe quotationmarks. Theproblemisn’tsolved,and no spaceisleftforthe numbers’sign.
Nowmove the cursor back to line 1and change the line so itlooks like this:
,^^^ionTforgetthe semicolon)
1PRINT“2*3+1= ";2*3+ 1^"
RUN#
----------
-----------------------------
2*3+1=7_____________-—
3----------------^^the answer for line2stays
If you wantto bothPRINTthe problemANDsolve ityouhavetotype ittwice: onceinquotes and onceout of quotes.
NOTE:The C-264 doesn’tacceptcommasas part ofanumber. For example,always type 109401insteadof 109,401. If youput acommainanumber, theC-264thinksyoumean twonumbers (separatedbythe comma),so the C-264wouldread 109and 401insteadof109401.
FRACTIONSANDDECIMALS
Youcan writea fractionlike this: 1/2
or like this: .5
If you put afractioninaPRINTstatement, youranswer will always bereturnedas adecimal or wholenumber.For example:
PRINT139/493 +5
5.28194726
Here’sanexamplethat usespi(3.1415926535...), whichrepresentstheratioof thecircumferenceofacircleto its diameter.Justtype the pikey.
RHURN
---------
fhis spaceisleft for the answer’s^)
^sign^
thesame_..-
PRINT"/374
8.39998036E-03
RHURN
39
Page 46
SCIENTIFICNOTATION
Whatdid the C-264 meanbytheE-03part of the above answer ?TheC-264displaysdecimal numbersintherange -999,999,999 to 999,999,999 in
standard numerals,but numbersbeyond this range are automaticallydisplayedinscientificnotation. Thisspecial notationlets the C-264 displaylarge numbersinfewer digits.
Scientificnotationtakesthis fc
numbef|.numberJE<+|->nun
For example:
20=2E+1
105000 =1.05E+5
.0666 =6.66E-2
thedecimal point ismoved1digitleftthe decimal point ismoved5digitsleftthe decimal point ismoved2digitsright
Page 47
IMMEDIATEMODE
Youcanput any calculationinaprogram, orget an immediateanswer bytyping PRINTand the problemwithoutalinenumber, likethis:
PRINT343
-3
PRINT24/(6+2)
3
Whenyoudon’thavealine numberbeforeaBASICstatement, youdon’thaveto type RUNto teli the computerto followthe instruction. WhenyoupressRETURN, yougetinstant results. Nothaving a line numbermeans thecommandshould beactedonimmediately; it’sinIMMEDIATE, or DIRECT
MODE. Havinga line numbermeans thestatementispart of a BASICprogram; it’sinPROGRAMMODE.
You’veusedseveralother immediatemode commands: RUN, NEW, and
LIST.Youcan use PRINTinimmediatemodetoinstantly solvecalculations
or display messages.
PRINT“2TOTHE3RDPOWEREQUALS";2t3
2TOTHE3RDPOWEREQUALS 8
TIPSONERRORS
ifyou makeamistakeinyour PRINTstatement, use theINST/DELkeystomakecorrections.Youcan change the line as muchasyou like beforeyoupress the RETURNkey.
If you makeamistakethatyoudon’tcatchbeforeyoupress RETURN, yourC-264displaysanerror messageto helpyoufigure out whatyoudid wrong.For example:
7SYNTAXERROR
Ifyou getthis message, checkover whatyou typed tosee where youmade amistake. ThecomputerIsverypicky, and Itcan'tfoliowinstructions thatcontainspellingerrorsor othermistakes. If youcan’tfigureout yourmistake, refer to AppendixAformoreinformationabouterrormessages.
Onceyou findyour mistake, youcan use the cursor control keysto movethe
Sometimesit'sagood ideato put negative numbersinparenthesesforclarity. For example, if youwant to add 45and -5,type itlike this:45 +(-5).The C-264will understanditeitherway.
42
Page 49
USINGVARIABLES
Theexample36*(12+(A/3))showsone of the mostpowerful features ofacomputer.Whenweused a letter insteadof a number inamathematicalproblem, weusedaVARIABLE. Avariable stands fora value:
10A=3
20 PRINT"TOTAL:";A*4RUN
TOTAL: 12
Therearethree typesofvariables youcanuse:
Type
________
Integer
Textstring
Floatingpoint
Alwaysuse the rightvariable type. If you tryto dosomethinglike assignaword toaninteger variable, yourprogram won’t work.
Whenyou RUNthis program, type inanswers to theDATE? and WHAT’SYOURNAME?.
press the cursor-down arrow 5times
43
questions WHAT’STHE
Page 50
INPUTTINGINFORMATION
Thelast exampleshowedyouanewBASICstatement, and anewway toenterinformation. INPUTletsyouenterwords and numbersWHILEtheprogramisrunning. Thegreatestadvantage tothis isthe reusabilityINPUTtingbrings toprograms.
For example, ifthe last program had the line PRINT"OCTOBER31”,you’dhavetochangethe line beforeyouexecutedthe program whenever thedateisn’tOctober31.Withthe INPUTstatement, you don’tchangethe program.Instead,everytimeyoureuse it,you supply fresh information.
Line 10tellsthe computertodisplay aquestion, calledaPROMPT, to tellyouto INPUTavalueforX$. The program waitsuntil yousupply thevaluebeforecontinuingwiththe pr#gram.
Line 20 PRINTsamessageand the valueyouINPUTfor X$.
Line 30tellsthe computerto end theprogram immediatelyIFthe valueyouINPUTfor X$isSTOP. Whenthis happens, line 40isnot executed. IfthevalueyouINPUTisnot STOP, the program doesn’t end.
Youtype inthesewords.TheCommodore264 prints
the rest.
44
Page 51
Line 40 tellsthe computertogobacKto line 10soyoucan INPUTanothervalue for X$.
Youdon’thavetoinclude amessageinan INPUTstatement. Whenyoudon’t,the computerdisplaysaquestionmark to tell youit’swaitingfordataINPUT. For example:
NEW10FORC=1TO320INPUTX
30PRINT"TOTAL:";X*1.06
40NEXTCRUN?5.5
TOTAL: 5.83
?1.00
TOTAL: 1.0676.97TOTAL: 7.3882
Page 52
USINGLOOPS: FOR...NEXT
Sofarwe’veshownyou severalways to makeaprogram repeat someor allofits lines. GOTOahd IF...THENstatementsare twoways to control andrepeat program execution.
FOR...NEXTstatementslet youcreateprogram LOOPSthatcontrol thenumberof timesasegmentof aprogram isexecuted. The FORstatementsets a limiton the numberof timestheloopwill executebyassigningarange ofvalues toavariable. FORworks like this:
FORcounter=first timeTOlast timedosomethinguntil the last value forthe counterisreachedadd the NEXTvalue to thecounter
TheNEXTstatementmarks the end of aFOR...NEXTloop. Whenthe
program reaches the NEXT^statement,the computersends control backtothe FORstatement. Thecomputerthenincreases the loopcounter valueby1(orwhateverthe value namedinaSTEPstatement)and checksto see iftheend limitofthe loophas beenreached. Ifthe end limithasbeen
exceeded, control istransferred tothe statementfollowingNEXT. If the end
Ordinarily, every timea FOR...NEXTloopexecutes, the valueof thecounterincreases byone. You canvarythe amountofthe increasebyadding aSTEPstatementto the FORstatement:
FORCT=1TO4STEP2
FORCT=1TO4STEP.5
FORCT=4TO1STEP-1
this STEPadds 2to the countereachtimethe loop executes, so this loop executestwice, not four times
this STEPadds .5to the counter, so thisloopexecutesseventimes
cursor changesone of the 8colors printed on the bottomof eachcolorkey.All16colors can appear on the screenat the sametime.
HOLD®
WITHCOLORKEY
1ORANGE234PINK567DARKBLUE
__________8__________
Table2:Colorsusing S']key
COLORRESULTBLACKWHITEREDCYAN
GREEN
YELLOW
COLOR
RESULT
BROWNYELLOW-GREEN
BLUE-GREENLIGHTBLUE
LIGHTGREEN
___________
__________
___________
48
Page 55
GRAPHICCHARACTERS
Each letterkey contains2 differentgraphiccharacters, asdothe @,-,*,
and £keys. Toprint graphic characters,youmust hold downthe SHIFTor
[C«|keywhileyou press the key for the graphic symbol youwant.
Whenyour C-264isinuppercase/graphicmode, holddownSHIFTandpressaletterkeyto displaythe graphiccharacter onthe right sideof that
letterkey.Thesecharactersinclude the playing card suits, asolid and ahollowball, and a set of lines and connectingcharactersthat let youdrawmany differentpictures on your screen.
Herearesomeexamplesto helpyougetused to thesecharacters:
Exercise 1:LargeCircle
Step1:PressdowntheSHIFTLOCKkey. It shouldstaydown.Step2:Hitthe *etterUthenthe letter I.Step3:Hitthe fcMH:l!l key.Step4:Hitthe letterJthen the letterK.Step5:Hitthe ^;UnkMkey.
Did youwonderwhythe computerdoesn’tsaySYNTAXERRORwhenyouhit RETURN? After all, youhadcharactersontheline that weren’tcommandsthat the computercan understand.
Thereason isthat the C-264doesn’tpayattentionto the line youtypedifyou holddownSHIFTwhenyoupress RETURN. If you pressRETURNwithout the SHIFTkey,the computertries to figure out whatyoumeanwhenyou're just drawingpictures.
Sofarwehaven’ttalked about the graphic charactersonthe left side of thekeys.These graphicswork justlike the rightside characters, exceptthat youholddownthe £*]keyinsteadof SHIFT.There isno [C«]lock, soyoumust holditdownyourself.
You can print this set of graphicsineitheruppercase/graphicmodeorupper/lowercasemode.
Press downthe SHIFTLOCKkey. It should staydown.HitM, then SPACE, thenN, thenSPACE, then —.Hitthe BMB:Mkey.HitSPACE, thenV, then SPACE, then*, then+,thenHitthe BTfHI'M key.HitN, then SPACE, thenM, thenSPACE, then —.Hitthe i-MI:lflkey.
The left side graphic charactersincludelines and angles usedfor drawingcharts and tables. For example, here’showtounderline aword:
Moviesarereallyasequenceof still pictures. Each picture isalittledifferentfromtheone thatcamebefore. Theprojector showseach picturefora veryshort time, thengoes on tothenext one. The scenebecomesanimated.
Computeranimationworks the sameway. Firstthe computerdraws onepicture, then itchangesthepicture slightly. TheC-264isfast enoughtoallow objectstomove smoothlyall around the screeninyour gamesandpracticalprograms.
You can’ttypefast enoughto createanimation. Amovie isanimatedat arate of 30 pictures per second. Thechangesmustbefast enoughto fool theeye. Soyoumustuseaprogram to drawa picture, wait for asplitsecond,thenchangetoanewpicture.
Toget the program tocreatepictures weuse the PRINTstatementwiththegraphic characters. The simplesttype of animationinvolves alternatingtwocharactersto get the effectof movement.
To geta more interestingeffect,you can build asmall picturefrom severalgraphiccharacters, thenchange afewof the characterswhileleaving othersinthe same place.Thisgivestheeffectof part of anobjectmoving.
RETURN
52
Page 59
*Exercise9:JumpingJacks
^TypeNEW and hitRETURN. Remember tohitRETURNaftereachline.
10PRIMT"CM1R9S|ME3BIWQSS|1]"
-20PRINT"SPACEg]+SPACE"
30PRINT"iBBINSPACEE3S| M"
-40FORL=1TO100:NEXT50PRINT"flBTCflSPACEGSBWSPACE"
60PRINT"te*jT@+S>jT"
70PRINT"SPACEg|Gg|G"80FORL=1TO100:NEXT90GOTO10
TypeRUNand hit RETURN.
Inbothexamplesofanimationso far,we’veworkedon only one area on thescreen. The next stepisto movethe animatedfigure around.TheTABfunctionhelps whenyouwantto moveobjectsfrom the left edge.
Exercise 10:CrawlingSnake
Type NEWand hitRETURN. Remember to hit RETURNaftereach line.
Using charactersliketheball(SHIFTQ),youcan playvideogamesonthescreen. Tomoveaball, justerasethe balland replaceitat a newposition.
53
i"
Page 60
Exercise11:MovingBall
TypeNEW and hitRETURN. Remember tohitRETURNaftereachline.
10PRINT"20
PRINT■
30
FORL=1
40
GOTO20
TypeRUNand hitthe RETURNkey. Hitthe STOPkey whenyouwant theprogram to stopmoving the ball.
CONTROLLINGCOLORS
Separate colors can be put into eachpart of the screen. Theborder canbeone color, thebackgroundadifferentone, and eachcharactercan haveitsown color.Youalreadyknow how toset the character colors using thekeyboard.TheCOLORcommandadjuststhe color of the otherscreenareas.
Turn lheborder of your screenredbytyping the commandCOLOR4, 3andpressing theRETURNkey. The number 4inthe commandstands fortheborder area, and color number 3isred(the samenumberas on the keymarked RED).
NowtypeCOLOR0, 7and hit RETURN. The screenbackgroundturns blue.Thenurnber 0standsforthe background, whilethe 7isblue (also the sameas the keyboard).
The first number after the word COLORstands forthe areaonthe screenyouwant tochange. Area0isthe background, 1isthe character color, 4is
the border.You'll learn about areas 2and 3whenyougetintomulti-color
graphicslater inthis chapter.
QQ|
SPACETO50
SHIM
NEXT
£=CRSR
Area #
~~-
1234
Table3:ScreenArea Numbers
AreaName
Background
Character
multi-color 1multi-color 2Border
_______
54
Page 61
Each color alsohasanadjustablebrighlnesslevel,calledthe luminance.
Youcanaddanumber from 0(darkest) through 7(brightest) afterthe color
numberto varythe color. TypeCOLOR4, 3,0 and hit RETURN. The border
becomesadark red.Type COLOR4,3,7and the border changestoabright
red.
ColorKeyffColor
__
BLACK2345678
___________
Inshort, the COLORcommandlooks like this:
COLORarea, color, luminance
Hereisa quickprogram toshow you allthe C-264's colors:
Exercise 12:LuminanceBars
First type NEWand hitRETURN. Don’tforgetto hit RETURNaftereach
NowtypeRUNand hitRETURN. Youwill seeabright blue screenwitheach
of the other 15colors shownat eachluminancelevel.
55
Page 62
HIGHRESOLUTIONGRAPHICS
The C-264 screen contains25 rows of 40 characterseach, or1000totalcharacter positions on the screen. Each character isformedout of single~dots, with8 rows of8dotseachmakingan entirecharacter.Vour screenhasa total of 320 dots on eachrow, and 200 rows, or64,000 dotsalltogether. —The Commodore264 letsyoucontrol every dot.
Using normal graphics, youhavelimitedcontrol overthe individual dots. You~must use the 128charactersbuiltinto the C-264, whichletsyoucreatemany
pictures. But think of how manyyou couldcreateifyoucouldcontrol each —
dot byitseif!
Thehighresolutiongraphicsabilityof the C-264lets youdojust that. You~can use commandsthat let youdrawand erasedots, tines, circles,and othershapes. -
There isonelimittohigh-res graphics. TheC-264 can still only use onecolor
ineach character position. Thatis,each 8by8space6nthe screenwhere —charactersusually gocanstill onlyhaveone color (aside from thebackground color).Youcan use differentcolorsforeachdifferentcharacter —position, but only one color withinthat position.
Noticethat the colorschange near the intersections.
Toswitchfrom normal graphics(also calledTextMode)to high-res,justtyp<*the commandGRAPHIC2,1and hitRETURN. Thescreengoesblank and thecursor reappears nearthe bottomofthescreen. The C-264 dividesthe —screeninto 2separate sections: the topfor graphics and the bottomfive_lines for text. Ifyoudon’twant the bottomfive lines for text, you can use thq_commandGRAPHIC1,1,but you won’tbe abletosee anycommandsyou
type. ._
56
Page 63
Youcanswitchbackand forth fromgraphics totext using the GRAPHIC
~command. The commandGRAPHIC0switchesthe screen backto text,
There isanother waytoclearthe high-resolutionscreen. ThecommandSCNCLRwill erasethe screenwithoutchangingthe graphic mode.
Onceyouuse high-resolutiongraphics, the computerloses 10Kof memory,whichisset asideforamoredetailedscreen. Whenyouare through usinggraphics, youcan reclaimthismemorybyusing the commandGRAPHICCLR. Inmostprograms it won’tmakeadifference, but it’sagoodhabit togetinto.
57
Page 64
POINTS, LINES, ANDLABELS
Type the commandsGRAPHIC2,1:DRAW1,0,0and hit RETURN. Look
closelyat the upper leftcornerof thescreen. TheC-264drewablackdotthere.
Inthe DRAWcommand, the first number lseither1(drawa dot) or0(erase a
dot).The next twonumbers are for the rowand columnpositionsforthe dot.
Soif youwantedtodrawadot at row17,column20, justtype DRAW1,17,20.To erasethe same dottype DRAW0,17,20.
theword TOand the coordinatesoftheotherend, like this: DRAW1,1,1TO100,100. Thisdraws aline from1,1to 100,100.
If youare used to drawinggraphs inmath, you mightgeta littleconfusedatfirst whileusing the computer.Thecoordinatesysteminthe C-264isupsidedownfrom whatyou're used to.Inmath the 0,0point wouldbe at the lowerleftcorner ofthe screen, but onthe computeritisthe upperleftcorner.You’llget used tothe systeminthe computeras you practice.
Onceyouhaveput apoint or line on the screen, youcan drawaiine from ittoanyother point like this: DRAW1TO150,50.Thisdraws aline from thelast pointdrawn torow150,column50.If your program usesalot ofDRAWTO commands, you couldpositionthe first dot at apositionon the screenbyusing the LOCATEcommand, as inLOCATE100,100.
Thisprogram plots the same curveusing pointsinsteadof lines.
USINGTEXTINGRAPHS
Your graphs will be more attractive ifyouusewords tolabel them. You canuse the CHARcommandto mix text right into ahighresolutiondrawing. Forinstance, thecommandCHAR1,0,5“HELLO”putsthe word HELLOintothesixthrowat the leftedgeof the screen. Thefirst numberafterthe wordCHARiseither1(for draw) or 0(for erase). Thenexttwonumbersarethecolumnandrowwhere thetextwill appear.
Using the DRAWcommand, youcan draw pictures byplottingmany dotsorlines. To draw a square, you canuse the commandDRAW1,0,0TO100,0TO100,100 TO0,100TO0,0.
rectangular shapes.The BOX commandlets youpickthepoints of 2oppositecorners ofthe square. To duplicatethe same boxasinthe aboveexample, just use BOX1,0,0,100,100. Thenumber 1again means that youwantto draw and not erase. Thenext four numbersarethe coordinatesofthe box’soppositecorners, (0,0)at the upper-leftcorner and (100,100)nearthe middleof the screen.
Youcan evenrotate the boxbyspecifyinganangle (indegrees) after the lastcoordinate,like this: BOX1,50,50,100,100,45. Theboxrotates 45 degrees
clockwise.
If you wouldlike todraw asolid boxinsteadof justtheoutline,youjust addacomma1aftertheangle.Asolid boxat the centerof thescreenisshownas BOX1,100,50,220,150,,1. Noticethat you need acommato hold the placeof the angle, even though youdon’twant the boxrotated.
Sometypical forms of the BOX commandare:
COMMAND
BOX1, row1, column1,row2,column2
BOX1, row1, coll,row2, col2, angle
BOX1, row1, coll,row2,col2,,fill
BOX0, row1,coll,row2, col2, angle, fill
Exercise 17:RotatingBoxes
Type NEWthenhit RETURN. Don’tforget tohit the RETURNkey aftereachline. Type RUNand hitRETURNat the end.
HitRETURNand typeRUN. Holddownthe STOPkey to end theprogram.
This program draws differentcoloredsquares all over the screen. You’llnoticesomeparts ofthe screenchangingwhenother parts nearthemchange. The reason forthis wasdiscussedInsection5earlier inthischapter.
DRAWINGCIRCLES
The C-264 alsohascommandsfordrawingcircles. Like theBOX command, _wecan varythe shape of the circleto forman oval(also catied anellipse),“andwe can rotatethe oval.Wecan alsojustdrawasectionofthe shape(called anarc).*
This commanddrawsacircleinthe center ofthescreen: CIRCLE
1,160,100,50.ThistellstheC-264 to draw a circlewithits centerat row 160*
and column100,witha radiusof 50.Thisactuallyproduces an oval,sincethedots on the screenare taller thanthey are wide. Tochangethis toareal~circleyoumustaddaseparate numberto tell that theheightisdifferentfrom the width, like this: CIRCLE1,160,100,50,42. -
TheC-264can also drawasquare, triangleor other polygon usingtheCIRCLEcommand. Justtell thecomputerhow manydegreesto gobetween~points onthe circle,like this: CIRCLE1,160,100,50,42,,,,120.This commanddraws a triangle,sinceeachsideis120degrees. Asimpleformulatogetthe —angle for apolygon withNsidesis360/N.
TheBOX commandallowsyouto createsolid blocks insteadof outlines. But
itdoesn’tlet you color inirregular areas onthe screen. That’swh6rethePAINTcommandcomesIn.
64
Page 71
Inthe last exercise,wecreatedthe5-ringsymbol of the Olympicgames. Byadding somePAINTstatementstothe program wecan color inonly theareasbetweenthe rings.
Exercise22:OlympicPainter
Type inthe programinExercise 20, thenadd the&elines:
110FORL=0TO2120PAINT1,120+35*L,75
130NEXT
ThePAINTcommandwill fill inanyenclosedarea uptotheboundaries
formed byany lines drawnon the screen. Ifthere are nodrawnlines, the
screenisfilledrighttothe edge.
MULTI-COLORGRAPHICS
TheCommodore264highresolutiongraphicsgiveyoucontrol over a greatmanydots onthe screen, but youhaveseen that the ability toput colorsclosetogether islimited. Mosthigh-res programs will probably onlyuseonecolor.
Togetaround this, the C-264 hasanin-betweengraphicsrnodecalledmulticolor graphics. Inmulti-color graphicsyoucan control half as many dotson.eachrowas inhigh-resbecauseeachdot istwiceaswide. Youget 160dotsoneach row, and youstill get200 rows.
Tobegin usingmulti-color graphics, refer totable5earlier inthischapter.Youwill seethat the multi-color screenwithout text isGRAPHIC3and themulti-color screenwith5linesof text isGRAPHIC4.
Nowlookat table3on page 54,the color area table. Youwill see twoareas
that we haven’tusedyet, areas 2 and 3.These areashold twoextra colors.Youcan use any of the three colors (1,the text color; 2,an extra color; and 3,
Color area 3,the secondof the multicolorareas, hasa special abilitythat ^none of theothers has.Onceyou havedrawnon thescreenusing area3,you canchange that color everywhere it appearson the screenbyusing the_COLORcommand. If you set the color withCOLOR3,5 and draw usingthatcolor, your graphicswill appear inpurple. Ifyouthenchangethe color withCOLOR3,6, allthe purple areaswouldchangetQgreen. Thisdoesn’twork ~withany otherarea.
Hereisashort program lomakemusiconthe C-264. Justtype theprogramexactlyasitlooks, and rememberto press RETURNat the end of eachline.Whenthe program isentered, type RUNand the pressRETURN. Whentheprogram asks youto entera number,typeany numberfrom0to1023andpress RETURN.
10VOL720DO30INPUTX40SOUNDl,X,1050LOOPUNTILX=0
Here’show to playanofeonthe C-264. If you typed inthe program at the
beginningof thischapter, press the 0keyand press RETURNto stoptheprogram.
Example#1:
First:
TypeVOL8and press
Second:
TypeSOUND1,266,60 and press
Youshouldhear anoteplayfor about asecondand thenstop. If youdon’thearanything, turnupthevolume of your televisionor monitor and tryitagain.
Thesetwostepsare theonlycommandsthat youneed to knowto playmusic on your C-264. Let’slookat whatthesetwocommandsdo.
RETURN
RETURN
68
Page 75
VOL
The VOLcommandcontrolsthe volume of thenotesthat theC-264will play.Thinkof the first three letters of theword ‘volume’toremember the VOL
“command. The numberthat comesafterVOListhe settingfor the volume.
—SOUNDcommand. Itcan go veryhigh,and pretty low too.
Voice2—Thisvoice can be used fortonesorfor noise. Usea 2after the
“SOUNDcommandto selecttones, and a 3to select noise.
You can usenoiseto makesound effectslike thunderand rain.
NOTE
Thesecond number afterthe wordSOUNDisthe notevalue. This can be any
«. numberfrom0to1023,and ittellsthe C-264 howlow or high anotetoplay.
Asthe numbersgetbigger, the notes gethigher.
—Noiseis“white”noiseonly inthe range 600-940.Youcan use register values
outsidethis range to createotherinterestingsoundeffects.
69
Page 76
Hereisachart that showsallofthe notesinone scale,alongwiththenote
value touse. For examplerifyouwantto play an*E\youwouldlook for‘E’
onthe chart and thenread across to 854. The854 wouldbe thenote valuetouseinthe SOUNDcommand. Thereisa completechart of notesfortheC-264inAppendixG.
NOTESOUNDREGISTERVALUEACTUALFREQUENCY(HZ)
AD
C
D
EFG
Try puttingthe followingprogram intothe C-264:
770440.4798494.9810522.7834588.7854658864881782.2
699
NEW10VOL7
-----
—turnonvolume20X=030DO
40SOUNDl,X,5
-----
playnote50X=X+560LOOPUNTILX=102070VOL0
------
—turnoffvolume
80END
Typethis program inexactlyas itisshown. Don’tforget to pressRETURNaftereachline. Whenyoufinishtyping itin, and youhavecheckedformistakes, type RUN and press RETURN. TheC-264will show offhowlowand highitcan goand playmany notesinbetween.
DURATION
Thethird numberafter the wordSOUNDiscalledthe duration. This tellstheC-264howlongtoplaythe note.Thisnumber can beanythingfrom 0to
65535. Thisnumberisatimer, exceptinsteadof tickingonenumber eachsecond, itticks60.Adurationof 60will keepthe note on for one second.Youdon'tneed tounderstandthis right now,justremember that the biggerthe number, the longer the notewill stayon.Infact ifyou use 65535, thenotewill stay on for over 16minutes.
Page 77
MAKINGSOMEMUSIC
Nowthat we’velookedat the commandsthat the C-264 usesformakingsound, let'smakesomemusic. Hereareacoupleof programs totype:
Thefirstprogram turnsthekeys from1through8into apiano. Typeintheprogram and thentype RUN.
ColorPiano
5SCNCLR
6FORX=1TO8:READN(X):NFXT
10VOL7
20DO
30GETA$:1FA$=""fllEN30
35A=Af>C(A$):IFA<49ORA>56T!IF,N50
36M=fl-4R
40SOUND 1,N(N),5
45COLORO,N,3
50LOOP UNTILA=32
55VOL0:COLORO,2,1
100DATA169,262,345,383,453,516,571,596
Press numbers1through8to getnotes. The screeneven changescolors
withthe differentnotes. Whenyoufinishplaying, youcan press the space
bar to stop the program.
Hereare the numbers to press forafamiliarsong:
Twinkle,Twinkle,LiHleStar
1155665443322155443325544332
11556654433221
71
Page 78
Hereisaprogram that plays asong by reading a list ofDATAstatements.
TheDATAstatementsare inpairs. Thefirst number isthe notevalueforthe
SOUNDcommandand the secondnumberisthe durationfor the SOUNDcommand.
WhenyoupressaKeyfrom 1through 9, the notewill beplayed, and anotewill appear onthe staffon the correctline.
As this chapterhasshown, it’snot hardto writeyour ownsoundprogram.The programsinthis chapterjustbegintoshow the musiccapabilitiesofthe C-264. Don’tbe afraid totrynewsounds and noisesand createyour veryownmasterpiece.
74
Page 81
CHAPTER
BASICTRICKS
75
Page 82
CONTROLLINGTHESPEEDOFYOURPROGRAMS(FOR...NEXT)
Did youever want toSLOWDOWNaprogram? Youcancontrol the speedofyourprogram byusing aspecial two-part commandcalleda timedelay loop.
Timedelay loopsuse the FOR...NEXTcommandto tell the computerto
pause andcount to some numberbeforecontinuing, slowingdownyourprogram.
Here’swhat a timedelay looplooks like —youcan insert a line like this
These twonumberscanbe any two*numbers. Thecomputerwill "count”^from the firstnumber tothe second,and thelarger the difference, thelongerthe timedelay. For example
ITOIOOisamuchshortertimedelay
thanITOIOOO.
Let’stryanexampletosee howitworks. Type the word NEWand press theRETURNkey(to erase any previousprograms), thentype the followingprogram exactlyas shown:
10PRINT'COMMODORE”20PRINT”TECHNOLOGY”30 GOTOIO
______
RETURN
RETURN
RETURN
Nowtypethe word RUNandpress the RETURNkey. That’stoo fast!Let’sslow itdown. First, let’sdecidewhere wewantthe program toslow down.Afterthe word COMMODOREappears on the screenwewanttomakethecomputer pausesowecan readthe word, so agoodplaceto put atimedelay would berightafterLINE10...at anewline numbered15soit fitsbetweenLine 10and Line 20.
Wealsowant sometimeto read the secondmessage, whichisthe wordTECHNOLOGY,solet’sput atimedelay afterLine 20,onanewlinenumbered 25 so itfits betweenLINE20andLINE30.Typethesetwolinesexactlyasshown(thecomputerwill automaticallyinsert theminto yourprogram):
15FORT =1TO500:NEXT25 FORT =1TO500:NEXT
RETURN
RETURN
Type the word RUN and press theRETURNkey.Tostop your program, holddowntheRUN/STOPkey. Thentype the word LIST and press RETURNtosee the completeprogram. You’llsee FOR...NEXTloops used astimedelays invarious programs inthis manual.Remember,whenever youseethevariable Tused inaFOR...NEXTloopinthis manual, it isbeingused asatimedelay.
76
Page 83
TIP: To makethe messages flashfaster, trychangingthe number 500 inLines15and 25 tothe number100.
•ANEASY SOUNDEFFECT(FOR...NEXT...STEP)
FOR...NEXT...STEP can be used creatively insound effects. Inthis
*■program wearegoing to use aFOR...NEXTloopwithanegative step, so
wecan count downfroma high number to alower one.
*10VOL7
20FORS=1000TO700STEP-25
~30SOUND1,S,1
40 NEXT
~TypeRUN and press RETURN. Hear the sound effect?The keyisLINE20,
where weused anumber range from1000to700 going DOWNTHESCALE.
*~ThenweSTEPped-25 numbers at atime.Finally, inLINE30 weplayed
each note veryfast bysettingthe DURATIONto1.Experimentingwith
—differentnumberand durationvalues can giveyousomeveryinteresting
effects.
PROGRAMMINGTIP:
You canmakealongprogram shorterbycombiningmore than onecommandon aline. For example, youcan writethe musical sound effectprogram onONELINE,byseparating the various commandswithcolons (:),like this:
10VOL7:FORS=1000TO700 STEP-25:SOUND1,S,1 :NEXT
Whatthis doesiscreatea ONE-LINEmusicaltoneorsound effectthat youcan easily insert into your BASIC programs where youwantaquickmusicalprompt. This techniqueiscalled"crunching”yourprogram. Crunchingmakes theprogram uselessmemory,runfaster, and istheway to get themost out of the memory capabilityof your computer.
77
Page 84
UNDERSTANDINGRANDOMNUMBERS
Take10piecesof paper and wrileanumber from 1to10on eachpiece.
Next, put the 10pieces of paper into ahat or other container where you can'tsee them. Now, cover your eyes and draw out onepieceof paper. Whatnumberdid youget? ThatnumberisaRANDOMnumber. Nowput thenumberback intothe hat, mixupthe papers and drawagain. Each timeyoudraw a number, put that numberbackinthe hat sothere are always 10piecesof paper to choosefrom. Keeping10numbersinthe hatmeansyoualwayshave10random numbersinthe hat.Whenyoutakeanumber, youDON’T know what numberIsgoingto comeupnext, but youDOknowthatthe numberwillbebetween1and 10.Thisisthe basis of RANDOMNUMBERS.
Inprogramming, randomnumbersusually haveaRANGE. Thismeansthere’san UPPER LIMITand aLOWERLIMITtothe numbers youcan draw.Inour hat example, therangeof number is1to 10.The lower limitis“1”andthe upper limitis“10”,whichmeans that ANYNUMBERFROM1TO10CANCOMEUP ATRANDOMWHENYOUDRAW.
Nowlet’sseehow your Commodorecomputerhandles random numbers,and someof the funthings youcandowiththem. Here’saprogram thatgenerates5 completelyRANDOMnumbers:
10FORX=1T05:PRINTRND(X): NEXT
Theserandom numbers are allrathercomplex, withseveral places on theright side of the decimal point...but mostusesfor random numbersrequire WHOLENUMBERS. You can makeyour numberscomeout as wholenumbers(withoutdecimal places) byusing the INTegerfunction, whichcutsoffallthe digitsonthe RIGHTside ofthe decimal point. Thenext sectiongivesyouaformulafor using random numbers.
REtURN
78
Page 85
ANEASYRANDOM NUMBER FORMULA
Here’sasimpleformulafor generatingrandom numbersinanyrangeyouwant.Youcan use this formulaalmostanywhereyouwoulduse a variable ornumber inyour program.
INT(RANGE*RND(1))+LOWERLIMIT
TheINTcommandtellsthe computerto cut offanydecimal places and onlygiveyou wholenumberslike 1,45, or 320, insteadof numbers like 1.223,
45.6677, or 320.59. Wholenumbers areeasier towork with whenusingrandom numbers.
LOWERLIMITinour formulameans the lowest number youwant thecomputerto choosefrom.
RANGEmeans how many numbersare inthe total group.
For example, ifyouwantto choosearandom number from 1to 5,theLOWERLIMITwill be 1and the RANGEwill be 5.Ifyouwant to choosea
random numberfrom15to 20, the LOWERLIMITwill be15and the RANGEwill be 5becauseyouare still choosingfrom atotal group of 5numbers. Ifyou’rechoosingnumbers from2to100,the LOWERLIMITis2 and the
RANGEis98. Seehowitworks? Let'stryout aprogram:
10PRINTINT(5*RND(1))+1
TypeRUNand press RETURN. TypeRUNagain...andagain. Each timeyou
Oneof the funthings you can do to impressyour friends istouse yourcomputer’sgraphiccapabilitiestocreateinterestingpatterns and designs.This programcreates beautiful concentriccircleswithexquisiteopticaleffects.
increase the radius by2and go backanddrawaslightlylarger circle, again andagain, each circlealittlelargeruntil wehaveaseries of concentriccircles.
back into textmode.
NoteinLine 10weset theline drawingcolor todark blue. COLOR1 meansdrawingcolorand 7means setittoblue, but there’saTHIRDnumberhere!Wedidn’tshow youthis feature inthe previousexample, but ifyouadd aTHIRDNUMBERtoyour COLORcommand, you can designateLUMINANCE.
Luminancecan be thought of asthe LIGHTNESSorDARKNESSof acolor.
Inotherwords, youcan set luminancelevels from 0(darkest) to7(brightest).Wewantedaverydeepblue so wechosealuminancelevel of 2.Trychangingthe luminancelevels and see what happens tothe color.
81
Page 88
CIRCLEPATTERNS
Hereareacoupleofone line programs that showoffthe circlecommand.
Thekeytopositioningaword or graphic image where youwant itonthescreen...orevenmakingitMOVEinanimatedprograms ...isusing theCHARstatement. Whileitispossibleto doitwithstrings containingthecursor movement keys, youwill soonagreethat the CHARstatementismucheasier touse:
20 FORT =1TO2000:NEXT25 CHAR1,0,5,"5SPACESUP";30 FORT =1TO2000: NEXT35 CHAR1,0,0,"HOMEPOSITION”;40FORT=1TO2000: NEXT45 CHAR1,10,0,"10 SPACESRIGHT";50 FORT=1TO 2000:NEXT55CHAR1,12,12,"12 DOWN, 12LEFT”;
60END
Youcan usethis sametechniquetoPRINTGRAPHICSYMBOLSanywhereusing the keyboard graphicsexplainedinChapter6.
LL
i
1
I
i1
I
i
|
I
1
i
I
11
82
i
i
j
Page 89
CHANGINGCOLORS
Whenyou turn onyour C-264, the screenisBLUE and the charactersonthescreenareBLACK. Asthe last program showed, youcan changethesecolors. Your C-264 has16colors eachwith8luminancelevels (except black),so there are alot of differentcolor combinations. Here’saprogram thatshowsyouall the combinationsbychangingthe backgroundcolor to eachone.
10DO20FORC=1TO1630FORL=0TO740COLOR0,C,L50FORX=1TO100:NEXT X
60NEXTL:NEXTC
70 LOOPRUN
Here’showto change the colors toacombinationyoulike:
COLOR0,X,Ybut insteadofan X,type inthe numberofthecolor you
want,andinsteadofY, selectthe luminanceyou want.
For example:
10COLOR0,2,0
setsthe background toa dark shadeofgrey.
3.Tochange the color of the characters,type this:
COLOR1,X,Ybut insteadof an X,type inthe number of the color you
want, and insteadof Y,selectthe luminanceyou want.
For example:
10COLOR1,3,7
setsthe charactersprintedto red.
83
Page 90
USINGTHESEMICOLON
The semicolonisveryimportant inBASIC. Sometimesitmight betheanswer toone ofthose sticky programmingproblems.
The semicolonprevents BASICfrom moving the cursor tothe beginningofthe next line afterexecutinga statement. AcommonuseiswhenyouCLEARTHESCREEN.
Trythis:
10PRINT"<SHIFT><CLR/HOME>"
20 PRINT’TITLE”
RETURN
RETURN
Type RUN and press RETURN. Whathappens? Theword TITLEappears inthe upper leftcornerof your screen ...but it’sONELINEDOWNFROMTHETOP! WheneveryouCLEARthe screen, the next itemyouPRINTwillautomaticallyappear onthe secondline fromthe topof the screenUNLESSYOUUSE ASEMICOLON.
Now, addasemicolonto the endof Line 10,like this:
10PRINT"<SHIFT><CLR/HOME>";
RETURN
Type the wordLIST andpress RETURNto see thenewprogram, thentypetheword RUNandpressRETURN. Theword TITLEappears onthe TOPline!Of course, the same techniqueworkswitharealtitle,and that’sone of thesemicolon’sprogramminguses.
Youcan eliminatethe needfor the semicolonand saveyourselfsomeprogrammingspaceifyouinclude the CLEARSCREENcommandinquotationmarks along withthe messageyou’rePRINTing, like this:
10PRINT"<SHIFT><CLR/HOME>TITLE”
ThisautomaticallyPRINTs the wordTITLEonthe first line becausethe
CLEARSCREENcommandand word you want to PRINTare combinedonthe same line.
Page 91
PRINTINGGRAPHICSSIDE-BY-SIDE
Let'sexploreanother use ofthe semicolon, this timewithgraphics. Typetheword NEWand press RETURN. Wewant toPRINT40 hyphensacrossthescreen, to maKeanattractiveborder or dividing line betweentwoparts of aprogram we’rewriting. There are twoways. Onewayisto type all40symbolsinLine 20,like this:
InLine10weCLEARthe screen, PRINTaprompt message, thenprovide anINPUTVARIABLEwhichwecall N$(the variable wechoseisarbitrary; itcouldjust aseasilybe anotherlegal stringvariable namelike A$,XY$orNN$).InLine20weCLEARthe screenagainandPRINTanother message,thistimeusing the namethat wasinput. Here, N$, whichisthename theuser typedin,isPRINTedbecauseN$equalswhatever theuser typed in.Butwhatif youdon’twant to use a questionmark forthe INPUTdata? Whatifyou want tohavethe user type ina LISTOFITEMS(like aninventory list, forexample, orsome business data)? Here’saveryhelpful technique:
10OPEN3,0
20 PRINT*<SHIFT><CLR/HOME>NAME:”;:INPUT#3,N$
30 PRINTCHR$(13) “YOURNAMEIS”N$40CLOSE3
Line 10:Weopen device number 0,whichisthe keyboard. Thekeyboard has adevice numberjustlike aDatasette, disk driveor printer (the Datasettedevicenumberis1,the singledisk devicenumber isnumber 8and theprinter isnumber4).Openingthe keyboard lets yougetinput whilesidesteppingsomeof the built-in functionslike the automaticquestionmarkwhichappears whenyouusually program anINPUTstatement.
Line 20:Herewe CLEAR the screenagainand PRINTaprompt messagewhichisNAME:— thenweprovide forthe INPUTof the name whichwedesignateN$. INPUT#3isthe same asour usual INPUTstatementexceptweare now INPUTTINGtothe screensoweadd the #asshown.
Line 30:The namewhichwas typedin(N$) isincludedat the end of oursimplePRINTstatement.
1
1
ii
J
1
JJJ
1
JJ
j
JJ
86
Page 93
USINGCOMMODOREBUSINESSGRAPHICS
Your Commodorecomputerhasa fullsetofkeyboard graphicsthat includean excellentset of businessgraphics. Thesespecial lines and blockslet youcreatea widevariety of chartsandgraphs. Here’sa quick lessoninhow toset upyour screenusing thesegraphics:
To getthis symbolhold downthe shiftkey and pressthe
Three useful functions whichareseldomexplainedinuser’sguidesare theSTRINGFUNCTIONS.Thesefunctionslet youdefineastring of characters,letters, numbersorgraphic symbols inside QUOTATIONMARKS,and thenworkwithanypart of the informationcontainedinthat string. Thebest waytodescribe how thesefunctionswork isto giveyouanexample:
10SCNCLR20C$=“HELLOGOODBYE”30 PRINTLEFT$(C$,5)40PRINTRIGHT$(C$,7)50 PRINTMiD$(C$,4,3)60 PRINT“GOODSTARTS IN POSITION”;INSTR(C$,"GOOD")70MID$(C$,4,3) =“RUG”:PRINTMID$(C$,4,3)
Type RUNandpress RETURN. There are three words displayed. TheyallcamefromtheC$ string letterswedefinedinLINE20.
LINE10CLEARs the screen.
LINE20 definesthe stringvariable C$ as agroup of letterscontainedbetweenthe quotationmarks. Theseletterscouldalsobe numbers or
graphic symbols.
LINE30shows how LEFT$ works. PRINTLEFT$(C$,5) means: PRINTthefirst5characterscontainedinC$. Thefirst 5characters formthe word HELLO.
LINE 40 shows how RfGHT$works.PRINTRIGHT${C$,7) means: PRINTthelast 7characterscontainedinC$. The last 7charactersformthewordGOODBYE.
LINE50shows how MID$works. PRINTMID$(C$,4,3) means: PRINTthreecharactersfromC$, startingwiththe FOURTHCHARACTERFROMTHELEFT. The fourth character isanL.PRINTingthree charactersfrom thatposition displays the word LOG.
LINE60shows how yoij can use the INSTRfunctiontosearchforawordinanother string.
LINE70 shows how youcan change the definitionofthe middleof astringusing the MID$function.
I
i
i11
1
1J
1
J
Ii
J
i
J
JJJ
88
Page 95
AMORECOMPLEXPROGRAM(GOSUB, LEFT$)
Here’sa differentconstructionof the program wejustran.Payclose
attentiontothis examplebecauseitmayhaveapplicationsto your own
TheGOSUBcommandsat the end ofLINEs30and 40tell the computertojumptoTHESUBROUTINEcontainedon the lines shown. For example,GOSUB1000meansgoto Line 1000and perform the actionthere. Inthiscase, LINE1000displays the messageGOODand plays the sound effect.TheRETURNcommandaccompaniesthe GOSUB. ActuallyRETURNtellsthe computerto go back totheend of the linewhereitcamefromandcontinueonthrough the program. Soif the user types aYforyes, themessageand toneinLINE30 areprovided, thenthe program RETURNs toLine 30andcontinuesdownthroughLine 40(nobody pressed Nsonothinghappens inLine 40)...to Line 50wherethismessageisdisplayed. TheGOSUBand RETURNfeatures inLINE40work justlike LINE30.
TheENDcommandisneededbetweenthe part of the program withtheGOSUBand the LINEscontainingthe actualsubroutine. Lineswithsubroutineslike those inLINEs1000and 2000 should alwaysbe relativelyhigh program line numbers so youhavespace tofit your program.
Wecan improve the program abit. Bynow youshouldn’tneedthe detailed
One offhemostcommonbeginningsforprogramsisamenu.A menuisju§talistofoptionsthatyouchoosefrom.Here isa simpleprogramthatprintsamenuon thescreenandthenpromptsyouforyourchoice.
Lines10through 60display the titleMENUand the three selections.
Line 70promptsyoufor anumber from 1to3.Line 80uses anew commandcalledON..GOSUB. ThiscommandwillGOSUB100,200 or 300 dependingon thevalueofA.ItwillGOSUB100ONA=1,GOSUB200 ONA=2,andGOSUB300 ONA=3.
Line 90makes the programwait for alittlewhileand thengoback tothebeginning.
Lines 100through 300 makethe circle, the sound, andend the program.
Page 97
CATCHINGERRORS
Thisprogram demonstratesa verypowerful toolthat isbuiltinto theC-264.ThistooliscalledERRORTRAPPING.Thismeansthat if an error occursina
program you cankeep theprogram from crashing. Type the followingprogram into your computer:
20INPUT“TYPEANYNUMBER";A
30PRINT“32/A ="32/A
40PRINT“THEEND”50 END
Run this programacoupleof timeswithdifferentnumbersto be sure that it
works. Nowenterazero asthe number. You getan error and theprogram
Nowrunthe program and entera zero. Theprogramnowtraps the errorbeforetheprogram can crash. Hereiswhatthe commandsare:
Line 10setsthe trapand saysthatif an error occurs, go to line 1000.
Line 1000checkswhicherroroccurred(IFER=20).If the error isDIVIDEBYZERO, a warningmessageisprinted. Thenext commandisRESUME.Thisstartsthe program backupagain. Thenumber afterthe RESUMElsthe linenumber wherethe program will restart.
Line 1010prints out theerror and line number ofany other errorsthat occur.
Page 98
COMMODOREFUNCTIONKEYS
The COMMODOREFUNCTION KEYSatthetopofyourCOMMODORE264keyboardareamongthemostuseful featuresofyourcomputer.
Herearejust afew ofthe ways the COMMODOREFUNCTIONKEYS can beused:
•Software developers use thesekeys to definespecial functions thatmaketheirsoftware easierto use. MostCOMMODORESOFTWAREusesthesekeys,includingthe HELPkey, whichgives youinstructions ifyoumakeamistakeor haveaquestionwhileusinga softwareprogram.
•Youcanuse these keys toLOAD, SAVE, RUN and edityour ownBASICprograms becausethe keysare programmedwhenyou turnontheCOMMODORE264.
•Mostimportant —youcan program thesekeys yourselftomeet yourownneeds asyouprogram.
Thosethree functions of the keysareexplainedelsewhere. But howdoyou
use theminyour own programs? Havingto checkfor anentiremessage willbog yourprogram down. Fortunately the answer iseasy.Wecan reprogramthe functionkeystomatchthe functionkeys onthe Commodore64and
VIC-20. fThisalsomakesprogram conversions from those machineseasier).
To reprogram the keys,put the followingline into your program:
10FORK=1TO8:KEYK, CHR$(K+132):NEXT
That'sallthere isto it.Nowwhenever youtype afunctionkey,itsends anon printing character,from 133to140,just like the Commodore64. Tocheckforthis inaprogram, youcan use this method;