title: Controlling Empty Arrays in Classic ASP
body: <p>OK I'm a complete newbie to ASP.</p>
  
  <p>I have a client with different content loading depending on what is passed in an array.</p>
  
  <pre><code>select case lcase(arURL(4))
  </code></pre>
  
  <p>Sometimes though, <code>arURL(4)</code> might be empty, in them cases I'm getting the following error:</p>
  
  <p>Error running function <code>functionName()</code>, the error was:</p>
  
  <blockquote>
    <p>Subscript out of range</p>
  </blockquote>
  
  <p>Does anybody know a way to fix this?</p>
  
  <p>Thanks</p>
  
  <p>OK further code as requested.  It is horrible code and I don't mean to cause anybody a headache, so please excuse it.  Thanks again ........</p>
  
  <pre><code>function GetContent()
      dim strURL, arURL, strRetval
      select case lcase(request.ServerVariables("URL"))
          case "/content.asp"
              strURL = ""
              arURL = split(request.querystring("url"), "/")
              if request("page") = "" then
                  select case lcase(arURL(2))
                      case "searches"
                          select case lcase(arURL(1))
                              case "looking"
                                  select case lcase(arURL(3))
                                      case "ohai"
                                          strRetval = "Lorem"
                                      case "blahblah"
                                          strRetval = "Lorem Ipsum"                        
                                      case "edinburgh"
                                          select case lcase(arURL(4))
                                              case "ohai"
                                                  strRetval = "Ipsum"
                                              case "ohno"
                                                  strRetval = "Lorem"
                                          end select
                                      case "bristol"
                                          select case lcase(arURL(4))
                                              case "some_blahblah"
                                                  strRetval = "LOREM"
                                              case "overthere"
                                                  strRetval = "LOREM"
                                              case "blahblah"
                                                  strRetval = "LOREM"
                                          end select
                                      case "cambridge"
                                          select case lcase(arURL(4))
                                              case "some_rubbish"
                                                  strRetval = "Lorem"
                                          end select
                                      case else
                                          strRetval = " "
                                  end select
                              case else
                                  strRetval = " "
                          end select
                      case else
                          strRetval = " "
                  end select 
              end if
      end select 
      strRetval = strRetval &amp; "&lt;style&gt;h2{border: 0px);&lt;/style&gt;"
      GetContent = strRetval
  end function
  </code></pre>