Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Help with file pointers, please

Author
Message
Dracula
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: DBP Recreation of Castle Csejthe
Posted: 28th Oct 2006 23:12
Thank you for all the feedback on my previous post. I appreciate it. Ian, I will play around with your .ini plugin and see what I can come up with. Jinzai (or someone else), could you please explain how one can move a file pointer without reading a file using DBP? You mean by knowing how many fields are in a record you can use a loop (using step) to jump through records looking for a header, without reading each and every field? It sounds like it might be a good bet, if so. If I don't understand this correctly, someone please enlighten me, it will be of emense help

Thanks again!!

D
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 29th Oct 2006 03:20 Edited at: 29th Oct 2006 03:20
If you are using DBPro for your file I/O, then you would use the command:
skip bytes filenumber, bytes to skip.

That is how I would do it in your case. I think you have a good definition of your task worked up, and that you understand the process of making that happen.

I also work with the Windows functions in my DBPro code alot. So, if you decide that you want to do some of that, I have functions for file manipulation, as well. (They are just DBPro wrappers over Windows function calls mostly.) It is pretty simple to implement in your code later, too. In fact, I might just put that into my c runtime dll.

Finally, I am considering implementing an interface to Jet, but...I am a long way from coding it up. People don't seem to like Jet very much. I think ODBC is way more than I want, however.
Dracula
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: DBP Recreation of Castle Csejthe
Posted: 29th Oct 2006 03:57
Just for clairification... If I have a file with 15 records each containing five fields (lets call them f1,f2,f3,f4,f5), and the record totals 100 characters in length, and you used skip bytes, how many bytes would you skip to get to record 5? And is this more efficient than using a loop with step to search for the record you want?

Thanks for your help in explaining this!

D
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 30th Oct 2006 16:52 Edited at: 30th Oct 2006 16:59
In your hypothetical case, you would skip 400 bytes. Bytes to skip is the product of the record number and the sizeof the record.

On the surface, the stepped loop is more efficient because you'd read the entire file in, and simply skip to the record you wanted. Since you are asking about databases, I assume that your file would be quite large. That would not be practical in that case owing to the large file size. In the long run, you are better off simply winding the pointer, as we are discussing, imo.
Dracula
18
Years of Service
User Offline
Joined: 7th Aug 2006
Location: DBP Recreation of Castle Csejthe
Posted: 30th Oct 2006 18:12
Jinzai,

Thanks for helping me understand this better. I will use steps for the small files and skip bytes for the larger files. I think creating my own DB files will be more fun than linking to external progs.

One more question (please ): Can large (or small) files be created for storing memblock data that will be used for meshes as well as text data (in separate files, of course)?

Xiexie ni !!!

Many thanks!

D
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Oct 2006 21:00
Yes, in fact there are WRITE MEMBLOCK and READ MEMBLOCK commands that will write or read a whole memblock at a time.

If you are feeling adventurous, you might want to take a look at my utility plug-ins. With banks (equivalent to memblocks, but more flexible) and string commands, you can read a whole text file into memory and manipulate it in whole chunks. I do this in some example code posted in the same thread, that I used for build the help files for those plug-ins.

Login to post a reply

Server time is: 2024-09-25 11:32:49
Your offset time is: 2024-09-25 11:32:49