Code: Select all
0 poke 53265,peek(53265) and 239:poke 53280,6:poke 53281,6:print"{clear}";
10 print ".this is the first example of negating the problem with the string";
20 print" length in basic v2, which although it works, it does present the";
30 print" programmer with problems, which are: ";
40 print"[1] that it's slow, therefore i've switched off the screen whilst";
50 print" this text is being copied from the screen to memory @ 49152, and";
60 print " [2] essentially you have the data copied twice, once";
70 print" printed to the screen and once copied to the area of memory mentioned";
80 print" above. "
90 print"a more memory- and speed-efficient method is mentioned below...*";
100 sc=1024:m=49152
110 poke m,peek(sc):if peek(sc)<>42 then sc=sc+1:m=m+1:goto 110
120 print"{clear}":poke 53265,peek(53265)or 16
130 m=49152:i=peek(m)
140 m=m+1:if peek(m)<>42 then poke m-1,peek(m):goto 140
150 poke m-1,i:for i=0 to 39:poke 1984+i,peek(49152+i):next:goto 130
Once you run it, you'll see what I mean about the speed, and some help is needed, i.e., SuperCPU or other accelerator.
Each string variable may only be 255 characters in length, but an array may have one or more elements, so if you had a string array of four (dim a$(3) as zero would be counted as one element), then you'd have 4 x 255, or 1020 characters. As the screen may contain up to 1000 characters, this should be more than enough for our purposes. Also, you don't have the problem with repeating data with the above example. Here the listing for you to try with CBM prg studio:
Code: Select all
0 dim a$(3):poke 53280,0:poke 53281,0:print"{clear}"
10 a$(0)=". this is an example of a getting around the problem of 255"
11 a$(0)=a$(0)+" characters per string: think of each array as a single string"
12 a$(0)=a$(0)+", so a$ is broken into four elements (or fewer as required) a"
13 a$(0)=a$(0)+"s we know that there are 1000 characters by default on a"
14 a$(0)=a$(0)+" commod"
15 a$(1)="ore 64 screen, so dim a$(3) will suffice. if one was to use a 2-"
16 a$(1)=a$(1)+"dimensional array using the same logic, like dim a$(9,3), you"
17 a$(1)=a$(1)+" could say that the first identifier (0 to 9) could state "
18 a$(1)=a$(1)+"the page or location, with the second (0 - 3 inclusive) "
19 a$(1)=a$(1)+"being the conten"
20 a$(2)="ts of the page or location. rather handy if you wanted to try your"
21 a$(2)=a$(2)+" hand at a text adventure, something which i may do. as"
22 a$(2)=a$(2)+" this is just an example, i've already run out of things"
23 a$(2)=a$(2)+" to say and i'm not even 800 characters in yet, so i may "
24 a$(2)=a$(2)+"as well send some gre"
25 a$(3)="etings out, as is customary in scrollys......... greetings to nigel"
26 a$(3)=a$(3)+" p, allan b, bert, wayne w......... happy programming."
27 a$(3)=a$(3)+"......."
30 a$=left$(a$(0),1)
40 for i=0 to 2
45 l=len(a$(i))-1:a$(i)=right$(a$(i),l)+left$(a$(i+1),1)
50 next
55 l=len(a$(3))-1:a$(3)=right$(a$(3),l)+a$
60 print"{home}{right}{dark gray}"mid$(a$(0),1,2)"{gray}"mid$(a$(0),3,1)"{light gray}";
65 print mid$(a$(0),4,1)"{white}"mid$(a$(0),5,30)"{light gray}"mid$(a$(0),35,1)"{gray}"mid$(a$(0),36,1)"{dark gray}"mid$(a$(0),37,2)
70 wait 53265,128,128:get a$:if a$="" then 30
Regards,
Shaun.