Newbie query - reading a data file

Post

Posted
Rating:
#1 (In Topic #540)
Trainee
 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.
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Enthusiast
GrayGhost is in the usergroup ‘Enthusiast’
 I am not an expert at this but I found this … it might help

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Enthusiast
PJBlack is in the usergroup ‘Enthusiast’
maybe this is a more "gambas-like" approach

https://gambas-buch.de…7.4:k7.4.9:k7.4.9.4:start

or if you hold on struct

k7:k7.2:k7.2.2:start [GAMBAS BOOK 3.19.5]
Online now: No Back to the top

Post

Posted
Rating:
#4
Avatar
Expert
Quincunxian is in the usergroup ‘Expert’
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:

Code (gambas)

  1. Public Sub ReadVBData
  2. Dim BFile As File
  3. Dim NameAry As New String[]
  4. Dim IntAry As New Integer[]
  5. Dim TmpStr As String
  6. Dim TmpInt As Integer
  7.  
  8. BFile = Open \{file  path} For Read
  9. While Not Eof(BFile)
  10.  TmpStr = Read #BFile As String
  11.  TmpInt = Read #BFile As Integer
  12.  NameAry.Add(TmpStr)
  13.  IntAry.Add(TmpInt)
  14. Close #BFile
  15.  

Cheers - Quin.
I code therefore I am
Online now: No Back to the top
1 guest and 0 members have just viewed this.