Page 1 of 1

Convert VBA code

Posted: Sat Oct 15, 2022 6:14 pm
by jparada
Hi,
Can someone help me to convert this VBA code to Harbour

Code: Select all

Public Sub Example()
    Dim bytFile() As Byte
    bytFile = GetFileBytes("c:\test\dirdump.doc")
    ''// Do something with bytFile here.
End Sub

Public Function GetFileBytes(ByVal path As String) As Byte()
    Dim lngFileNum As Long
    Dim bytRtnVal() As Byte
    lngFileNum = FreeFile
    If LenB(Dir(path)) Then ''// Does file exist?
        Open path For Binary Access Read As lngFileNum
        ReDim bytRtnVal(LOF(lngFileNum) - 1&) As Byte
        Get lngFileNum, , bytRtnVal
        Close lngFileNum
    Else
        Err.Raise 53
    End If
    GetFileBytes = bytRtnVal
    Erase bytRtnVal
End Function
I appreciate your help.

Regards,
Javier

Re: Convert VBA code

Posted: Sun Oct 16, 2022 7:37 am
by serge_girard
Javier,

What does it? Return FileSize?

S