View Complete Thread | FoxWeb Forum Home
Date:    Msg ID:   
From:    Thread:   
The behavior you describe does seem like a bug, but  if I were you, I would post your question in one of Microsoft's VFP-specific newsgroups.

Instead of releasing the array, you could dimension it with a single element and set it to .F..  If VARTYPE(ArrayName(1)) = 'L', then you can assume that the array is empty.

FoxWeb Support Team email

Sent by Jim Doe on 11/10/2004 08:48:52 AM:
Hi all
The Apology:
I know that this is more of a FoxPro question, but since I do all of my FoxPro coding by way of FoxWeb, and since there isn't one dominant discussion board for FP, I thought I'd pose this issue here.  Apologies to those who might be offended by this.  Besides, this group is, by far, the sharpest FoxPro group out there!  (Where's the 'Shameless Flattery' emoticon?)
The Issue:
When passing an array to a function (by reference), the function whittles down the array via re-dimensioning.  Based upon certain criteria, the array should be emptied and since "Dimension Arr(0)" won't work, I used a "Release Arr" instead.  A quick test as to the existence of "Arr" proved that the array had in fact been released.  However, when the function ended, I discovered that the array that had been passed to the function and subsequently RELEASEd was still alive and well.  I'm almost certain that this isn't by design.  My biggest fear is that the memory of the array is in fact released back into the free memory pool and subsequent program execution will stomp all over it.  I can code around it, but I just wanted to know if this is a bug, misunderstanding or stupidity on my part.  I'm using Visual FoxPro 7 with FoxWeb 2.6.
Added Follow-Up:
Within the function, the array can be altered with the "Dimension" command and those changes are seen in the calling program
The Example:

<H2>Hi There</h2>

Dimension Items(20)

Function Whittle(Arr)
  * - Just for fun, kill the array
  release Arr
  * - The next line will cause "Variable 'ARR' is not found", as it is supposed to - Uncomment to see
  * response.write(alen(arr))
  return 0


Hi There

Since the array is passed by reference, I would have thought that the second "alen" call would either cause an error or yeild a 0.  Any thoughts? 


"The true measure of a career is to be able to be content, even proud that you succeeded through your own endeavors without leaving a trail of casualties in your wake."  - Allen Greenspan