Session array FAQ - picky subroutine detail

Results 1 to 2 of 2

Thread: Session array FAQ - picky subroutine detail

  1. #1
    Goodeye Guest

    Default Session array FAQ - picky subroutine detail

    Here is a picky detail about the excellent Session Array FAQ from 4guys:<BR>"How do I put an array into a Session or Application "variable"? How do I then use it on the next ASP page? "<BR><BR><BR>On the subsequent ASP page, when retrieving the array, then attempting to expand it, I did the expansion in a subroutine, similar to addCartElement. However, I passed in the (now local) array as an argument (I&#039;m a big fan of passing variables, to avoid the whole &#039;global&#039; scene mess).<BR><BR>It turns out this was ok, except that I had also passed in an element of the array, as in: <BR> cartItem = addCartElement(cartArray(NODE_ID, i), other params, cartArray)<BR><BR>(the NODE_ID is from my code; doesn&#039;t fit the example exactly)<BR><BR>This produced the error:<BR>"This array is fixed or temporarily locked"<BR>on the ReDim line.<BR><BR>I chased the &#039;fixed&#039; aspect, but it turns out &#039;locked&#039; was the problem. When I used a separate variable for the node ID, and passed it instead, it worked like a charm:<BR><BR>cartItem = addCartElement(nodeID, other params, cartArray)<BR><BR><BR><BR>Thanks,<BR>Bob Cooley<BR>

  2. #2
    Join Date
    Dec 1969

    Default Interesting...

    ...don&#039;t think I ever envisioned anybody trying to add an element to the array that was already in the array.<BR><BR>The problem is that the cartArray must be passed "byRef" and the system isn&#039;t smart enough (I guess?) to make a copy of the element for the call.<BR><BR>Did you try doing this, by any chance:<BR><BR>cartItem = addCartElement( ( cartArray(NODE_ID, i) ), other params, cartArray)<BR><BR>Notice the extra parens in there. That *should* force VBS to make a copy of the value and then send the copy to the function, but maybe not. I&#039;d be interested to know. (I could do it myself, but I&#039;ve long since dumped the test pages that I used to generate that FAQ so I&#039;d have to regenerate everything.)<BR><BR>Bill Wilkinson<BR><BR><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