Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.acorn.programmer > #1776
| From | "David Holden" <SpamBin@apdl.co.uk> |
|---|---|
| Newsgroups | comp.sys.acorn.programmer |
| Subject | Re: BBC BASIC, Long Strings, And BeagleBoard |
| Date | 2012-06-05 06:37 +0000 |
| Organization | APDL |
| Message-ID | <a35nq6Fs18U1@mid.individual.net> (permalink) |
| References | <4ca81a1d-7657-4dbb-9868-2c29a25e7f2c@f30g2000vbz.googlegroups.com> <3e123c1e-58ab-4e2e-9e3b-dc1a51278ea5@e20g2000vbm.googlegroups.com> |
On 5-Jun-2012, Michael <michaelremerton@gmail.com> wrote: > David: > > I agree, the backwards thing did bug me a little, but as they worked - > > "If it ain't broke, dont fix it" > The problem is that it *is* broke. It's a hangover form the original BBC 6502 Basic and exixts only because with a 6502 and limited RAM code could be faster and more compact it you counted down to 0 instead of up to a certain number. Hence starting at the end of a string and working down the the start was 'better'. The trouble is that it makes the data effectively unreadable for anything except BBC Basic. If you use BPUT# instead of PRINT# and then GET$# to retrieve a string then the strings are just put into the file 'normally' so they can be read by any other method, including simply visually. > As I am using arrays of strings and integers, how would I arrange my > memory into a block and save/read that? I have always steered away > from looking into this, as my system has worked until now, and in case > I bugger something up ;@) > Create a byte array big enough to hold your data eg. DIM array% 8000 for 8000 (actually 8001) bytes. You now need a pointer to the data, eg. ptr%. Assuming you've got a Basic string and 2 integers you could use - ptr%=array% :REM set ptr% to start of data block $ptr%=name$ :REM insert string at ptr% ptr%=ptr%+LEN(name$)+1 :REM point to next byte after end of string ptr%=(ptr%+3) AND NOT 3 :REM word align ptr% !ptr%=data1%:ptr%+=4 :REM insert 1st data word and inc ptr% !ptr%=data2%:ptr%+=4 :REM insert 2nd data word and inc ptr% repeat until done (obviously without the 1st line for subsequent records). It would also be sensible to leave (say) 4 bytes empty at the start and keep a count of the number of records as you go then put this into the start of the data so you know how many records there are when you relieve it; eg., start out with ptr%=array%+4, then before you save !array%=count% Note. It's not strictly necessary to word align the integers in a Basic array but it's neater and would make it easier for another language to retrieve the data from the file. If the names are longer than 255 characters then instead of just inserting Basic strings you'd have to copy them. If (as you say) you've used OS_GBPB to get the names then set a pointer (name%) to point to the name returned by OS_GBPB and instead of lines 2 and 3 above use - WHILE ?name% >13 :REM repeat until end of name found ?ptr%=?name% :REM copy a character ptr%+=1:name%+=1 :REM inc pointers ENDWHILE ?ptr%=0:ptr%+=1 :REM terminate string and inc ptr% To save the data it's best to use the appropriate OS_File command but you could just use - OSCLI "save "+filename$+" "+STR$~array%+" "+STR$~ptr% Retrieving the data is the reverse of the above. > Last thought, should the Wimp Message System be pointing to a byte > array as well to overcome this? (not knowing anything really about > it) :) All text passed to and from the Wimp message system *is* passed in that way. Basic will hide this from you by letting you put a Basic string as a parameter but it converts it to a 0 terminated string before passing it to the SWI. The limitation is because the Wimp message system itself passes only 256 bytes. Some of these are used for various parameters so any text will be limited to about 240. Of course, this won't matter if you're not using the Wimp message system, eg. to load/save data by dragging. -- David Holden - APDL - <http://www.apdl.co.uk>
Back to comp.sys.acorn.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
BBC BASIC, Long Strings, And BeagleBoard Michael <michaelremerton@gmail.com> - 2012-06-04 03:19 -0700
Re: BBC BASIC, Long Strings, And BeagleBoard "David Holden" <SpamBin@apdl.co.uk> - 2012-06-04 13:37 +0000
Re: BBC BASIC, Long Strings, And BeagleBoard Gavin Wraith <gavin@wra1th.plus.com> - 2012-06-04 15:49 +0100
Re: BBC BASIC, Long Strings, And BeagleBoard Michael <michaelremerton@gmail.com> - 2012-06-04 17:20 -0700
Re: BBC BASIC, Long Strings, And BeagleBoard "David Holden" <SpamBin@apdl.co.uk> - 2012-06-05 06:37 +0000
Re: BBC BASIC, Long Strings, And BeagleBoard spampling <spam.pling@btinternet.com> - 2012-06-05 10:13 +0100
Re: BBC BASIC, Long Strings, And BeagleBoard "John Williams (News)" <UCEbin@tiscali.co.uk> - 2012-06-05 12:06 +0200
off-topic - was Re: BBC BASIC, Long Strings, And BeagleBoard spampling <spam.pling@btinternet.com> - 2012-06-05 16:25 +0100
Re: BBC BASIC, Long Strings, And BeagleBoard Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2012-06-15 08:37 +0200
Re: BBC BASIC, Long Strings, And BeagleBoard "David Holden" <SpamBin@apdl.co.uk> - 2012-06-15 08:58 +0000
Re: BBC BASIC, Long Strings, And BeagleBoard Rick Murray <heyrickmail-usenet@yahoo.co.uk> - 2012-06-15 17:37 +0200
Re: BBC BASIC, Long Strings, And BeagleBoard Paul Sprangers <Paul@sprie.nl> - 2012-06-15 18:34 +0200
Re: BBC BASIC, Long Strings, And BeagleBoard Frank de Bruijn <zuiderduin@hotmail.com> - 2012-06-16 08:25 +0200
Re: BBC BASIC, Long Strings, And BeagleBoard "David Holden" <SpamBin@apdl.co.uk> - 2012-06-16 07:57 +0000
Re: BBC BASIC, Long Strings, And BeagleBoard Steve Drain <steve@kappa.me.uk> - 2012-06-16 11:00 +0100
Re: BBC BASIC, Long Strings, And BeagleBoard Michael <michaelremerton@gmail.com> - 2012-08-06 01:28 -0700
Re: BBC BASIC, Long Strings, And BeagleBoard Frank de Bruijn <zuiderduin@hotmail.com> - 2012-06-16 12:05 +0200
Re: BBC BASIC, Long Strings, And BeagleBoard Richard Russell <news@rtrussell.co.uk> - 2012-06-07 06:29 -0700
Re: BBC BASIC, Long Strings, And BeagleBoard jgh@arcade.demon.co.uk (Jonathan Graham Harston) - 2012-06-05 20:59 +0100
csiph-web