Results 1 to 7 of 7

Thread: Problem Resolution

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5

    Default Re: Problem Resolution

    Just saw another side effect of this and here it might be even more confusing.

    I have code that compiles in both DF19.1 as well as DF20.0

    So for wrapping the Windows API I have these declarations:
    Code:
    #IF (!@ < 200)
    Use vWin32fhA.pkg     // WinAPI ANSI legacy interface
    #ELSE
    Use vWin32fhW.pkg     // WinAPI Unicode version
    #ENDIF
    Where vWin32fhA.pkg includes the vWin32fhA.h file that has this struct declaration ->
    Code:
    Struct tvWin32FindData
     Dword            dwFileAttributes
     Dword            ftCreationLowDateTime
     Dword            ftCreationHighDateTime
     dword            ftLastAccessLowDateTime
     Dword            ftLastAccessHighDateTime
     Dword            ftLastWriteLowDateTime
     Dword            ftLastWriteHighDateTime
     Dword            nFileSizeHigh
     Dword            nFileSizeLow
     Dword            dwReserved0
     Dword            dwReserved1
     UChar[vMax_Path] cFileName
     UChar[14]        cAlternateFileName
    End_Struct
    and the wide version alternative in vWin32fhW.h looks like this:
    Code:
    Struct tvWin32FindData
     Dword            dwFileAttributes
     Dword            ftCreationLowDateTime
     Dword            ftCreationHighDateTime
     dword            ftLastAccessLowDateTime
     Dword            ftLastAccessHighDateTime
     Dword            ftLastWriteLowDateTime
     Dword            ftLastWriteHighDateTime
     Dword            nFileSizeHigh
     Dword            nFileSizeLow
     Dword            dwReserved0
     Dword            dwReserved1
     Short[vMax_Path] cFileName
     Short[14]        cAlternateFileName
    End_Struct
    While debugging I issued a "Goto definition" on the following line:
    Code:
      //
      Procedure LoadBuffer String sSearchPath
        tvWin32FindData FindData
    and this brings up the ansi version of the declaration and not the wide version even while I _am_ compiling with DataFlex 20.0.

    If you're debugging and not aware of this particular pecularity then it is super weird that the following code does not work...

    Code:
    Move (UCharArrayToString(FindData.cAlternateFileName)) to sAlternateFileName
    Because well.. it's not a UChar array at all, it's an array of Shorts!

    FWIW you fix that like this:
    Code:
    #IF (!@ < 200)
    Move (UCharArrayToString(FindData.cAlternateFileName)) to sAlternateFileName
    #ELSE
    Move (PointerToWstring(AddressOf(FindData.cAlternateFileName))) to sAlternateFileName
    #ENDIF
    FWIW, it might be a good idea to add "UCharArrayToString" invocations in your code to the "to be inspected list" for DataFlex 20, especially when it is data that comes from interacting with the Windows API.

    --
    Wil
    Last edited by wila; 7-Dec-2019 at 03:17 PM. Reason: a to an

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •