Link to home
Start Free TrialLog in
Avatar of Destiny Amana
Destiny AmanaFlag for Nigeria

asked on

ARRAY trouble shooting

I have a string that is passed through a web service.

paytxncode, I use the ASP Function split , to split it up with the & sign and we always get 8 values.

Problem is if an incorrect value is based in the web service, we get back a string with only 2 items.

How do I code to make sure the page does not fail on errors.

Here is what I have written already

ptbc=Split (paytxncode,"&") ' Once Split we get 8 values in the Array

if ISNULL(ptbc(2)) then

    ' Only 2 values in the array sent back
        rspcode = ptbc(0)
        rspdesc = ptbc(1)

        rspcodetext = Split(rspcode,"=")
        'Response.Write "<p> <b>RESPONSE CODE </b>: " & rspcodetext(1) & "<p>"
        rspdesctext = Split(rspdesc,"=")
        'Response.Write "<p> <b>RESPONSE DESCRIPTION </b>: " & rspdesctext(1) & "<p>"

    else
    'Normal 8 values
        transtime = ptbc(0)
        pan = ptbc(1)
        froacc = ptbc(2)
        toacc = ptbc(3)
        paytxncode = ptbc(4)
        appamt = ptbc(5)
        rspcode = ptbc(6)
        rspdesc = ptbc(7)

End if
SOLUTION
Avatar of wobbled
wobbled
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of khaaz
khaaz

With ubound function you could be sure that you have 8 items :

if Ubound(ptbc)<> 8 then
    response.write "error !"
    else
    response.write "ok"
end if

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial