title: How to implement an array in vbscript with a variable size
body: <p>I am redesigning a part of a webpage to make it easier to update in the future.  Currently, it is a series of tables, that are hard-coded.  To redesign the table (for example, to alphabetize it like I want to), requires manually swapping around a lot of values in the html.</p>
  
  <p>This is what I'd like to do:
  Create a url_Link object with a title and link variable, to hold the display name and the url respectively.
  Create an array of url_Link objects, and populate it at the top of the .asp file for the page.
  Perform a for each loop on those arrays to build and populate the table</p>
  
  <p>This itself isn't so bad, but I run into two problems.
  First, I'd like to not have to define the array size, as this makes a second place that has to be changed when changes are made to the number of links.
  There will be some logic to prevent certain url_Link objects from being displayed (for example, some users can't access certain pages, so they will not see links), and this would cause issues when sizing the arrays.</p>
  
  <p>I know that I could just make the arrays of a large size, but this seems wasteful to me (and I don't know how for each functions and do not want a bunch of empty rows to show up).</p>
  
  <p>What can I do to resolve these problems?  I'm not very knowledgeable in vbscript, and most of the code that I have been working with does not take advantage of arrays or objects.</p>
  
  <p>UPDATE:
  I've tried using a redim PRESERVE to trim the excess fat of an oversized array.  The problem is that in some cases, my array is populated by smaller amounts of objects than its max size because of if conditions.  This is causing problems later when I use a for loop (tried to get a for each to work and that is not happening at the moment).  I get the error "This array is fixed or temporarily locked" on the redim line</p>
  
  <p>Code:</p>
  
  <pre><code>  dim systemSettingsArray(1) 
    arrayCounter = 0
    if ADMIN = "Y" then
        set systemSettingsArray(arrayCounter) = (new url_Link).Init("Account Administration","Maintenance/Account_Admin.asp")
        arrayCounter = arrayCounter + 1
    end if
    set systemSettingsArray(arrayCounter) = (new url_Link).Init("Time Approval","Maintenance/system_Time_Approval.asp")
    redim Preserve systemSettingsArray(arrayCounter)
  </code></pre>