Announcement

Collapse
No announcement yet.

Arrays w/Negative values

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

  • Scott Turchin
    replied
    Ya know, that appears to have worked!
    The Functions are returning zero, but that's a whole different issue


    I Just did a Dim Array(-10 to -1) and it liked it, I guess it has to increment to the right...

    Thanks!

    Scott

    -------------
    Scott Turchin


    Leave a comment:


  • Randy Standridge
    Guest replied
    I know you can dimension an array like this:

    Dim myArray(1900 to 2000)
    The only restriction I know of is that the subscript must be a long. Since this includes negative numbers I don't see why you couldn't dim the array as -1 to -10. I dod a quick test and confirmed this. In mine I dimmed the array like this: Dim myArray (-10 to -1) As Integer.




    -------------
    R.

    Leave a comment:


  • Scott Turchin
    started a topic Arrays w/Negative values

    Arrays w/Negative values

    This is going ot sound strange, my solution seems to be eluding me.
    I have the following return codes from a non PB DLL:
    See the function ErrToString for the error..
    Code:
    %INVALID_KEY            = -1
    %INVALID_PARAM          = -2
    %MODEM_NOT_RESPONDING   = -3
    %DIALCMD_DIDNOTECHO     = -4
    %NOCONNECT_AFTERDIAL    = -5
    %NETWORK_NOTUP          = -6
    %NETWORK_DIDNOTRESPOND  = -7
    %TRANSACTION_GARBLED    = -8
    %PORT_NOT_INITIALZIED   = -9
    
    Each Function is depending on the previous function before it is SUPPOSED to function, so I need to store each return for each function in an array:
    
    
    Function InitDLL() as long
    Dim MsgArray(1 To 10)   As Long
    Dim MsgStArray(1 To 10) As String
    Local x         As Long
    
    
    Now, I make a function call (1 of 10):
    Incr x
    '1)
    Key = "Reset":Param = ""
    lResult = FreeCCSDLL(Key,Param)
    MsgArray(x) = lResult
    MsgStArray(x) = ErrToString(MsgArray(x))
    Incr x
    
    So now i have an INTEGER/LONG return code and a corresponding STRING value.
    
    Life is good, except the return code is negative, and if the function returns a 1 then it succeeded, 0 if it fails.
    
    So I want to add up which one's failed in an array of MsgStArray() but want to keep the numeric in MsgArray().
    
    I thought I had this working once, but it is best to keep the return values in negative connotation, or I can use ABS to convert, but then if the function succeeds it will seem as an error...
    
    '------------------------------------------------------------------------------
    Function ErrToString(ByVal ErMsg As Long) As String
    Dim MsgStr(0 To 10)      As String
    
    Here is the problem, the array can't be dimmed as -1 to -10, or can it?
    
    'DLL Error codes
    MsgStr(0)                       = "Function Failed"
    MsgStr(%INVALID_KEY)            = "Invalid Key on Function "  '-1 for real, converted to abs is 1, so incr instead
    MsgStr(%INVALID_PARAM)          = "Invalid Parameter"
    MsgStr(%MODEM_NOT_RESPONDING)   = "Modem Not Responding"
    MsgStr(%DIALCMD_DIDNOTECHO)     = "Dial Command did not echo"
    MsgStr(%NOCONNECT_AFTERDIAL)    = "No connection after dialing"
    MsgStr(%NETWORK_NOTUP)          = "Credit Card Network is not up"
    MsgStr(%NETWORK_DIDNOTRESPOND)  = "Credit Card Network did not respond"
    MsgStr(%TRANSACTION_GARBLED)    = "Transaction was garbled"
    MsgStr(%PORT_NOT_INITIALZIED)   = "Com Port did not initialize
    Function = MsgStr(ErMsg)
    Erase MsgStr
    End Function
    -------------
    Scott Turchin


Working...
X