B4J Question Redim array

rameshb

Member
Hi all,

When i want to redim array (using dim with new dimension),do i need to specify its type again?

When i didnt specify the type i redim ,it is taking as string type

and showing error as previous declaration type do not match.
 

LucaMs

Expert
Licensed User
Longtime User
I have noticed one thing to point out (I used B4A but certainly it is the same).

I have declared an array of strings without its size in Globals ( Private mArr() )

I was able to resize the array inside a routine using Dim but also Private.
This means that you can not have two arrays with the same name, one global and one local.

In addition, if a function return as a result an array of the same type, it can automatically resize the array.

mArr = ReturnsAnArrayOfString

Sub ReturnsAnArrayOfString As String()
End Sub
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
This is correct for all variables. Not just arrays.

Yes, in some cases, the IDE will warn you also, I think (or maybe it's the compiler: now my actions are automatic, so I do not note everything :))
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Compiler, a little bit different case
upload_2014-11-5_13-58-18.png
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
This is true. A parameter cannot hide a global variable. However you can "redim" a global variable again.

Thanks, i haven't problem.

That was only related to the previous posts, just to waste time and theorize :)

Sorry, Erel, thanks.
 
Upvote 0
Top