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 / newb needs help with arrays/lists

Author
Message
JamesBlond
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Germany
Posted: 27th Oct 2002 16:31
How do I do it that i start with an empty array and then add elements to any dimension in the array using "array insert at bottom"?
I can do it for 1 dimension (starting with dim name(0), then adding elements), but I didn't manage to figure out how to do that for more than one dimension (dim name(0,0,0)).
Can anybody help me here please?
TGWDNGHN
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 27th Oct 2002 16:40
Kinda Like This....


just use it like a normal variable...just as you would do this:

you would do this:
JamesBlond
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Germany
Posted: 27th Oct 2002 19:58
Thx for answering, but that's not what I mean.
I don't want to predefine how many element the array has at the start like you did there (dim name(10,5,2)). I want to start with the array having no elements at all (dim name(0,0,0)) and then adding elements when I need them, that is only if there is more data to store.
JamesBlond
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Germany
Posted: 28th Oct 2002 19:13
Can someone tell me how to even write the command properly (it doesn't say in the help files). For example,
ARRAY INSERT AT BOTTOM Array Name(0)[,Index] becomes what,
ARRAY INSERT AT BOTTOM name(0)[1,0] ?
Or how do I write it that in this case it adds an element to the second dimension for the first element of the first dimension (its really hard putting this into words... )?

If anybody understood what I'm trying to say here pls reply. I really need this.
TGWDNGHN
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 29th Oct 2002 01:00
so sad that it ain't possible...make an array with the max elements you'kll use and fill them up when you need them...it'll be easy to change...

If you need 5,5 elemtns but then need 6,5 elements....just add it in your array...it might mess up some for-loops though but you can handle it....

besides...if you think about it what your asking for is stupid...any more Qs?
JamesBlond
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Germany
Posted: 29th Oct 2002 13:54
So it's only possible for 1 dimension?
The point is, I have a text file with data in it which ANY user should be able to change or add more to it, without changing the program code. Now my program should be able to read all the data into different dimensions of an array, increasing the array size (adding more elements) as more data becomes available, without me having to dim(999,999,999,999,999) just to make sure that all data will be read in...

By the way, there are no stupid questions. I'm new to programming, I didn't develop dbpro and I'm just asking whether a certain feature is possible.

Smile and be happy, things could be worse!
So I smiled and was happy, and things got worse...
ChipOne
22
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 29th Oct 2002 18:42
no one's saying your questions are not valid, young jedi

while your question may valid, it is possible your intentions are not, however.

what purpose would it serve to create an infinately-growing text file? to allow the users to add at a whim section upon section? perhaps you need to look at the problem a different way...

here's one thing you can do:
1) make the text file have only one section in it
2) allow support for multiple text files. i.e., scan all files in a directory.
3) allow support for nested directories, i.e., the user can create directories inside a directory to indicate there is a section inside a section.
4) build your interface so that the user *feels* like they are using a single file. it does not really matter how it is stored.
5) allow users to first select the actual section they want to view/edit/delete and *then* load it into your array.

just one of many possible solutions (although, many databases operate in this way, so it is not, by any means, an uncommon approach).

cheers

-= i only do what my rice krispies tell me to do =-
TGWDNGHN
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 29th Oct 2002 22:43
The maximum dimesions are 5 elements with I believwe it is 256 each...While I'm unsure of the maximum (sub)element number I know you may only have a maximum of 5 elements...in terms of:
Dim array(number,number,number,number,number)
GroovyMysterioso
22
Years of Service
User Offline
Joined: 29th Oct 2002
Location:
Posted: 1st Nov 2002 12:45
I would actually like to hear whether insert array at [whatever] is possible with a multi element array or not. So is it? If it's practicle enough a function to be possible with a single element array then I'd imagine it's practicle enough for a more-than-one element array.
Please, by all means, tell me if I'm takin crazy pills here.

JamesBlond
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Germany
Posted: 2nd Nov 2002 14:39
Doesn't anybody have some examples or code snippets showing some advanced use of arrays, including some commands using lists,stacks and/or queues (in more than one dimensions if possible)?

Smile and be happy, things could be worse!
So I smiled and was happy, and things got worse...
TGWDNGHN
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 2nd Nov 2002 16:09
I checked the commands list and their ain't no way to "add elements"...Why don't you stop trying to add some and just use the maximum amount you will use....

