Page 1 of 1

How to read VB's udt files?

Posted: Wed Jul 26, 2006 8:27 pm
by Shannara
In VB you can write a whole UDT into a file. Have anybody have experience in reading the udt files in purebasic?

Posted: Thu Jul 27, 2006 9:25 am
by KarLKoX
WriteData(FIO, my_udt, sizeof(my_udt)
ReadData(FIO, @my_udt, sizeof(my_udt)

Posted: Thu Jul 27, 2006 4:33 pm
by Shannara
Ah, thanks for the information! :) I didnt know Fred cloned the VB's UDT writing and reading exactly.:) I'll check that out as soon as I get home.

Posted: Thu Jul 27, 2006 4:49 pm
by KarLKoX
UDT PB equivalent is the Structure, whatever language you use, writing structure is always done this way :wink:

Posted: Thu Jul 27, 2006 7:02 pm
by Shannara
Okay then .. I'll give it a shot to read a vb udt file. If it doesnt work, I'll post both the code for vb and pb :)

Posted: Thu Jul 27, 2006 7:31 pm
by ts-soft
This doesn't work for Strings! Only the useless Pointer is written :wink:

Posted: Thu Jul 27, 2006 8:23 pm
by Shannara
Hehe, well er... Cant be entirely useless as vb must be able to read the string somehow. :)

Posted: Thu Jul 27, 2006 8:33 pm
by ts-soft
You can use FixStrings for that

Code: Select all

Structure test
  text.s{255}
EndStructure

test.test
test\text = "Holla, purebasic rulez"

File = CreateFile(#PB_Any, "C:\test.dat")
If File
  WriteData(File, @test, SizeOf(test))
  CloseFile(File)
EndIf

Posted: Thu Jul 27, 2006 9:27 pm
by Shannara
Yes, but that wasnt my question that started the thread. I am trying to read a udt file that was created in VB.

Posted: Thu Jul 27, 2006 11:21 pm
by ts-soft
Is more the answer to that:
KarLKoX wrote:UDT PB equivalent is the Structure, whatever language you use, writing structure is always done this way :wink:
I haven't VB to test it