Download PolyLetter 1991 - PolyMorphic
Transcript
Po lyletter 9 1I3 Page 6 GET statement . GET #1,X Xis the record number in the file, the same as the Poly POS number . MA Y /JU N 199 1 Poly discards the extra characters. A l i ttle experimenting suggests that the FIELD statement I imits how many characters get written out to the data file . If the strings are concatenated by 1$=N$+P$+T$ flLE:4,POS,X \READ:4,A$ When the GET statement is executed, N$, P$, and T$ are all automat i cally filled up \olith the data from the file . There no need for the MID$ conversion. But this is not always convenient and \ole could define the FIELD statement similar to the Poly's DIM statement. 20 FIELD #1, 31 AS A$ Then "'e \olould have to do the MID$ thing, but it \olOUld be different from the Poly. This could actually make converting between Poly and PC BASIC programs easier. But \ole must remember that the MIDS function is different bet...,een both BASIC's. In Poly BASIC it's: MI 0$ CstrillCj,StartillCj position,endillCj position>. In PC BASIC it's: the extra spaces wi 11 cause P$ and T$ to be i n the ...,rong place and maybe cause data to be lost. Suppose N$="John James Bro...,n". P=2235 and T$="4588421 ". When the code 100 110 120 130 N$=N$+" P$=STR$CP,%#41> T$=T$+" 1$=N$+P$+T$ is run on the Poly, 1$ \olill be: John James Brown But \olhen the BASIC 100 110 120 130 22354588421 fol lo...,ing N$=N$+" P$zSTR$CP> T$=T$+" 1$=N$+P$+T$ code is run under PC II MID$ CstrincJ,startillCJ position,l'Ullller of cllaracters>. 1$ \oli 11 be: \olhere the number of characters is optional. John James Bro\oln Like Poly's BASIC, if there aren't enough characters the function \oli 11 return an empty string. But \olhen the number of characters is omitted, then the function \oli 11 return the rest of the string. Suppose the Poly MID$ function is setup as foll O\olS MID$CA$,X,Y> The converted function is MID$CA$,X,Y-X+1 > There is another important difference bet..,een Poly and PC BASICS concerning the MID$ function. In Poly BASIC, strings are dimensioned to the number of characters. PC BASIC a I lo"'s the size of a string to be flexible, up to 255 characters. The result is that adding 20 spaces to a string ...,i 11 make it 20 spaces longer! But if the resulting length is greater than 255 an error "'i 11 result. 22354588421 Before the PUT statement can ta to the file, a LSET statement data in the buffer defined by the ment. This can be accomplished by 130 above to \olrite the da must put the f IELD statechanging line 130 LSET 1$=N$+P$+T$ LSET insures that the data is left justif i ed in 1$ and is in the buffer defined by the FIELD statement. Once the data is in the buffer, it can be ...,ritten to the file with the PUT statement. In the above example, the PUT statement ...,i 11 cause the follo...,ing to be written out to the file: "John James Bro'Nn " 1$ wi 11 sti 11 be: John James Brown 223545884 2 1 But only the first 31 characters ...,i 11 be ...,ritten to disk.