JOYTemplate for Letters group è ÿÿà�dà�2–o×ì‘I”tyßÐ pXh¥{…òI” Lø"ɾ”z ¶k Z-–K¥Òi´Z-–K: Nä"Õ¦I…` ¶{x R< Nä"Õ¦I…` ¶{x R<Lï$ЦI”z ¶yx ULï$ЦI”z ¶xx ULï$ЦI”z ¶x ULï$ЦI”z ¶~x ULï$ЦI”z ¶}x ULï$ЦI”z ¶|x ULï$ЦI”z ¶sx ULï$ЦI”z ¶rx U€ xScript 1: 0x R< È@ è˜ZBASIC.TIP(S)File $ÐAuthorS.W.Keen1988, ^TheElms,KimblewickRd,Gt.Kimble,Aylesbury,Bucks,HP178TDAsausertoZedcorZBasic,IhavewrittenthistipsandhintsfiletoaidPCWusersoftheP.D.versionZBDEMO.COM.   Mh 0˜ #`DISCCONTENTS ZBDEMO.COMandZBASIC.HLPareZBasicfiles.ZBASIC.HLPisaccessedfrom<ZBDEMOsimplybytypinghelp.Thehelpfilethendisplaysalistofthevarioustopicscovered.ZBASIC.TIPisaLocoScriptdocumentdcontainingvarioustipsandtricksforusingZBDEMO.AccessthisbystartingLocoScript,select"changedisc",insertthisdiscandpressPÄtoprintit ŒFIND$.ZASisaroutinewhichchecksthediscdirectorytofindaPspecificfile,anddemonstratestheprinciplesofZBasicdiscerrorìtrapping.ZMODE2.ZASisaprogramwhichdoesanumberofstatisticaltestsondataÈstoredinanarrayandprintsthetimetakentodothesetestsVALL.ZASisaroutinetocheckfornumbersinstringinputsDATABASE.ZASisarandomaccessfiledemostrationprogram,DATABASE.DAT€isthedatathattheaboveprogramreadsSEQUENCE.ZASisaroutinetofiletheendoffilemarkerinsequentialaccessfiles,SEQUENCE.DATisthedatafilethattheaboveprogramreads<BRIKBAT.ZASisagame.Usetheleft&rightcursorkeystocatchthexfallingbricks,BRIKBAT.COMistheaboveprogramaftercompilationGRAFIX.ZASisademoofsometherudimentarygraphicsavailableonthedPCWŒSLIKMENU.ZAShowtodoLocoScriptstylepulldownmenusinZBasic TORUNANYOFTHE.ZASFILESFROMTHEZBASICEDITOR,SELECTEFROMTHEPMENU,ANDTHENENTERLOADFILENAME.ZAS(MUSTBEINCAPITALS) DThelastprogramsarehandyP.D.utilities:D.COMdoesaDIR[SIZE]andSHOWsimultaneouslyUNERA.COMwillunerasefilesiftheyarestillhiddeninthedirectory.ôSimplysayUNERAprogname.typtorecoverafileÀ xScript 1: 0x R< ÈFIP.COMislikePIP.COMbuthasmenusandcangiveadirectoryoferased<files0CLS.COM&CLS.ASMclearthescreenfromCP/M<PAUSE.COM&PAUSE.ASMwritesReadyonthescreenandwaitsforakeyDpress,handyforpromtingdiscchangesetc. À ¨˜TEXTNOTES meansakeyonthekeyboardPWhendiscussingZBasiccommands,optionalcommandsareshowninsideL[squarebrackets]0X,variable$andvariablearevariablenames”ZBasiccommandsareshowninUPPERCASE  €P€ xScript 1: 0x R< ÈÐ 0˜GETTINGSTARTED dZBDEMO.COMistheP.D.versionofthefullblowninteractiveBASIC<compiler,whileZBASIC.HLPisahelpfilewhichcanbeaccessedfrom<withinZBasic,howeverZBDEMO.COMistheonlyfilerequiredtowrite¬yourownBASICprograms.ThemajordrawbackoftheP.D.versionisthatitdoesNOTallowyoutoXsavecompiledcodetodiscasa.COMfile. Ð  0TEXTISCOMPILEDINTHEMEMORYONLY. dAsZBasicexistsinvariousformsformanydifferentcomputersandoperatingsystemsyoumustfirstconfiguretheZBdemofiletosuitthePCW(seeCONFIGUREFORPCW).ThisisdonebyrunningZBDEMO,whenthisdhasloadeditprintsamessagestatingthelimitationsoftheP.D.„version,andoffersamenu.   Mh � �˜ZBasicMENU YouentertheprogrammingareabyselectingtheEoption,andthenkeyinyourprogramtextasusual,butnotethattheZBasiceditordoesn't(usethespecialPCWkeyssuchasetc(seeEditorCommands).TORUNANYOFTHE.ZASFILESFROMTHEZBASICEDITOR,SELECTEFROMTHEMENU,ANDTHENENTERLOADFILENAME.ZAS(THECOMMANDANDFILENAMEMUSTÔBEINCAPITALS) PisthePatchoptionwhichallowscleverpeopletomodifythecontentsofmemoryaddresses.Don'tworryaboutthisbitunlessyouareheavily intoJumpTablesandMemoryMaps. WistheZwarm"warmstart"filecreator.Ihavefoundthisveryuseful,asoverenthusiasticuseofthekeycancrashZBasicanddropyoudthru'toCP/M,meaningthatyourprogramcodeisstranded,andyou<destroyitwhenyourestartZBasic,howeverZwarmstartsZBasicinaðslightlydifferentwaysoyoucanrecoveryourprogramtext. ¬CreateZwarmasfollows:AfterConfigure,Savethechangesasdescibedabove,typequittoreturntoCP/MandthenrestartZBasicbytypingzbdemoand8€ xScript 1: 0x R< ÈthenselectWfromthemenuandthenSaveitasZWARM.COM.(Then,ifyoucrashoutofZBasic,justtypezwarmtorestart<ZBasic,pressEtoentertheeditorandpressLtoLISTyourprogram<text.TheSoptionallowsyoutosavethechangesmadetoZBDEMOafterusing¨theC,PorWoptionsdescribedabove.         €@€ xScript 1: 0x R< ÈÀ (˜CONFIGURINGZBasicFORPCW Atthispoint,selectCtoConfigurewhichmeansansweringaseriesofquestionsconcerningyourparticularchoiceformathsaccuracyetc,andthehardwarecodesforcontrollingthescreen. €Configureasksthefollowingquestions: <Doubleprecisionmathsthemaximumlengthofdoubleprecisionmathsð  h ¸  Xis54butforspeedsetthisto6DSingleprecisionmathsforspeedsetto4HScientificmathsditto(MaxBufferssetto1,becauseZBDEMOwon'tallowyouopen�  h ¸  Xmorethan1fileatatime(ArrayBase ¸  XforcompatabilitywithMallardBASICsetto0ŒRoundingNumber  XsetstheroundingfactorforPRINTUSINGüDefaultVariableTypeŒSingle,DoubleorIntegerforspeedchooseIntegerandmarkreal  h ¸  Xnumberswithinyourprogramsusing!(Single)(  h ¸  Xor#(Double)oruseDEFSNGorDEFDBLatthe   h ¸  XstartdTestArrayBounds Xthischecksforarrayoverflow,chooseY<ConverttoUppercaseifyouchooseNthenyouMUSTtypeinBASICŒ  h ¸ keywordsincapital.TheYoptionwill  h ¸  X"capitalise"alltextthatyoutypeBUTyouared  h ¸  Xnotallowedtoembedkeywordsinvariable<  h ¸  Xnamesi.e.totalisnotallowedbecauseitx  h ¸  XcontainsthekeywordTO.TheYoptionis<  h ¸  Xprobablyeasiertousebutbecarefulwith€  h ¸  XvariablenamesŒDefaultCLEARsizeThisisusedbyaspecialZBasicarray(  h ¸  XcalledINDEX$.ZBDEMOonlyallowsyou2kforŒ  h ¸  XINDEX$.Suggestyoujustpress x xScript 1: 0x R< ÈClearScreenStringenter&451B.ThisisthePCWcodeCHR$(27)"E"ClearEndofLineenter&4B1B."""""CHR$(27)"K"ClearEndofPageenter&4A1B."""""CHR$(27)"J"CursorOffenter&661B."""""CHR$(27)"f"CursorOnenter&651B."""""CHR$(27)"e"�ListPreviousLineChooseakey,sayuparrow¤ListNextLine""""downarrow¤List1stLine""""leftarrow�ListlastLine""""rightarrow¤Findnextoccurence""""semicolon(Print@stringenter&591B.ThisisthePCWcodeCHR$(27)"Y"OverlayOffsetbecausethisversiondoesn'tsupportl  h ¸  Xusers.OVLfiles ThenpressStosavebutenterthefilenameinUPPERCASE.  Ð 0˜EDITORCOMMANDS <UseltoLISTyourprograms,l100liststoline100,l100200listsPlines100to200,l"subroutine"liststhelabelledsubroutine,l+ �P€€ xScript 1: 0x R< Èxlistswithoutusinglinenumbers(usethistoimpressyourPascalØfriends!). <Usee10toeditline10.Presstodisplayeachcharacter,Ðnumberformultiplemoves. lCtoChangetocharacterunderthecursor Press< óDEL>tobackspaceorusenumber<óDEL>formultiplemoves,theÈthedeletekeyfunctionisswitchedoffunlessyouuseeXtend. \SXtosearchforcharacterX. ”Ddeletethecharacterunderthecursor ðD5deletethecharacterunderthecursorandthenext4too. HKXkillallcharactersuptoX œIinserttext Xjumptoendoflineandgointoisertmode. Dlinenumberdeletesthatlinenumber lDELorDELETE500deletesthatlinenumber DDELorDELETE100deletesline100onwards \orAtoabortchanges.   Mh  P p˜RANDOMPROGRAMMINGTIPS ZBasicdoesn'taddFILETYPEStoyourprograms,sospecifyyourownwhenPyouSAVE.i.e.use.ZAStodifferentiatebetweenZBasicandMallardìprograms.ŒZBasicdisablesthekey,sowhendevelopingprogramsalwaysstart(yourprogramswithTRONBtoenable,otherwiseyougetwellandDtrulystuckifyougetintoanendlessloop <ToclearthescreenuseCLS,howeverthisdoesn'thomethecursor.Ibelievethatitispossibletohavea4byteclear&homestringbutthis´istheonlypartoftheZBasicmanualwhichissomewhatopaque.PToclear&homedoeitherCLS:PRINT@(0,0)orPRINT@(0,0):CLSPAGEor\CLS32ifyoucanwaitallday dCLSPAGEclearsthescreenfromthecurrentposition,whileCLSLINEPclearsthecurrentlinefromthecurrentposition.CLSASCIInumber�fillsthescreenwithcharactersofthatASCIIcode. €P€ xScript 1: 0x R< È(ZBasicregardsALLmonitorscreensasbeingthesamesize,andPRINT@and[LINE]INPUT@regard0,0asthetopleftcorner.ThecoordinatesaregivenasHorizontal,Verticaltherefore80,24isthebottomrightcorner. Syntaxerrorsaredisplayedwitha0besidetheoffendingcharacterandthemissingcharacterisprintednexttotheerrormessage. (WhenyoutypeRUNthewholeoftheprogramcodeiscompiledinmemoryÜandallsyntaxischeckedthen,notaseachlineisexecuted. dZBasichasitsownprogrameditorwhichisnotspecifictothePCW<keyboardsoMallardtrickslinetogettoendofaline¼won'twork,useXtoeXtendtheline. ZBasicsupportstheusualFOR..NEXTandWHILE..WENDloopsandalsohaspDO..UNTILloops,forexample (200DOt210a$=INKEY$L220UNTILLEN(a$) Œisanelegantwayofwaitingforakeytobepressed.However,I(preferredtouseINPUT$inMallardandthisdoesnotexistinZBasic,butyoucandoitwith[LINE]INPUT!&n,a$the!meansdon'twaitforand&nmeansacceptaninputtoamaximumofncharacterslong ZBasicusestheusual*,+,,/mathssymbols,MODfindstheremainderofPintegerdivision,[orðdoexponentiationandyoucanalsodosome”mathsinBinarywhichalittlequicker. Binarymathsuses<<(2lessthansigns)todomultiplicationand>>(2<greaterthansignstododivision).UsingthismethodyoucanfindPIwiththeexpressionpi!=ATN(1)<<2inBinarymathsthe2infactmeans2tothepowerof2.Otherexamples4>>1(4/2indecimal),4<<1(4*2indecimal),904.>>6=14.15625theexpressionindecimalis904/64,notethat904isfollowed(bya"."toforcetheresulttoarealnumber,alsobeawarethatthe(numberfollowingthe<<or>>signsisforcedtointeger.InmyopionBinarymathsisn'tmuchhelpbecauseofthebrainbendingthatyoumustH€ xScript 1: 0x R< Èèdoinordertouseit. However,areallyusefulfeatureallowsyoutohavecomplexIFs,instead„ofhavingalinewhichsays 01000IFa=54thenz=12:count=1:message$="OK" tYoucandothis L1000LONGIFa=54Ø1010z=12œ1020count=1$1030message$="OK"Ø1040ENDIF �P€ xScript 1: 0x R< È OryoucanuseIF...THEN...ELSEtypelogicwiththeXELSEclause L5000LONGIFa=54Ø5010z=12œ5020count=1$5030message$="OK"Ø5040XELSEÔ5050message$="NotOK"Ä5060ENDIFpwhichismuchmorereadable. <BecauseZBasicisacompileryoudon'thavetogoformultistatementlinestoincreasespeed,gobacktoyourearlyprogrammingdaysandputüastatementperline. ZBasicindentsloopsandLONGIFsforyoutomakethemeasiertoread.dIfyoudohavealoopthatiscompletedon1linethenitputsa*againstthelinenumbersothatyoucanidentifyiteasier. PThelineeditorgenerateslinenumberstomakeiteasierforyoutoalteryourcode,butyoucanuselinelabelsforsubroutinesandifyou<mustuseGOTOthensayGOTO"start"ratherthanGOTO1500,forexample  `1000GOSUB"test"˜1010PRINT"testcompleted"Œ. .  h ¸ programcontinuesŒ.€2000"test":REMstartoftestsubroutineˆ2010a=VAL(a$)Ä2020RETURN \Linelabelsaidreadability!! <Anotherlittlepeculiarityisthatitdoesn'tconvertfilenamesintoxuppercaseorautomaticallyadd.ZASfiletypes,sowhenyouSAVEa programtypesavePROGNAME.ZASN.B.speechmarksarenotneeded. <Onthesamethought,makesurethatyourprogramsconverttheirdatafilenamesintouppercasetoofilename$=UCASE$(filename$) SequentialfilesinZBasicareverysimilartoMallardinthatyousay OPEN"O",1,filename$ŒPRINT#1,variable$","variableoruseWRITE#1,variable$;n,variableìCLOSE[#1] Ôwhichwillwriteafile $OPEN"I",1,filename$ÈINPUT#1,variable$,variableoruseREAD#1,variable$;n,variableìCLOSE[#1] �P€ xScript 1: 0x R< ÈÔwhichwillreadafile. PRINT#andINPUT#arewillreadandwriteASCIIfiles,READ#andWRITE#àareforfileswherethedatahasbeentokenised. Pnisthelengthofastring,andmustbeusedwhenstringsareused. @RandomaccessfilesarelittledifferentthaninMallard(Forexampleyoudon'thavetoLSETorRSETdataorconvertnumberstostrings/stringstonumbers.ThisconversionisintrinsicinREAD#andWRITE#. äOPEN"R",1,filename$[,recordlength]\WRITE#1,variable$;n,variableìCLOSE[#1] Ôwhichwillwriteafile äOPEN"R",1,filename$[,recordlength]pREAD#1,variable$;n,variableìCLOSE[#1] èwhichwillreadafile PYoucanpositionthedatapointertoaparticularplaceinthefile(usingthekeywordRECORD#filenumber,recordnumber[,locationinrecord] i.e.setrecordnumberto1atthestartoftheprogram,searchthru'theìfilewith xDO4 recordnumber=recordnumber+1¬ RECORD#1,recordnumberè READ#1,variable$;1ÔUNTILsearch$=variable$ pthenoverwriteexistingdata üRECORD#1,recordnumberèWRITE#1,newvariable$;1 xZbasicDIRis"passive"andonlyworksineditmodenotduringrund(anyway,thedisplayis'orrible).ThereisnotaFILESfunction. ZBasicdoesnotsupportJetsamfilingnordoesithaveaFIND$function,PhoweverfeelfreetousemyFIND$.ZASroutineincludedonthisdisc.Ifyouwanttoalterthisroutine,makesurethatyouresetERRORto0PbeforeRETURNingtothemainprogramorthesameerrormessagewillècropupoverandover. <Otherdiscerrorsareasfollows,butnotethatONERRORGOSUB65535(enablesyourownerrortrappingroutinesandONERRORRETURNdisableslthisandreturnserrortrappingtoZBasic �P€ xScript 1: 0x R< È (fERROR <° =Ä >ØMEANING ,z256 <° =Ä >Ø ?ìNoerrorinfile#1d ,z257 <° =Ä >Ø ?ìEndofFile#1 ,p258 <° =Ä >ØDiscFullinfile#1 ,z259 <° =Ä >Ø ?ìFile#1notfoundP ,p260 <° =Ä >ØFile#1notopenŒ ,z261 <° =Ä >Ø ?ìFile#1badfilename ,z262 <° =Ä >Ø ?ìFile#1badfileNo( ,z263 <° =Ä >Ø ?ìFile#1iswritePonly< ,z264 <° =Ä >Ø ?ìFile#1isreadPonly )>265512 <° =ÄDiscerrorinFile#1 àErrors513768arethesameerrorsinFile#2à"7691024""""""#3 <INDEX$isaspecialarraywhichallowsyoutoinsertanddeletedataelements.INDEX$doesn'tworkwithSWAP.SadlyIhaven'thadmuchreason¤touseINDEX$socannotofferanytipsonusingit. PRENUMrenumbersprogramlinesandusesthesameoptionalcomandsasMallard ¸Youcanuse?asshorthandforPRINTand'forREM ¼Maximumlinelengthis250characters MallardsONINSTR....GOSUBdoesn'twork.InZBasic,useINSTRtofindlthepositionononestringwithinanotherTX=INSTR(startposition,stringtosearch,stringtofind) ”UseONXGOSUBlineinmenuselections. �ZBasicdoesn'tlikecomplexstringwork,forexample ¬FORi=1toLEN(variable$)Ð variable=ASC(MID$(variable$,i,1)PNEXT äproducesaStringTooComplexerror ØInsteaddo ¬FORi=1toLEN(variable$)\ temp$=MID$(variable$,i,1)Ô variable=ASC(temp$)PNEXT XLeaveZBasicwiththecommandquit There'snosequentialaccessfileEOF,usetheroutineinSEQUENCE.ZASinstead  �È€ xScript 1: 0x R< ÈXIfyouwantadelayloopdon'tbotherwith tFORi=1to5000PNEXT PjustsayDELAY5000instead.DELAYcountsin1/1000thsofasecond,„therefore5000is5seconds Don'tbotherwithbel$=CHR$(7):PRINTbel$insteadjustuseBEEPtosound0thespeaker,justlikeonyouroldSpectrum! ZBasichasalotofgraphicscommands,unfortunatelyonlyafewworkon<thePCW,andthosethatdoaren'tveryinmpressive.Theprogramfile@GRAFIX.ZASshouldgiveyousomeideaofwhatyoucando. TheprogramfileBRIKBAT.ZASandBRIKBAT.COMshowwhatyoucandowithÌZBasicifyouwanttowritefastisharcadegames dYoucansetupyourPROFILE.SUBfiletoautomaticallytoenterthe´editor.Makethefirstcommandzbdemoandthesecondcommand