Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
redimming deletes original contents
#1
completely noob question here, but when i redim something it's original contents are deleted. How can i prevent this?
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#2
If you're compiler takes it you should be able to do:

REDIM PRESERVE VariableName AS DataType

that should keep it's contents.
hen they say it can't be done, THAT's when they call me ;-).

[Image: kaffee.gif]
[Image: mystikshadows.png]

need hosting: http://www.jc-hosting.net
All about ASCII: http://www.ascii-world.com
Reply
#3
only qb7.1 version alows that. qb45 won't so if your working with 4.5 version you will need to keep a temp array to store the old contain while your rediming the the main array.
Reply
#4
Thanks

Will that work in fb too?
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#5
Yes, Freebasic can do REDIM Preserve :-)
hen they say it can't be done, THAT's when they call me ;-).

[Image: kaffee.gif]
[Image: mystikshadows.png]

need hosting: http://www.jc-hosting.net
All about ASCII: http://www.ascii-world.com
Reply
#6
Just out of curiosity, why are you doing a REDIM in the first place?
*****
Reply
#7
Quote:Just out of curiosity, why are you doing a REDIM in the first place?
*****

For some reason when i tried to use DIM SHARED it didn't work...dunno why.

It seems to be working now....come to think of it i recently deleted and rewrote a large part of the sub, maybe i fixed something that was broken...
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#8
if you need to do it in qb45, as it doesnt support PRESERVE, you can copy the array contents to temporary array of same size, redim the array and then copy back from the temporary. Thats how I used to pull it off. And im sure how many others did as well.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)