![]() |
![]() |
![]() |
![]() |
|
Guest
Posts: n/a
|
ict@ccess wrote:
> If one really thinks about it, text files are a kind of virtual > memory. You can add strings, retrieve strings. And if the strings > are of a fixed length, then you can even replace strings in a text > file. > > But I found the text file commands of DOS3.3 and Basic.system very > slow. Some recommendations were to save your strings to a BIN file > instead. So I combined the two and created a sort of semi-Virtual > memory for strings > > Applesoft is limited with what it can do with variables. The maximum > value for any dimension is 32767, and the actual string space > available for strings is far less. > > Using my virtual string array add on, you can define up to 65536 > strings including string zero. And the maximum length of any string > is 255 characters (not 256 because string zero cannot be used since it > is used as an end of string marker) > Strings used this way can reach Prodos's maximum file size of 16 Mb > limit (65536 x 255 = 16711680) > > Advantages - > Only one virtual string array variable is created in memory with 255 > characters, one master block and one single byte block is also loaded > with the pointers (the 1 block that is loaded with the actual text > uses basic.systems buffer so does not take any additional space. If > the string spans 2 blocks, then the first part of the string is moved > to the string space, then the 2nd block is loaded) > > Text files of Prodos's maximum files size can be created > Multiple Virtual String Array files can be created and used within the > same program > Virtual Array Text files can be created using any Word Processor that > can create large files (I wrote a short applesoft program that > creates a header from the text files so any string can be jumped to > automatically as if it were the first string in the list) > > > Disadvantages - every string must be retrieved from disk although with > the advent of flash cards has made the speed of drives more tolerable. > One extra file is created for the pointers. > > > The commands to use > > & DEF VA$(0) - creates a virtual string variable and sets its length > to $FF (255) and makes space in string space > & GET VA$(0-65535),"Virtual String Array filename" - gets string from > file > & STORE X$,"Virtual String Array filename" - appends the string X$ to > the end of the file. If file does not exist then create it. If file > is not a Virtual Array file then return with error > > > Also a separate short applesoft program was created to make a header > for the pointers to every string. I used a pretty neat trick to > compress the header so that only one byte is needed to point to each > string instead of three and a one block master header to point to the > start of each string block. > > Long story short, hopefully. One block can point to 512 strings. so > only 128 blocks would be needed to point to 65535 strings plus one > master block. The master block holds the two high bytes of the start > of each of the 128 blocks so only one master block is needed. Once > one of the 128 blocks has been chosen by a little math (# of the > string divided by 512 gives one of the 128 blocks)(coincidently, this > same result also points to the hi bytes in the master block), a short > search is then made in the found block so that each time the next byte > is less than the preceding byte, a counter advances the high bytes > until the start of the correct string is found. Remember, these > blocks can point to 512 strings of 255 characters, so the master > pointers may also need to be incremented. There, short and sweet. > > A three byte pointer header would take 384 blocks to point to each > string to reach the 16 MB limit. > > One last thought for a use of Virtual String Arrays. One String Array > can have 65535 strings and multiple Virtual files can be created. > Each file can be designated as a column. Strings can become > formulas. Are you getting the picture. > > A Virtual Spreadsheet with 65535 columns by 65535 rows. There is a > good program in Nibble magazine Vol6 No8. Dynamic functions. It puts > formulas into a string and then uses redefined DEF and VAL commands to > evaluate the formula. > > Allowing Applesoft to play with the big boys. In several programs I've written, I needed to be able to process large files (>>64KB) while building several tables of an unpredictable size. I found that a single, sparse, binary file, accessed using BLOAD and BSAVE with B (byte-offset) parameters worked quite well. The binary file has a potentially huge size, but its sparseness greatly reduces the actual disk allocation. I generally use this approach with a pool of fixed-size buffers that cache the most-recently-used chunks of the file, so the overall performance is not too bad. Applesoft and ProDOS make a pretty powerful combination! -michael NadaNet 3.1 for Apple II parallel computing! Home page: http://home.comcast.net/~mjmahon/ "The wastebasket is our most important design tool--and it's seriously underused." |
|
![]() |
![]() |
![]() |
![]() |
| Copyright ©2007-2008 MacShock.com. |
Powered by vBulletin Copyright ©2000 - 2012, Jelsoft Enterprises Ltd. |