
reading binary files, can't be done
Quote:
>writes
>>Here's a simple question: Write a file with microsoft fortran
>>powerstation with the command:
>>REAL* 4 A, B,C
>>WRITE(2) A, B, C
>>Is there anyway to read this file in Microsoft visual basic and get
>>real values of A,B and C?
If the fortran file is opened with form='binary',
the following seems to work:
Declare Function hread Lib "kernel32" Alias "_hread" (ByVal hFile As Long, lpBuffer As Any, ByVal lBytes As Long) As Long
Declare Function lclose Lib "kernel32" Alias "_lclose" (ByVal hFile As Long) As Long
Declare Function lopen Lib "kernel32" Alias "_lopen" (ByVal lpPathName As String, ByVal iReadWrite As Long) As Long
Dim x(3) As Single
filehandle& = lopen("my_fortran_binary_file", 0)
dummy& = hread(filehandle&, x(1), 12)
For i = 1 To 3
debug.print x(i)
Next i
dummy& = lclose(filehandle&)
If the file is opened with form='unformatted',
insert a line to read a two byte header:
dummy&=hread(filehandle&, tmp%, 2).
I don't know the exact format for 'unformatted' fortran file.
It has some paddings.
Hope this helps.
Bo Yu
Brookhaven National Lab