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 / Array help...

Author
Message
Reggie12
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location:
Posted: 23rd Mar 2009 12:43
im having problems using the array insert at bottom command.
i am new to DBPro and the help files dont help much.
the arrays are declared as follows:



I think it is this code that is not working; i thought it may have something to do with how the arrays are declared but have never used these commands before.

HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 23rd Mar 2009 16:57
try taking the zeros out.



Dark Physics makes any hot drink go cold.
Pillarofire
20
Years of Service
User Offline
Joined: 31st Dec 2003
Location: Good Question, <looks around.>
Posted: 24th Mar 2009 12:04
Quote: "try taking the zeros out."


Good thought but that is perfectly legal, that's not the problem.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 24th Mar 2009 12:43
What exactly is it that does not work?
That command adds a new index at the end of the array, which you then have to fill yourself.
If it does indeed not add another element, then you could always try re-dimensioning the array (which you have to do if you are using an UDT array anyway), like so:


Reggie12
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location:
Posted: 24th Mar 2009 16:44
I took the zeros out and it works now, interesting that both methods are legal and one does not work. It was not adding another element to the array, i used array count to check.
Could this be a problem with dark basic?

Thanks for the help.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 24th Mar 2009 16:45
Quote: "If it does indeed not add another element, then you could always try re-dimensioning the array (which you have to do if you are using an UDT array anyway), like so:"


Doesn't doing that erase the contents of the array? Also, I've used ARRAY INSERT AT BOTTOM on UDT arrays lots of times.


@Reggie: That code should work. Could you tell us what it is you are trying to do with that, exactly?

<---Spell casting battle game!
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 24th Mar 2009 17:03
No, it doesn't.
Yes, apparently you can, but it messes up any strings in there I think. Or maybe that only happened when undiming them... I can't really remember, but I recall there being some reason that you should redim your udt arrays instead of inserting elements to them. Have always done so since anyways, maybe it isn't necessary after all
Anyways, it works quickly and leaves all data intact, so there is no downside to doing it.

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 24th Mar 2009 23:04 Edited at: 24th Mar 2009 23:07
Wow I didn't know the DIM command didn't erase the data! That's good to know...

By the way, this works. My game relies heavily on it . Also, the ARRAY DELETE ELEMENT command can be used as well (and it automatically shifts everything else in the array down which is great)



Maybe you were thinking of multi-dimensional UDT arrays, in which case the DIM method would have to be used.

<---Spell casting battle game!
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 24th Mar 2009 23:31
Quote: "Maybe you were thinking of multi-dimensional UDT arrays, in which case the DIM method would have to be used."

Now that you say it, that was it. So I've been shifting my (single dimension) arrays manually for a long time in vain then..
Well, as I said, it works just fine anyway, so no big problem, apart from some extra work then

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 25th Mar 2009 00:00
Thanks for pointing that out though! Now I can expand multi-dimensional arrays .

Anyway, until Reggie12 tells us what he's after we can't really help much...

<---Spell casting battle game!
Reggie12
15
Years of Service
User Offline
Joined: 11th Mar 2009
Location:
Posted: 25th Mar 2009 14:24
Its all working now, the problem seems to go away when i take the zeros out; probably something to do with accessing it like a dynamic array rather than a list.
Thanks for the help

Login to post a reply

Server time is: 2024-11-24 11:52:21
Your offset time is: 2024-11-24 11:52:21