R RichardN Well-Known Member Licensed User Longtime User Apr 11, 2011 #1 As a VB refugee I am having some problems understanding the fundamentals of random access read/write operations in B4A. In VB I would construct a user-defined data type including fixed-length strings that would always give rise to a database divisable by the record-length. I can't understand how to do this in B4A. A singlerecord might be: varInt varBoolean varFloat varString (maxlen 10) varString (maxlen 30) Q. How are the variables initialised in B4A to give a fixed length record? Q. How is such a record written or read ? Q. How is the number of such records determined when opening such a database? I can't find an example in the documentation. Any chance of a short code sample that demonstrates the above ? Thanks R
As a VB refugee I am having some problems understanding the fundamentals of random access read/write operations in B4A. In VB I would construct a user-defined data type including fixed-length strings that would always give rise to a database divisable by the record-length. I can't understand how to do this in B4A. A singlerecord might be: varInt varBoolean varFloat varString (maxlen 10) varString (maxlen 30) Q. How are the variables initialised in B4A to give a fixed length record? Q. How is such a record written or read ? Q. How is the number of such records determined when opening such a database? I can't find an example in the documentation. Any chance of a short code sample that demonstrates the above ? Thanks R
Erel B4X founder Staff member Licensed User Longtime User Apr 12, 2011 #2 Do you want to save the data in a SQL database? If yes then you should use the SQL library: http://www.b4x.com/forum/basic4android-getting-started-tutorials/6736-sql-tutorial.html DBUtils - Android databases are now simple! Simple example that uses DBUtils to display a table: http://www.b4x.com/forum/basic4andr...ls/8655-two-dimensional-database-reports.html If you want to write the data to a file directly then you should use RandomAccessFile: Basic4android - RandomAccessFile RandomAccessFile was updated several days ago and it can now save a custom type: RandomAccessFile - V1.10 - Read/Write objects You can declare custom types with the Type keyword. Strings cannot be limited to a fixed size. Upvote 0
Do you want to save the data in a SQL database? If yes then you should use the SQL library: http://www.b4x.com/forum/basic4android-getting-started-tutorials/6736-sql-tutorial.html DBUtils - Android databases are now simple! Simple example that uses DBUtils to display a table: http://www.b4x.com/forum/basic4andr...ls/8655-two-dimensional-database-reports.html If you want to write the data to a file directly then you should use RandomAccessFile: Basic4android - RandomAccessFile RandomAccessFile was updated several days ago and it can now save a custom type: RandomAccessFile - V1.10 - Read/Write objects You can declare custom types with the Type keyword. Strings cannot be limited to a fixed size.
R RichardN Well-Known Member Licensed User Longtime User Apr 13, 2011 #3 Thanks very much Erel. In that case SQL is the way ahead. Upvote 0