Page 1 of 1

[pb450 b3 x86] DIM and Swap in combiantion = IMA

Posted: Mon May 03, 2010 4:03 pm
by walker
see http://www.purebasic.fr/english/viewtop ... 04&start=0 for details

this code causes an IMA because after the second Swap (and DIM) array_1 dimensions are set to -1,-1

Code: Select all

Dim array_1.s(1, 10)
Dim array_2.s(0, 0)
;create some content
For x = 1 To 10
    array_1(1, x) = Chr(60 + x)
Next

rows = 1
cols = 10

For m = 1 To 2
    nrows = rows
    ncols = cols
    Dim array_2.s(0, 0); set content to nothing
    Dim array_2.s(nrows, ncols)
    Swap array_1(), array_2()

    Debug array_2(1, m)

    Dim array_1.s(0, 0)
    Dim array_1.s(nrows, ncols)
    Swap array_2(), array_1(); now array_1 should contain the original content .. but is set to -1,-1 ....
    rows = nrows
    cols = ncols
Next

Re: [pb450 b3 x86] DIM and Swap in combiantion = IMA

Posted: Mon May 03, 2010 5:08 pm
by Trond
The shorter version:

Code: Select all

Dim array_1.s(1)
Dim array_2.s(1)

Swap array_1(), array_2()
Dim  array_1(1)
CallDebugger
Array dimensions are set to -1,-1 when using Dim after Swap.

Re: [pb450 b3 x86] DIM and Swap in combiantion = IMA

Posted: Mon May 03, 2010 8:27 pm
by Demivec
Fred already responded to the bug report here, that using swap this way is not be supported (even though it was in the help file and worked in earlier versions).

Here is a previous bug report regarding Redim here.