No announcement yet.

Arrays w/Negative values

  • Filter
  • Time
  • Show
Clear All
new posts

  • Scott Turchin
    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...



    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.


    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..
    %INVALID_KEY            = -1
    %INVALID_PARAM          = -2
    %NETWORK_NOTUP          = -6
    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
    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