You were using the procedure instead of a function Swap(@a[1], @a[2]) inside of PROCEDURE Swap(v1, v2)
Compiler should have barfed that one up for you.
On Thu, Apr 21, 2016 at 5:43 AM, Laurie Alvey trukker41@gmail.com wrote:
I'm sure we're all familiar with the standard way to swap two variables:
LOCAL p, q p = 1 q = 2 Swap(@p, @q) && pass by reference
PROCEDURE Swap(v1, v2) LOCAL dum dum = v1 v1 = v2 v2 = dum ENDPROC
Using this technique to swap two array elements doesn't work. If you try this:
LOCAL ARRAY a[2] a[1] = 1 a[2] = 2 Swap(@a[1], @a[2])
you'll get Error 11.
Instead, this will work:
LOCAL ARRAY a[2] a[1] = 1 a[2] = 2 ASwap(@a, 1, 2)
PROCEDURE ASwap(p, i1, i2) *!* i1 and i2 are the ELEMENT numbers to be swapped LOCAL dum dum = p[i1] p[i1] = p[i2] p[i2] = dum ENDPROC
Laurie
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]