| www.retrosoftware.co.uk http://www.retrosoftware.co.uk/forum/ |
|
| Reading X num of bytes from a file http://www.retrosoftware.co.uk/forum/viewtopic.php?f=73&t=913 |
Page 1 of 1 |
| Author: | PaulT [ Mon Sep 29, 2014 10:38 pm ] |
| Post subject: | Reading X num of bytes from a file |
I am working on a dictionary utility and I need to read in data from disk, the database is a just a list of words, but with the 1st letter missing, and no delimiters, i.e. APPLE ACKLE ADDLE would be stored as a string PPLECKLEDDLE With it so far ? OK, to read in the data, we know that this particular file contains 5 letter words beginning with 'A', so we start with 'A' and read in the first 4 bytes and add that to the 'A', then start with 'A' again, read next 4 bytes and so on. The reading is being done in a loop, doing a BGET# for as many characters we need to read, now this works perfectly, but it's quite slow as you need to loop reading just one byte at a time. Is there any way in BBC Basic, machine code call, hack etc to read a known number of bytes, i.e. a string in one operation, i.e. something like in$=BGET# file,number of chars to read I cant use INPUT# as that expects a certain format, and it does not know where the string ends ? Any ideas ? |
|
| Author: | DavidB [ Mon Sep 29, 2014 11:23 pm ] |
| Post subject: | Re: Reading X num of bytes from a file |
Take a look at the OSGBPB call in the Advanced User Guide. The Electron version of the guide has this description of the call in section 5.5: "This routine enables the transfer of a group of bytes to or from an open file. This routine is implemented particularly for filing systems which have a high time overhead associated with each data transfer e.g. the Econet." |
|
| Author: | PaulT [ Tue Sep 30, 2014 3:08 am ] |
| Post subject: | Re: Reading X num of bytes from a file |
DavidB wrote: Take a look at the OSGBPB ........" Thanks, that looks like it might well do the job, I've read up on it, and found some example code. Looks very promising, I'll give it a go |
|
| Author: | PaulT [ Thu Oct 02, 2014 3:31 pm ] |
| Post subject: | Re: Reading X num of bytes from a file |
DavidB wrote: Take a look at the OSGBPB ........" Just a quick update: Thanks DavidB, I got the OSGBPB call working It speeded up that part of the code as I thought it might |
|
| Author: | DavidB [ Thu Oct 02, 2014 9:53 pm ] |
| Post subject: | Re: Reading X num of bytes from a file |
Good to know it was useful. |
|
| Page 1 of 1 | All times are UTC [ DST ] |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|