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 / Arrays inside arrays??

Author
Message
el zilcho
17
Years of Service
User Offline
Joined: 4th Dec 2006
Location:
Posted: 4th Apr 2007 18:24
I\'ve been trying to figure out a way of storing an infinite number of co-ordinates into various objects which are already stored in an array, but you can\'t declare an array inside an array.

this is what i have so far:



the only way i can think of doing it is typing in loads of vertices like in the code.

can anyone help?

have i explained this clearly enough?

-EZ-
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Apr 2007 18:37
Add an object id to your existing array. Then, one object is made up of many elements in the array, all linked by a common object id.

SimSmall
20
Years of Service
User Offline
Joined: 7th Aug 2004
Location: United Kingdom
Posted: 4th Apr 2007 18:46
Since there's an array dimensionised, wouldn't it be better to treat the element number as the id? just a thought... unless of course the proposed id, in boxpoints is for something I've not thought about
el zilcho
17
Years of Service
User Offline
Joined: 4th Dec 2006
Location:
Posted: 4th Apr 2007 18:53 Edited at: 4th Apr 2007 18:56
maybe i don't understand, or i may have not explained myself that clearly.

in this code, the maximum number of vertices i can store within a new part of the array is the number of vert1/vert2/vert3's that i've typed into the type BoxPoints.



i want to know how to add infinite amounts of vertices into one object's information. so that for example, everytime i click, a new corner will be added to my shape, and the co-ordinates stored within the array.


sort of like this: (although it wouldn't work, but it might make my message clearer)



then i would just be able to say, array insert at bottom vertex(0)

and voila infinate points.
but again, that wont work.

any ideas?
el zilcho
17
Years of Service
User Offline
Joined: 4th Dec 2006
Location:
Posted: 4th Apr 2007 19:01
also, to make myself clearer, my original idea was to retrieve my data like this:

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 4th Apr 2007 19:14
That is a useful feature that I wish was possible in DBPro, but unfortunatelly, it isnt.

el zilcho
17
Years of Service
User Offline
Joined: 4th Dec 2006
Location:
Posted: 4th Apr 2007 19:35
damn.

is it possible to store a string of numbers in a single variable

say, give the variable, 'VertsAssigned' the numbers 1,2,3,4,7,9.. etc
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Apr 2007 20:00
Yes, but it's inefficient to extract those values or change them.

Here are a few alternatives:

a) Two arrays. One for your 'BoxPoints' array, and one for vertex's. The BoxPoints array holds a single number that holds the ID of the first vertex from the second array. The vertex array is built using a type that holds the x and y coords you require, but also a 'NextID' entry which identified the next vertex to use. If the NextID is set to -1, then there is no next vertex.

Here's an example that you can use as a guide - it was for a war strategy game of some type - A square grid, where each entry on the grid can hold an unlimited number of units:


b) One array and some low-level mucking around. Your BoxPoints array holds counter for the number of vertex's it holds, and a memory address.

It's probably easier to show you that one:


Both BoxPoints and vertex's start from 0. This code also requires the use of one of my utility plug-ins (low-level memory access). You could do it with memblocks instead, but you limit yourself to 255 BoxPoints (255 for actual storage, and 1 left for copying when expanding an existing memblock).

Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 4th Apr 2007 20:46 Edited at: 4th Apr 2007 20:47
You could just use a 2D scalable array. It would be a lot easier to do than direct RAM accessing but could be wasteful on memory because every time you add a vertex a space gets added not only for the box you want, but every box. (Only if it's the box with the most vertices though)

By reading this sentence you have given me brief control of your mind.
el zilcho
17
Years of Service
User Offline
Joined: 4th Dec 2006
Location:
Posted: 4th Apr 2007 20:49 Edited at: 4th Apr 2007 20:50
Thanks IanM. that's really helpfull. i'll see if i can implement that second idea.

@codedragon, what's a scaleable array?
Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 4th Apr 2007 21:17
A scalable array is an array you can add and delete elements from. array insert at bottom and array delete element are the commands for 1D arrays, but if you want to resize 2D arrays just dim them again.

Here's an example:



By reading this sentence you have given me brief control of your mind.
Milkman
18
Years of Service
User Offline
Joined: 30th Nov 2005
Location: United States
Posted: 4th Apr 2007 22:19 Edited at: 4th Apr 2007 22:27
You are able to easily do something like this (arrays within arrays) with oodbp. You would just dimension an array of class objects, with the class containing an array in its definition.

For example,


The beta will be released soon.

PS: i'm still deciding whether to use the '~' or '.' operator to access methods of objects. Which would you prefer?

I think the latter is more clear. Unfortunately, i was not able to have methods called like this:


Who needs a signature?

Login to post a reply

Server time is: 2024-11-25 20:23:23
Your offset time is: 2024-11-25 20:23:23