I’m converting an application from vb6 to Xojo for someone and I’ve come across this issue in conversion:
Open cD.FileName For Binary As #FileNum
Put #FileNum, , UBound(VirtualFiles)
For i = 1 To UBound(VirtualFiles): Put #FileNum, , VirtualFiles(i): Next i
Close #FileNum
…
In Xojo, VirtualFiles() is an array of Type(Structure):
TYPE_VIRTUAL_FILE
Name as String
Extension as Integer
Content as String
Used as Boolean
As far as I can get for this conversion is:
fname as FolderItem’(<-----is set as a function argument)
[code]
Dim VirtualF as BinaryStream
VirtualF = BinaryStream.Create(fname)
For I as integer = 0 to VirtualFiles.Ubound
???
next
VirtualF.Close[/code]
The functions need to be IDENTICAL to the VB6 input and output methods since the Xojo application will replacing the existing VB6 application and must be able to read as well as save to existing files without corrupting them.
TYPE_VIRTUAL_FILE is a TYPE variable in VB6, and most closely related to a STRUCTURE in XOJO
problem is a structure cannot take a “string” … it has to be a fixed length value…
I believe the structure of the file in VB6 has a linked list of pointers around each record allowing them to be of variable sizes
You may have to take a file with known contents and reverse engineer to see how those pointers are incorporated.
remember a VB6 string was limited to 255 characters with a +1 for a leading byte that indicated the string length
XOJO has gone beyong that. CString or Pstring MIGHT work here
minus the string portion…how would the rest of the conversion go since vb6 could save an entire array in a single sweep with multiple data-types…Xojo cannot :-/ each portion of the string is 256 indeed
simply write each portion as?
Dim tOut as BinaryStream
tOut = BinaryStream.Create(fName)
For i = 1 To UBound(VirtualFiles)
tOut.WritePString VirtualFiles(i).Name
tOut.WriteLong VirtualFiles(i).Extension
tOut.WritePString VirtualFiles(i).Content
tOut.Write VirtualFiles(i).Used ' What would VB6 convert a Boolean to?
next i
Close #FileNum
Conversion of the simplest things is difficult when no equivalents easily come to mind
if the strings are both exactly 256 bytes, you basically create a structure with 2 such strings plus the other stuff, or (probably better) use a memory block of the correct length.
Xojo will write and read that in once gulp, just like VB
The integer will be 16bits
The boolean is also a 16bit integer holding 0 or 1 (possibly -1, can’t recall, but the two are virtually interchangeable in VB in logic statements… if it isn’t 0 , its ‘true’)
BTW I dont recall VB strings as 255 bytes maximum. Thats a Pascal/Delphi limitation