Newbie query - reading a data file

Post your Gambas programming questions here.
Post Reply
carlhood
Posts: 3
Joined: Wednesday 30th December 2020 9:56am

Newbie query - reading a data file

Post by carlhood »

Hi,
I have a couple of data files that were created under VB6 with blocks of records of the same size and accessed using VBs random-access method. I know the structure and size of each record, but it seems I can't specify the size of a string using STRUCT in Gambas. , but stumped with Gambas Would welcome any thoughts how I might approach this problem.
Thanks.
User avatar
grayghost4
Posts: 174
Joined: Wednesday 5th December 2018 5:00am
Location: Marengo, Illinois usa

Re: Newbie query - reading a data file

Post by grayghost4 »

I am not an expert at this but I found this ... it might help
Attachments
MyStruct-DB-0.0.tar.gz
(8.26 KiB) Downloaded 270 times
User avatar
PJBlack
Posts: 184
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: Newbie query - reading a data file

Post by PJBlack »

SheilaNoe
Posts: 1
Joined: Monday 11th April 2022 7:04pm

Re: Newbie query - reading a data file

Post by SheilaNoe »

Hello, carlhood! You need to understand that using the string via the STRUCT feature with Gambas didn't help due to the common difference between VBs blocks. Also, I believe you got the different-sized blocks, which is the main issue. I would move the directory to another place and proceed with the restructuring process in your situation. After the process, you will need to check for the empty spaces on your disk, so you can use some recovery services like raid data recovery site.
Last edited by SheilaNoe on Thursday 14th April 2022 1:03pm, edited 1 time in total.
User avatar
Quincunxian
Posts: 171
Joined: Sunday 25th June 2017 12:14am
Location: Western Australia

Re: Newbie query - reading a data file

Post by Quincunxian »

Is this more like reading binary data?
If you know the field types of each record then it should be possible to READ the file under Gambas.
You may need to do some trial and error to get the field types right but should not be too hard. See: Binary Data Representation

(very) rough example of reading multiple binary records comprised of a string and an integer Id fields:
Public Sub ReadVBData
Dim BFile As File
Dim NameAry As New String[]
Dim IntAry As New Integer[]
Dim TmpStr As String
Dim TmpInt As Integer

BFile = Open {file  path} For Read 
While Not Eof(BFile)
 TmpStr = Read #BFile As String
 TmpInt = Read #BFile As Integer
 NameAry.Add(TmpStr)
 IntAry.Add(TmpInt) 
Wend
Close #BFile
End
Cheers - Quin.
I code therefore I am
Post Reply