• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

public variables, scope, local variables, and function calls

Started by Eduardo Jorge, June 11, 2018, 02:58:50 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Charles Pegge

In o2, redim is  really a macro for creating and resizing dynamic arrays, whereas dim can only create fixed-size arrays and other variables.

You can repeatedly redim an array to resize it, and the original data will be preserved.

Eduardo Jorge

Charles,
in case I want to resize an array that has been declared publicly

dim int ArrayK[100]

sub aa()
int t=50
  redim  int ArrayK[t]
   ArrayK (20) = 100
  print ArrayK (20)
end sub

call  aa

print ArrayK (20)




Charles Pegge

#17
You can make your initial redim with 0 elements, if you prefer. But it must be a redim


redim int ArrayK[0]

sub aa()
int t=50
  redim  int ArrayK[t]
   ArrayK (20) = 100
  print ArrayK (20)
end sub

aa()

print ArrayK (20)


Eduardo Jorge

Thanks, Charles.
it's one more thing to go for help and for the manual