Thread: array issue

    #1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Dec 2011
    Posts
    24
    Rep Power
    0

    array issue


    Thanks in advance for your help!!!

    My issue is checking a array variable in a if statement to see if it empty.

    Like

    Code:
    if pram(2) = "" then
    if empty redirect
    else
    not empty run code
    end if
    This is how my array is created

    Code:
    strString=Request.ServerVariables("HTTP_X_ORIGINAL_URL")
    strArray = split(strString, "/")
    Redim pram(uBound(strArray))
    For i = 0 to uBound(strArray)
        pram(i) = strArray(i)
    Next

    I can get empty array by

    if uBound(strArray) = -1 then

    But I want to check the second item in the array if it's empty. The first item in the array will exist but the second item may not exist and then I need the to redirect the user accordingly.
    Last edited by Will-O-The-Wisp; January 18th, 2016 at 02:24 PM.
  2. #2
  3. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,665
    Rep Power
    284
    Lets start from the beginning...
    strArray = split(strString, "/") return you array, why you need move that values to another array?
    GK
    __________________________________________________ _____
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree
  4. #3
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Dec 2011
    Posts
    24
    Rep Power
    0
    I was able to get my issue fixed. So here's what I did.

    ubound was right just did it wrong the first time. then I need to verify the name before doing something.
    so if you have string /1/2/3
    ubound = -1 check if empy string, ubound = 0 check first item in string, and ubound = 1 check second item in string and so on.
    hope this helps anyone with this issue.

    Code:
    if uBound(strArray) = 1 then
    redirect somewhere if empty
    else
    if pram(2) = "name" then
    do something if true
    else
    do something if false
    end if
    end if
    Last edited by Will-O-The-Wisp; January 19th, 2016 at 10:39 AM.
  6. #4
  7. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,665
    Rep Power
    284
    it is good you fixed your problem, but why you have
    Code:
    strString=Request.ServerVariables("HTTP_X_ORIGINAL_URL")
    strArray = split(strString, "/")
    Redim pram(uBound(strArray))
    For i = 0 to uBound(strArray)
        pram(i) = strArray(i)
    Next
    why not use just
    Code:
    if uBound(strArray) = 1 then
    redirect somewhere if empty
    else
    if strArray(2) = "name" then
    do something if true
    else
    do something if false
    end if
    end if
  8. #5
  9. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Dec 2011
    Posts
    24
    Rep Power
    0
    that might work as well. my only thought is does if strArray(2) = "name" then just look for "name" in the string to verify its there or will it fail do to not ubounding it first. Basically I'm ubound it an associating a parameter with it so I could call for a parameter just like a querystring. If thats the case then can you use strArray(2) in my sql statement to retrieve the results?
  10. #6
  11. Contributing User
    ASP Skiller (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,665
    Rep Power
    284
    Yes. Moving data from strArray into pram array is extra step
  12. #7
  13. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Dec 2011
    Posts
    24
    Rep Power
    0
    yep your right works perfect. so it looks like:

    strString=Request.ServerVariables("HTTP_X_ORIGINAL _URL")
    strArray = split(strString, "/")

    if uBound(strArray) = 1 then
    redirect somewhere if empty
    else
    if strArray(2) = "name" then
    do something if true
    else
    do something if false
    end if
    end if

    Thanks!!!

Similar Threads

  1. Another array issue
    By marco_v in forum ASP Development
    Replies: 4
    Last Post: May 27th, 2011, 08:30 AM
  2. Issue with For Next look and Array
    By cmt9000 in forum ASP Development
    Replies: 2
    Last Post: February 5th, 2008, 01:56 PM
  3. Array sort issue
    By el_bungle in forum ASP Development
    Replies: 2
    Last Post: October 4th, 2007, 03:04 PM
  4. Array Issue
    By snipered in forum .NET Development
    Replies: 1
    Last Post: March 26th, 2006, 05:11 AM
  5. Randomized Array Issue
    By NoTalentHack in forum ASP Development
    Replies: 3
    Last Post: February 4th, 2005, 05:29 PM

IMN logo majestic logo threadwatch logo seochat tools logo