Application Variables and arrays

Results 1 to 2 of 2

Thread: Application Variables and arrays

  1. #1
    Brian K Guest

    Default Application Variables and arrays

    Hi, <BR><BR>Decided to try and use application variables and arrays. <BR><BR>What I am trying to do is have an array of numbers. <BR><BR>When a number is inputted by a user this number will be added to the start <BR>of the array and the last element of the array is lost. <BR><BR>Using application variables because I want all users to be adding to the <BR>same array. <BR><BR><BR>the code I have been trying to use is: <BR><BR><BR>Dim newArray(20), searchArray(20), i <BR>For i=0 To 19 <BR>Application.Lock <BR><BR>Application("newArray(0)") = newVar <BR>Application("newArray(i+1)") = Application("searchArray(i)") <BR><BR>Application.UnLock <BR>Next <BR><BR>Application("searchArray()") = Application("newArray()") <BR><BR>The searcharray is my array that I want to use with new number appended to <BR>the start. <BR>The NewArray created to help me do this. <BR><BR>When I do a : <BR><BR>Response.Write "<BR>First Term now is : " & Application("searchArray(0)") <BR><BR>After this for loop <BR><BR>I don&#039;t get the new value at Position (0) I get the old value. Which now should be at position (1)<BR><BR>Logic of for loop seems good, but doesn&#039;t do what it is suppose to.<BR><BR>Does anyone have any ideas whats wrong!! <BR><BR>Thanks <BR><BR>Brian <BR>

  2. #2
    Keith M Guest

    Default RE: Application Variables and arrays

    Brian-<BR><BR>Application variables don&#039;t work that way with arrays.. what you have to do is create your array in your ASP code, then put the entire array into the application variable.<BR><BR>&#060;%<BR>Dim myarray(2)<BR>myarray(0)="This"<BR>myarray(1)="is" <BR>myarray(2)="Fun!"<BR><BR>&#039;Then set your application variable<BR><BR>Application.Lock <BR>Application("newArray") = myarray<BR>Application.UnLock <BR><BR>%&#062;<BR><BR>To read back your application variables, you must load the entire array back into a local ASP variable, then massage from there...<BR><BR>&#060;%<BR>ThisPageArray = Application("newArray")<BR>response.write ThisPageArray(2) &#039; writes Fun!<BR>%&#062;<BR><BR><BR>Also, check out:<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts