Here is the project file and basicpage.vfile to be opened/saved by the following code (also found in the project file)
Download: http://www.simulanics.com/projectfile.zip
Ultimately the issue is Xojo equivalents to VB6’s Get/Put binary file functions. I’ve translated a good 99% of the code from an old project, and am having a lapse as how to get this last little piece…placing an array structure into a binary stream, and retrieving existing array structures from a binary stream (ie the included basicpage.vfile from an original template). The original code has been shortened (confirmed to still function in VB6) for ease sake. Any help to get this working would greatly be appreciated.
OpenProject(sFilename as String) Method
[code] //Attempted VB6-Xojo translation
Dim fName as FolderItem = GetFolderItem(sFilename)
Dim vFileContents as BinaryStream
InitVirtualFiles()
vFileContents = BinaryStream.Open(fName,True)
Dim NumberOfItems as Integer
//VB6 Get Code to get contents (storing NumberOfItem as the number of items in the structure)
ReDim VirtualFiles(NumberOfItems)
For i as Integer = 1 to NumberOfItems
//VB6 Get Code to get next bit of data
Dim vFileExtension as Integer = VirtualFiles(VirtualFiles.Ubound - NumberOfItems + i).Extension
If vFileExtension = EX_MODULE then
Window1.ListBox1.AddRow "Modules"
elseif vFileExtension = EX_ENTRY Then
Window1.Listbox1.AddRow "Window"
elseif vFileExtension = EX_DIALOG then
Window1.Listbox1.AddRow "Dialog"
elseif vFileExtension = EX_MENU then
Window1.Listbox1.AddRow "Menu"
end if
Next
vFileContents.Close()[/code]
//VB6 Code for HTML designer
'Open cd.FileName For Binary As #FileNum
'Get #FileNum, , NumberOfItems
'ReDim VirtualFiles(UBound(VirtualFiles) + NumberOfItems) As TYPE_VIRTUAL_FILE
'For i = 1 To NumberOfItems
'Get #FileNum, , VirtualFiles(UBound(VirtualFiles) - NumberOfItems + i)
'If VirtualFiles(UBound(VirtualFiles) - NumberOfItems + i).Extension = EX_MODULE Then
'tvProject.Nodes.Add "Modules"
'ElseIf VirtualFiles(UBound(VirtualFiles) - NumberOfItems + i).Extension = EX_ENTRY Then
'tvProject.Nodes.Add "Entry"
'ElseIf VirtualFiles(UBound(VirtualFiles) - NumberOfItems + i).Extension = EX_DIALOG Then
'tvProject.Nodes.Add "Windows"
'ElseIf VirtualFiles(UBound(VirtualFiles) - NumberOfItems + i).Extension = EX_MENU Then
'tvProject.Nodes.Add "Menus"
'End If
'Next i
'Close #1
SaveProject Method
[code]//Attempted VB6-Xojo translation
Dim fName as FolderItem = GetSaveFolderItem("",“untitled.vfile”)
Dim bFile as BinaryStream
bfile = BinaryStream.Create(fName,true)
Dim i as Integer
For i = 1 To VirtualFiles.Ubound
//??? VB6 Put Array item VirtualFiles(i) as TYPE_VIRTUAL_FILE in file
Next i
bFile.Close[/code]
//VB6 Code for HTML designer
'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