start tok64 d64-2EYN2z 0 RUN00100 1 REM"{delete*6} 2 REM"{delete*6}ponzo*1983*waterloo 3 REM"{delete*6} 100 POKE53281,15:POKE53280,12:PRINT"{black}":PRINT"{clear}{space*14}{reverse on}{blue}c64 tutor-2 101 PRINT"{red}{cm a}{sh asterisk*37}{cm s}" 102 PRINT"{sh -} {reverse on}{blue}{space*10}more c64 basic{space*11}{red}{reverse off} {sh -}":ms$=" welcome! " 103 PRINT"{red}{cm z}{sh asterisk*37}{cm x}{black}" 104 sn$="1{0*3}":GOSUB63200:GOSUB63600 105 GOSUB60000:GOSUB59000 1000 GOSUB60000:GOSUB20000 1005 PRINT"{clear}in this,the 2nd part of "CHR$(34)"tutor"CHR$(34) 1010 PRINT"we'll talk about the manipulation of" 1020 PRINT"{space*2}strings." 1030 PRINT"{space*2}{cm y*7}" 1040 PRINT"{reverse on}recall{reverse off}: any variable whose name ends" 1050 PRINT"with a $ is interpreted as a string" 1060 PRINT"of symbols, and not a number or an" 1070 PRINT"instruction." 1080 PRINT"{down}so..the statement:" 1090 PRINT"{down}{reverse on}a$="CHR$(34)"123*456/789"CHR$(34) 1100 PRINT"{down}means that a$ is that set of symbols!" 1110 PRINT"{space*14}{cm y*2}" 1120 PRINT"(..and i certainly won't evaluate a$)" 1130 PRINT"{space*25}{cm t*8}" 1140 PRINT"now, one very nice set of symbols is:" 1150 PRINT"{down}{cm g} {cm h} {cm j} {cm k} {reverse on}{cm l}{reverse off} {reverse on}{cm l}{reverse off} {reverse on}{cm n}{reverse off} {reverse on} {reverse off}" 1155 PRINT 1160 PRINT"we'll call them s$(1), s$(2),..,s$(8)" 1170 GOSUB63000 1190 PRINT"{clear}we'll type:":PRINT 1200 PRINT"10 s$(1)="CHR$(34)"{cm g}" 1210 PRINT"20 s$(2)="CHR$(34)"{cm h}" 1220 PRINT"30 s$(3)="CHR$(34)"{cm j}" 1230 PRINT"40 s$(4)="CHR$(34)"{cm k}" 1235 PRINT"50 s$(5)="CHR$(34)"{reverse on}{cm l}{reverse off}" 1240 PRINT"60 s$(6)="CHR$(34)"{reverse on}{cm n}{reverse off}" 1250 PRINT"70 s$(7)="CHR$(34)"{reverse on}{cm m}{reverse off}" 1260 PRINT"80 s$(8)="CHR$(34)"{reverse on} {reverse off}" 1261 PRINT"{space*12}^that's rvs-off" 1270 PRINT"strange?" 1280 PRINT"well, the 1st 4 are on the keyboard." 1290 PRINT"the last 4 are obtained by {reverse on}rvs{reverse off}ing" 1300 PRINT"the characters{sh asterisk*5}>{space*2}{cm l},{cm n},{cm m},and{space*2}" 1310 PRINTSPC(32)"^" 1320 PRINTSPC(31)"{reverse on}that's a" 1330 PRINTSPC(31)"{reverse on}space.{space*2}" 1340 PRINT"{up*2}note that we turn" 1350 PRINT"the rvs off too!" 1360 PRINT"{space*8}{cm t*3}" 1370 PRINT"also..we don't need the last quotes." 1380 PRINT"i'll understand the "CHR$(34)"return"CHR$(34) 1390 PRINT"to mean the end of the statement." 1400 PRINT:GOSUB63000 1420 PRINT"{clear}now i'll print the statements #10-80" 1430 PRINT"again, and you can move the c'sor to" 1440 PRINT"to #10, then keep pressing return," 1450 PRINT"so i'll think you typed them,and i'll" 1460 PRINT"remember them.{cm t*3}" 1470 PRINT"{cm t*8}" 1500 PRINT"10 s$(1)="CHR$(34)"{cm g}" 1510 PRINT"20 s$(2)="CHR$(34)"{cm h}" 1520 PRINT"30 s$(3)="CHR$(34)"{cm j}" 1530 PRINT"40 s$(4)="CHR$(34)"{cm k}" 1535 PRINT"50 s$(5)="CHR$(34)"{reverse on}{cm l}{reverse off}" 1540 PRINT"60 s$(6)="CHR$(34)"{reverse on}{cm n}{reverse off}" 1550 PRINT"70 s$(7)="CHR$(34)"{reverse on}{cm m}{reverse off}" 1560 PRINT"80 s$(8)="CHR$(34)"{reverse on} {reverse off}" 1570 PRINT:PRINT"when you've done that, type:" 1580 PRINT:PRINT"list10-80" 1590 PRINT:PRINT"..so you'll be sure i got them!" 1600 PRINT:PRINT"{space*5}(to continue{.*3}{reverse on}type @{reverse off})" 1700 sn$="02{0*3}":GOTO63400 2000 GOSUB60000 2001 DIMd$(12),v(12) 2006 d$(1)="jan":d$(2)="feb":d$(3)="mar":d$(4)="apr" 2007 d$(5)="may":d$(6)="jun":d$(7)="jul":d$(8)="aug" 2008 d$(9)="sep":d$(10)="oct":d$(11)="nov":d$(12)="dec" 2110 v(1)=10:v(2)=15:v(3)=20:v(4)=25:v(5)=30:v(6)=31 2120 v(7)=25:v(8)=20:v(9)=15:v(10)=12:v(11)=11:v(12)=10 2130 FORi=1TO12:PRINT"{reverse on}"d$(i)"-"STR$(v(i))"{cm m}"; 2140 FORj=1TOv(i):PRINT"{reverse on} ";:NEXT 2150 PRINTs$(8*(v(i)-INT(v(i)))):NEXT 2160 FORi=1TO500:NEXT 2170 PRINT:PRINT"{space*4}nice?" 2175 FORi=1TO500:NEXT 2180 PRINT:PRINT"{space*2}let's try it!" 2190 FORi=1TO500:NEXT 2200 PRINT"first, we'll define the strings:" 2201 PRINT 2210 PRINT"m$(1)="CHR$(34)"jan"CHR$(34) 2220 PRINT"m$(2)="CHR$(34)"feb"CHR$(34) 2229 PRINT 2230 PRINT"..etc." 2240 GOSUB63000 2250 PRINT"{clear}" 2260 PRINT"..actually, just to demonstrate another" 2270 PRINT"talent of mine, we'll do it this way:" 2280 PRINT:PRINT"100 data "CHR$(34)"jan"CHR$(34)","CHR$(34)"feb"CHR$(34)","; 2290 PRINTCHR$(34)"mar"CHR$(34)","CHR$(34)"apr"CHR$(34)","CHR$(34)"may"CHR$(34) 2295 PRINT"101 data "CHR$(34)"jun"CHR$(34)","CHR$(34)"jul"CHR$(34)","; 2296 PRINTCHR$(34)"aug"CHR$(34)","CHR$(34)"sep"CHR$(34)","CHR$(34)"oct"CHR$(34) 2297 PRINT"102 data "CHR$(34)"nov"CHR$(34)","CHR$(34)"dec"CHR$(34) 2350 PRINT:PRINT"these "CHR$(34)"data"CHR$(34)" statements" 2360 PRINT"define a number of strings, called" 2370 PRINT"jan,feb,mar,etc.." 2380 PRINT"now type:" 2390 PRINT:PRINT"{reverse on}103 fori=1to12:read m$(i):next" 2400 PRINT:PRINT"this "CHR$(34)"reads"CHR$(34)" the data statements and" 2410 PRINT"assigns the string "CHR$(34)"jan"CHR$(34)" to m$(1)," 2420 PRINT"and the string "CHR$(34)"feb"CHR$(34)" to m$(2)..etc." 2425 GOSUB63000 2430 PRINT"{clear}you'll have to tell me how many of the" 2440 PRINT"{down}m$(1),m$(2),etc. you have, so i can" 2450 PRINT"{down}leave room for them in my memory," 2460 PRINT"{down}so you'll need a statement:" 2470 PRINT"{down}{reverse on}90 dim m$(12)" 2480 PRINT"{down}this says: the dimension of the array" 2490 PRINT"{down}of strings called m$(i) is 12" 2500 GOSUB63000 2519 PRINT"{clear}{.*3}altogether now!":PRINT 2540 FORi=1TO500:NEXT 2570 PRINT"{reverse on}90 dim m$(12){space*19}" 2580 PRINT"{reverse on}100 data jan,feb,mar,apr,may,jun" 2600 PRINT"{reverse on}101 data jul,aug,sep,oct,nov,dec" 2610 PRINT"{reverse on}102 fori=1to12:read m$(i):next{space*2}" 2620 PRINT"{down*2}note{down}{left*4}{cm u*4}{up}:if {reverse on}all{reverse off} the data are strings" 2625 PRINT"{down}then you can omit the quotes!" 2630 PRINT:PRINT"(don't enter the statements just yet)." 2640 GOSUB63000 2650 PRINT"{clear}now you'll want to input the 12 values" 2660 PRINT"which give the length of the bars." 2670 PRINT"type:" 2680 PRINT"{down}105 for i=1to12{space*3}" 2690 PRINT"110?m$(i)"CHR$(34)" value="CHR$(34) 2700 PRINT"120 input v(i){space*4}" 2705 PRINT:PRINT"note that#110 will print a prompting" 2706 PRINT"{space*2}remark, such as:" 2707 PRINT:PRINT"jan value=?" 2708 PRINT:GOSUB63000 2710 PRINT"{clear}{down}Qsince you'll print 150 of s$(8)={reverse on} {reverse off}" 2720 PRINT"(if an input value is 150)and i've" 2730 PRINT"got only"wd" columns on my screen(!)," 2740 PRINT"you'd better reduce all the values" 2750 PRINT"so the largest is,say,30." 2760 PRINT"so..you'll have to find the largest." 2761 PRINT"{space*19}{cm y*4}" 2770 PRINT"{down}Qyou see,we're going to print a "CHR$(34)"bar"CHR$(34) 2780 PRINT"with a length proportional to each v-" 2790 PRINT"input,and we'll do this by printing a" 2800 PRINT"number of {reverse on} {reverse off}{arrow left}these,and they're s$(8)" 2810 PRINT"{.*3}remember?" 2820 GOSUB63000:PRINT 2830 PRINT"{down}we'll type:" 2840 PRINT"{down}104 maxv=0" 2850 PRINT"130 if maxv"CHR$(34)CHR$(34)"then100" 15115 PRINT"{down}this will 'get' a character until the " 15120 PRINT"{down}buffer is empty." 15125 PRINT:GOSUB63000 15130 PRINT"{clear}{down}during {reverse on}tutor{reverse off} you may have noticed:" 15135 PRINT"{down}'hit {reverse on}return{reverse off} to continue{reverse off}'." 15140 PRINT"{down}the little subroutine which prints" 15145 PRINT"{down}this at the bottom of the screen.." 15146 PRINT"{down}then waits!..is:{down*2}" 15150 GOSUB63000 15165 PRINT"{clear}":ms$="{reverse on}au revoir!{reverse off}":GOSUB63100:GOSUB63500:PRINT"{home}" 15170 LIST63000-63003 20000 PRINT"{clear}" 20005 PRINT"{clear} before i forget, i should introduce" 20010 PRINT"{down}my friend"CHR$(34)"cursor"CHR$(34)"." 20015 FORi=1TO1000:NEXT 20016 wd=80:POKE32768+1024,96:IFPEEK(32768)=96THENwd=40 20020 PRINT"i call him {reverse on}crsr{reverse off} for short." 20025 FORi=1TO1500:NEXT 20030 PRINT"{down}come on crsr..don't be shy." 20040 FORi=1TO2000:NEXT 20050 FORi=1TO10 20060 PRINT"{down}";:NEXT 20070 PRINTSPC(14); 20080 FORi=1TO8:FORt=1TO50:NEXT 20090 PRINT" {left}{up}{reverse on} {reverse off}{left}";:NEXT 20100 FORi=1TO500:NEXT 20110 PRINT"{right} {arrow left}that's him" 20120 csr=32768+8*wd+14:FORi=1TO100:POKEcsr,32:POKEcsr,160:NEXT 20130 PRINT"{down}then we have crsr-left"; 20140 PRINT"{space*3}"CHR$(34)"{left}"CHR$(34) 20141 FORi=1TO500:NEXT:PRINT 20150 PRINT"and crsr-right"; 20160 PRINT"{space*5}"CHR$(34)"{right}"CHR$(34) 20161 FORi=1TO500:NEXT:PRINT 20170 PRINT"and crsr-up"; 20180 PRINT"{space*5}"CHR$(34)"{up}"CHR$(34) 20181 FORi=1TO500:NEXT:PRINT 20190 PRINT"and crsr-down"; 20200 PRINT"{space*5}"CHR$(34)"{down}"CHR$(34) 20201 FORi=1TO1500:NEXT:PRINT 20210 PRINT"(all brothers,of course)." 20215 FORi=1TO1000:NEXT:PRINT 20220 PRINT"we also have home"; 20230 PRINT"{space*4}"CHR$(34)"{home}"CHR$(34) 20231 FORi=1TO200:NEXT 20240 PRINT"..and clear{space*2}"; 20250 PRINT"{space*4}"CHR$(34)"{clear}"CHR$(34) 20251 FORi=1TO200:NEXT 20260 PRINT"..and rvs{space*5}"CHR$(34)"{reverse on}"CHR$(34) 20261 FORi=1TO200:NEXT 20270 PRINT"..and rvs-off{space*4}"CHR$(34)"{reverse off}"CHR$(34) 20280 FORi=1TO500:NEXT:PRINT 20290 PRINT"{>*3}get to know them{<*3}" 20295 FORi=1TO200:NEXT:PRINT 20300 PRINT"inside quotes,they do their thing." 20400 FORi=1TO500:NEXT:PRINT 20500 GOSUB63000:RETURN 23360 GOSUB63000 59000 PRINT"{clear}":GOSUB63100 59001 PRINT"{home}during the tutorial you may wish" 59002 PRINT"{down}to return to an earlier 'page'." 59003 PRINT"{down}just {reverse on}hit the @-key{reverse off}, at any time," 59004 PRINT"{down}and the tutorial will back up" 59005 PRINT"{down}a page or two." 59006 PRINT"{down}also, you have an opportunity to" 59007 PRINT"{down}compose your own programs." 59008 PRINT"{down}when you wish to continue with" 59009 PRINT"{down}the tutorial, {reverse on}hit the @-key{reverse off}!":GOSUB63000 59010 ms$="{reverse on}@{reverse off}{arrow left}remember":GOSUB63100 59020 GOSUB63000:RETURN 60000 POKE204,1:REM initialize 60001 bt$="{home}":FORi=1TO24:bt$=bt$+"{down}":NEXT 60002 pt$="{red}{cm a}{sh asterisk*10}{cm s}{down}{left*12}{sh -}{right*10}{sh -}{down}{left*12}{cm z}{cm r}{sh asterisk*8}{cm r}{cm x}" 60003 pt$=pt$+"{down}{left*13}N{cm t*12}M{down}{left*14}{cm g}{=*12}{cm m}" 60004 pt$=pt$+"{down}{left*14}PO{cm t*10}PO{up*4}{left*12}" 60005 pt$=bt$+"{up*6}{right*26}"+pt$+"{black}" 60007 ml$="{home}{down*9}{right*27}" 60008 wd=40:crt=1024:PRINTCHR$(142) 60009 w2=wd/2:w3=wd-1:w1$=MID$(STR$(wd),2): 60010 w2$=MID$(STR$(w2),2):w3$=MID$(STR$(w3),2) 60020 PRINT"{clear}":POKE53281,15:POKE53280,12:PRINT"{black}" 60998 IFPEEK(789)<>7*16+15THENSYS(7*4096+15*256+12*16+3) 60999 RETURN 61000 REM*new workspace 61001 m=7*4096+15*256+15*16 61002 RESTORE 61003 FORi=mTOm+15:READk:POKEi,k:NEXT 61004 DATA 1,96,3,96,3,96,3,96 61005 DATA 144,127,0,0,144,127,0,0 61006 m=6*4096:FORi=0TO2:POKEm+i,0:NEXT 61007 RETURN 63000 PRINT"{home}{down*23}hit {reverse on}return{reverse off} to continue"; 63001 GETa$:IFa$<>""THEN63001 63002 GETa$:IFa$=""THEN63002 63003 PRINT:RETURN 63100 FORt=1TO5:PRINTpt$ms$; 63101 PRINTpt$"{space*10}"; 63102 PRINTpt$ms$;:NEXT 63103 PRINT:RETURN 63200 POKE56,96:POKE52,96:POKE55,0:POKE51,0:GOSUB61000 63201 wd=40:PRINTCHR$(142) 63202 m=7*4096+15*256+9*16 63203 FORi=mTOm+91:READk:POKEi,k:NEXT 63204 DATA165,203,201,46,208,83,32,195,127,165,44,201,8,240,3,32,177,127,32 63205 DATA142,166,165,44,201,8,240,3,76,128,164,76,174,167,162,16,189,239 63206 DATA127,72,181,42,157,239,127,104,149,42,202,208,241,96,120,173,238,127 63207 DATA77,20,3,141,20,3,173,239,127,77,21,3,141,21,3,88,96,173,20,3,73 63208 DATA144,141,238,127,173,21,3,73,127,141,239,127,96,76,255,255 63216 POKEm+90,PEEK(788):POKEm+91,PEEK(789) 63220 key=7*4096+15*256+13*16+8 63221 SYS(key):REM key for irq swap 63299 RETURN 63300 REM*switch to new workspace 63301 GOSUB63600:REM run number 63302 GOSUB61000:REM new the workspace 63303 GOTO63403 63400 REM*switch to old workspace 63401 GOSUB63600 63403 swtch=7*4096+15*256+9*16+15 63404 SYS(swtch):REM swap pointers 63405 POKE204,2:END 63500 REM*restore pet 63501 sn$="100":GOSUB63600 63502 m=7*4096+15*256+12*16+3:IFPEEK(789)=7*16+15THENSYSm 63503 RETURN 63600 REM*insert run number 63601 m=2059:sn$="{0*5}"+sn$ 63602 FORi=1TO5:POKEm-i,ASC(RIGHT$(sn$,i)):NEXT:RETURN stop tok64 (bastext 1.0)