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

Just starting out? Need help? Post your questions and find answers here.
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

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

Post 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
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

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

Post 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.
User avatar
Demivec
Addict
Addict
Posts: 4266
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

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

Post 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.
Post Reply