and elements your not using you can leave em blank or put a code world that will instruct your proggram to skip it.

The point is that it is impossible to add elements...why don't you try to make a function that imitates arrays?!
Defoman
22
Years of Service
User Offline
Joined: 1st Nov 2002
Location:
Posted: 3rd Nov 2002 00:10
Mr. Blond's point is a practical one. A dynamic array otherwise known as a linked list or a stack/queue is a pratcial means of storing data without blocking unnecessary unused memory. Unfortunately, I don't think DB has the ability like TGW said and thus this type of functionality would have to be created on your own.

TheCyborg
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 3rd Nov 2002 02:10
I would like to see the code that you use to add 1 dimension.

TheCyborg Development.
http://TheCyborg.Amok.dk
The Ultimate Source To DarkBASIC Programming.
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 3rd Nov 2002 11:39
That's easy.


"If you can't make it good
make it look good."
Bill Gates
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 4th Nov 2002 13:33
theres a 5d array example on my free code page
click the www at the bottom of my post
use the navigation on my site to get the free code

indi is part of Team Lunarpixel
multimedia logisitics and interactive media
TGWDNGHN
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 5th Nov 2002 00:07
Good luck making the function! you'll need it...
TGWDNGHN
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 13th Nov 2002 02:56
just curious but did you mkae thefunction yet or did you at least solve your...um...problem?
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 13th Nov 2002 16:11
I have this "...um...problem" how you call it,too.
But I don't see any easy solution.
Perhaps I should think a little bit about it...

"If you can't make it good
make it look good."
Bill Gates
TGWDNGHN
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 16th Nov 2002 20:03
we can all work together for a solution...though what your asking for may need a mem-block over an array or function...

If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
Kale
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 16th Nov 2002 21:42
Quote: "I want to start with the array having no elements at all (dim name(0,0,0)) and then adding elements when I need them, that is only if there is more data to store."


The 'dynamic' array you are describing is called a 'Linked List' and currently these are not supported by DBPro at this time. But you could add a little more usabilty to a 'dimmed' array by putting the dimension size in element No.1 e.g.:

atleast then you can iterate through these arrays easily by using (0) element as a number to in a for loop.

am i making sense?

What the flame does not consume, consumes the flame.
----------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Pro
Kale
22
Years of Service
User Offline
Joined: 8th Sep 2002
Location: United Kingdom
Posted: 16th Nov 2002 21:48
just to add, i think you can re-Dim an array like in other 'basics' this will clear all data contained within the original array but again you will need some function to count how many pieces of data you wish to store within the array, which is a pain if you dont know until runtime.

simply 'dimming' an array to:


to cope with any eventuallity wil eat memory like me eating pizza's when im drunk!

What the flame does not consume, consumes the flame.
----------------------------------------------------------------------
AMD XP2100+, Geforce4Ti 4400, 512Mb DDR, Abit KX7, WinXP Pro
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 16th Nov 2002 23:13
Hmmm...
I've got a main idea how to do this.
You could save the content of an array in another.
Then you undim the first array and dim it with 1 more place in the dimension you like.
I tried this to code but I don't find the mistake that I'm doing.
Maybe I don't see the forest because of the trees .



"If you can't make it good
make it look good."
Bill Gates
Shadow Robert
22
Years of Service
User Offline
Joined: 22nd Sep 2002
Location: Hertfordshire, England
Posted: 17th Nov 2002 03:53
you can't put and array within a function like that without making it global

DBpro doesn't utilise open arrays right now, you could possibly achieve what you want by using the Stacks - however you'd have to read the data in linear order rather than dynamic - it is far better to simply create a buffer array to store data you want in the meantime of updating the original array

Anata aru kowagaru no watashi!
D Man
22
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 17th Nov 2002 10:03
In debug mode this does work.



"If you can't make it good
make it look good."
Bill Gates
TGWDNGHN
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 17th Nov 2002 17:33
I just don't see why you can't just have an Array with the maximum amount of "data cells" and work from there... if you make a function it would need to involve variabels rather than arrays because arrays cannot be expanded...you can think of a variable as a data cell in an array...I'm really not sure...

If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!

Login to post a reply

Server time is: 2024-11-23 18:24:13
Your offset time is: 2024-11-23 18:24:13