# PureBasic Forum

 It is currently Wed Aug 05, 2020 2:53 am

 All times are UTC + 1 hour

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: [Done]ReDimPosted: Thu Jan 09, 2020 6:21 pm
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6254
Location: Wales, UK
From the Help:
Quote:
If ReDim is used with a multi-dimension array, only its last dimension can be changed.

That's fine, but there should be an example.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.

Top

 Post subject: Re: ReDimPosted: Thu Jan 09, 2020 10:34 pm

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 1126
IdeasVacuum wrote:
If it sounds simple, you have not grasped the complexity.

Maybe I haven't grasped the complexity of your request. For me it sounds simple, even without an example

_________________

Top

 Post subject: Re: ReDimPosted: Fri Jan 10, 2020 12:38 am
 Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 6254
Location: Wales, UK
... documentation should include an example of every function.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.

Top

 Post subject: Re: ReDimPosted: Fri Jan 10, 2020 8:48 pm

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3734
Location: Utah, USA
Would something like this be to the gentleman's liking?
Code:
Dim MyArray.l(1) ; We have 2 elements
MyArray(0) = 1
MyArray(1) = 2

ReDim MyArray(4) ; Now we want 5 elements
MyArray(2) = 3

For k = 0 To 2
Debug MyArray(k)
Next

;Recreate the array with 2 dimensions and a total of 6 elements
;(2 columns × 3 rows). This will clear any previous contents.
Dim MyArray(1, 2)

Debug "---"
For k = 0 To 2 ; row index
For j = 0 To 1 ; column index
Debug "(" + j + ", " + k + ") = " + MyArray(j, k)
Next
Next

MyArray(0, 0) = 1
MyArray(0, 1) = 2
MyArray(1, 0) = 3
MyArray(1, 1) = 4
MyArray(2, 0) = 5
MyArray(2, 1) = 6

Debug "---"
For k = 0 To 2 ; row index
For j = 0 To 1 ; column index
Debug "(" + j + ", " + k + ") = " + MyArray(j, k)
Next
Next

;Now we want to change the number of elements. We can only change
;the size of the last dimension. We change the lastdimension
;from 1 to 3 for a new total of 8 elements (2 columns x 4 rows).
ReDim MyArray(1, 3)

Debug "---"
For k = 0 To 3 ; row index
For j = 0 To 1 ; column index
Debug "(" + j + ", " + k + ") = " + MyArray(j, k)
Next
Next

_________________

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 4 posts ]

 All times are UTC + 1 hour

#### Who is online

Users browsing this forum: No registered users and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

Search for:
 Jump to:  Select a forum ------------------ PureBasic    Coding Questions    Game Programming    3D Programming    Assembly Programming    The PureBasic Editor    The PureBasic Form Designer    General Discussion    Feature Requests and Wishlists    Tricks 'n' Tips Bug Reports    Bugs - Windows    Bugs - Linux    Bugs - Mac OSX    Bugs - IDE    Bugs - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite