binary files

How to choose a record in binary file and edit it ?

That question is too generic and there is no way to answer it without more information. It depends on the format of the file.

Have a look in the documentation here: BinaryStream.

You will find a Property called Position that allow you to set the next read Position.

The only existing Record is the one you create by yourself.

All of that said, Kem is 100% correct (he is always 100% correct). Share more details to allow a reader to be able to formulate a correct answer.

	dim f as FolderItem
	dim bs as BinaryStream
	dim mynam as string
	dim myage as double
	mynam = textfield1.Text
	bs=BinaryStream.Open (f,True)

that is the file i create and wrote 10 records in it.
i don’t know how to choose a record let’s say number 5 and edit it.


I would highly suggest (if possible) using an SQLite Database instead…

I second Dave’s suggestion, this is exactly what a database is meant to do.

If you cannot use a database, you need to come up with your own format to identify records and fields. You’ll probably need a general header, then a record header for each record, or you can use fixed-length. Whatever, it’s up to you to create a well-defined, usable format.

Or just use a database.


you may start reading here (sqlitedatabase-classic).

Then, on the left pane, you will see other entries SQLite related…

The file you tried to create is almost an old-school ISAM file.
Except that it needed a few things to work.

eg Your string may not always be the same length.
If so, you have no way to get at record 5 or 6 later, you dont know where they start.

So it would work if the string was always the same length… you get record 5 by moving to a position 4 * the size of one record.

Alternatively, you maintain a separate INDEX which records the start point of each record. (Nasty)

If you dont want a database, use a flexible file format like JSON or XML
You can iterate through those and use XQL to search it too.

for the record : ISAM = Indexed Sequential Access Method

and to quote Jeff… [quote]Nasty[/quote] especially since there are SO many better ways to handle data.

The first Help files (REALbasic) followed this kind of schema: it have indexes to go forward / backward (if mymemory serve). But it was a nightmare (to reverse ingeneering it).

They changed to use SQLite for the good, if not for the better.

That said, HATEM does not told us whyhe want to go this road. Sometimes there are reasons why people do things.

So based on the data that we do have, SQLite is the best solution we can provide