Announcement

Collapse
No announcement yet.

ASCIIZ Arrays

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cecil Williams
    Guest replied
    Scott,

    %MAX_PATH = 260 is located in the "win32api.inc" file.

    Cheers,
    Cecil


    ------------------

    Leave a comment:


  • Scott Turchin
    replied
    There are some powerful options in PB when dealing with Arrays!

    That seems to have resolved the issue, I saw all 5 files going to the function now...

    Thanks Lance!

    Scott


    ------------------
    Scott
    mailto:[email protected][email protected]</A>
    MCSE, MCP+Internet

    Leave a comment:


  • Lance Edmonds
    replied
    Scott, how much debugging of this code have you done? You need to find out what the code is really doing. One way is to copy the code into a small "stub" and debug it as an EXE. Otherwise, you have to find the exact point it fails by inserting MSGBOX or logging variables and loop counters to a disk file.

    One note: the call to the ArrayFileCount() function could be replaced with a single line of code:

    Code:
    ARRAY SCAN CAB_FILES(1), = "", to lCount

    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Scott Turchin
    replied
    OK good point on the MAXPATH, however I think it is also dimmed at 255, I'll verify.
    I'm going to hard code all of it at 256 for now as I can't seem to FIND The Max_Path in the DLL


    Code:
    Dim CAB_FILES(1 To 100) As Asciiz * 256
    
    '
    '
    'DLL CODE:
    
    '------------------------------------------------------------------------------------------------------------------------
    Function CCSCabInsert(CabFileSpec As String,CAB_FILES() As Asciiz * 256 )Export As Long
    Local lCount As Long
    Local lLoop As Long
    'lCount is now the array index
    lCount = ArrayFileCount(CAB_FILES())
    Dim fciErr As ERF
    
    If IsFalse FCI_LoadLib Then
       MsgBox "Could not open dll FCI.DLL!", %MB_ICONSTOP, g_szCCS
       Exit Function
    End If
    
    hCabFile = FCI_Create(CabFileSpec, 0)
    If IsFalse hCabFile Then
       MsgBox "Failed to create cab file" + CabFileSpec,  %MB_ICONSTOP, g_szCCS
       Exit Function
    End If
    
    For lLoop = 1 To LCount
        If IsFalse FCI_AddFile( hCabFile, CAB_FILES(lLoop), "", %tcompTYPE_MSZIP, 0, 0 ) Then
           MsgBox "Unable to insert file " & CAB_FILES(lLoop), %MB_ICONSTOP,g_szCCS
           Exit Function
        End If
    Next
    If IsFalse FCI_Close( hCabFile ) Then
       Function = %FALSE
    Else
       Function = %TRUE
    End If
    FCI_FreeLib
    End Function 
    
    '
    '------------------------------------------------------------------------------------------------------------------------
    Function ArrayFileCount(CAB_FILES() As Asciiz * 256)Export As Long
    Local lLoop As Long
    Local lCount As Long
    For lLoop = 1 To 1000
        If Len(CAB_FILES(lLoop)) Then Incr lCount Else Exit For
    Next
    Function = lCount
    End Function
    '
    '

    ------------------
    Scott
    mailto:[email protected][email protected]</A>
    MCSE, MCP+Internet

    Leave a comment:


  • Lance Edmonds
    replied
    Obviously if we can see the actual code within the function we could probably provide exact help.

    However, it is interesting to note that your function declaration is expecting an ASCIIZ array whose members are 256 bytes each, %MAXPATH + 1 is not equal to 256. If you are using an equate to define the array subscript length, why are you using hard-coded numbers in some parts? This just makes the code harder to maintain.

    Ok, it may also be a good idea to provide the DIM statement you are using to define your ASCIIZ array... you have only give us the global declaration.




    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Scott Turchin
    started a topic ASCIIZ Arrays

    ASCIIZ Arrays

    I've taken the cab file samples and put them in a DLL, so that only one function has to be called.
    But when I pass an ASCIIZ array to it it only returns the first value.

    I'm thinking twilight zone music righht now because this sounds SO familiar as if I had read it somewhere here..

    Anyway here's a sample:

    Code:
    Declare Function CCSCabInsert Lib "CCSCAB.DLL"(CabFileSpec As String,CAB_FILES() As Asciiz * 256) As Long
    Declare Function CCSCabExtract Lib "CCSCAB.DLL"(CabFileSpec As String, CAB_FILES() As Asciiz * 256,DestDirectory As String,DeleteFlag As Long) As Long
    
    'Inside of DLL, other functions have access to this, could this be the problem?
    Global CAB_FILES() As Asciiz * %MAX_PATH + 1
    
    
    '
    CabFileSpec = "C:\CABTEST\CCS.CAB"
    CAB_FILES(1) = "C:\CABTEST\WINLOG.EXE"
    CAB_FILES(2) = "C:\CABTEST\CCS.DLL"
    CAB_FILES(3) = "C:\CABTEST\CCSDATE.DLL"
    CAB_FILES(4) = "C:\CABTEST\CCSENCR.DLL"
    
    CCSCabInsert CabFileSpec, CAB_FILES()
    
    The function at the beginning ONLY gets the CAB_FILES(1).
    -------------
    Scott
    mailto:[email protected][email protected]</A>
    MCSE, MCP+Internet

    [This message has been edited by Scott Turchin (edited June 25, 2000).]
Working...
X