Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Increasing an array count?

Author
Message
Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 15th Nov 2011 02:48
So I was just wondering, how should I change an arrays amount. Should I do something like this (It doesnt work anyways)



Or just set a max amount?

-------------------------------------------------------------
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 15th Nov 2011 03:15
One reason it might not work is because AmountofText isn't global hence in the function it is always equal to 0. I don't think you need the undim command to increase the array count size. Just call redeclare it as an array using Dim but with the new amount. Like this:



Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 15th Nov 2011 03:39
Oh ok I see.

-------------------------------------------------------------
WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 15th Nov 2011 03:45
This is probable the simplest solution to that problem.

nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 15th Nov 2011 07:17
WickedXGames is right. If you UNDIM and then DIM an array again, it looses all its stored data. That is the purpose of ARRAY INSERT AT TOP, ARRAY INSERT AT BOTTOM, etc. You should browse the CORE COMMANDS in DBPROs help. At 3/4 of the way down you'll find some very useful commands for manipulating arrays.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 17th Nov 2011 02:12
Re-dimensioning retains all previous values (except, I suppose, if you reduce its size instead of increasing it):




"Why do programmers get Halloween and Christmas mixed up?"
nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 17th Nov 2011 11:07
Quote: " Re-dimensioning retains all previous values (except, I suppose, if you reduce its size instead of increasing it): "


I didn't realise you could directly redimension arrays like that in DBPro. I actually looked for a "REDIM" equivalent which didn't seem to be present in DBPro so I turned to ARRAY INSERT AT TOP/BOTTOM instead (situation dependent). I'm sure this'll come in handy though, as "DIM xzy(n)" is less to type than "ARRAY INSERT AT BOTTOM xzy(n), n"

Login to post a reply

Server time is: 2024-11-22 11:01:16
Your offset time is: 2024-11-22 11:01:16