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 / [DB Classic] A Question about Arrays: Why only 5D?

Author
Message
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Jun 2006 23:02
Wandering Swordsman, look back at my example again. You still have 2 dimensions, and you only have one piece of data per element. The only difference is that the first element represents a grid reference (1 - 1000), rather than 3 dimensions for X,Y and Z coordinates.



Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 30th Jun 2006 23:29 Edited at: 30th Jun 2006 23:38
Ok, is this correct then?

4D array with 1D handling 1-3Ds and 4D handling what data type your looking at.
Array(XYZ,DataType)

Array(10,10,10,6) With values of 4,5,3,1 would look like
Array(1000,6) = 5642

Or if I'm using double digits:
Array(1000,6) = 05060402

And if I stuck a variable on the end, say 5, it would look like this:
Array(1000,6) = 56426
(Or)
Array(1000,6) = 0506040206

Ack, no. I've got it backwards, it's not +1 it's -1... or is it.

Oops!

My mistake, these would be correct then?
Array(1000,6) = 34204
(Or)
Array(1000,6) = 0304020004


Have I still missed the mark?


(((EDIT - Text below this point is added)))

I think I've made an error... 2nd edit to this post in-progress...
(1 second...)


(((EDIT, again - Text below this point is added)))

Ok... (Ack, it is +1. 0 = 1, 1 = 2, 2 = 3, etc...)

Array(10,10,10,6) With values of 4,5,3. Data Type 4 and stored variable of 6 would look like:
DIM Array(1000,6)
Array(564,3) = 6
(OR if I'm using double digits for the XYZ)
Array(050604,3) = 6

Is my thinking still messed up or is that correct?

When I dream,
I carry a sword in one hand,
a gun in the other...
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 1st Jul 2006 05:17
Quote: "For arguments sake just pretend the array has to be that way:

- Can it be that way?"

Yes, but it shouldn't

Quote: "- Will a DBC program run with an array of this size loaded?"

Yes

Quote: "- Will a DBC program run with more than one array of this size loaded?"

Most likely, depends on how many arrays you put in.

Quote: "- Crit mentioned that a very large program probably won't compile in DBC. Why not? And how large? (Is this dependant on the RAM of the computer compiling it?)
"

You tell me - run this file, then try to open and compile c:\test.dba



Quote: "- X Trade mentioned a severe speed hit, how heavy a hit will it be?
(And will this be a constant speed loss, or only when certain things/commands are happening?)"

The mere fact that the array exists will not slow the program down. But if you try to access each element during every loop, your program will be slower than molassas going uphill in January.

Quote: "- Can the speed hit be remedied via large amounts of RAM or a good CPU?"

No.

Quote: "- X Trade mentioned using DarkEDIT to create Types in DBC, two questions. Will this allow greater then 5D arrays and where can I get information on how to do this in DarkEDIT?"

Dark Edit won't give you more dimensions, but Dark Basic Pro allows arrays of 9 dimensions.

CHESS ENCOUNTER
Demo
WIP
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Jul 2006 11:37
Quote: "Array(10,10,10,6) With values of 4,5,3,1 would look like
Array(1000,6) = 5642"


Array(1000,1) = 5
Array(1000,2) = 6
Array(1000,3) = 4
Array(1000,4) = 2



Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 2nd Jul 2006 02:41 Edited at: 2nd Jul 2006 02:47
Crit:
Quote: "Yes, but it shouldn't"

Excellent.

Crit:
Quote: "Yes"

That's great! I was kind of worried about this one.

Crit:
Quote: "Most likely, depends on how many arrays you put in."

I don't think I'm going to be using more than... 10 at the most?
(And that's stretching it, I think I can get by with only 3 or 5)

Crit:
Quote: "You tell me - run this file, then try to open and compile c:test.dba"

Ok. I'll run it and post the results to this thread.
*Copy, Past, Run...*
(if file exist ("c:test.dba") then delete file "c:test.dba")
"Syntax Error, Unrecognized Parameter"

DBC gave an error referencing the second line of your code snippet?

Crit:
Quote: "The mere fact that the array exists will not slow the program down. But if you try to access each element during every loop, your program will be slower than molassas going uphill in January."

So, as long as I only read/write data from/to a small number of the coordinates at a time. Everything is good? (Perfect!!!)

Crit:
Quote: "No."

Dang.

Crit:
Quote: "Dark Edit won't give you more dimensions, but Dark Basic Pro allows arrays of 9 dimensions."

Somehow I thought I misinterpreted that DarkEDIT comment.

9D in DBP... and that’s before adding 'types'. *Grins* That definitely has interesting possibilities.

BatVink:
Quote: "Array(1000,1) = 5
Array(1000,2) = 6
Array(1000,3) = 4
Array(1000,4) = 2"

... Ah!
Alright I think I see what you mean now:
Array(A,B)
'A' = The entry number, current 'object/entity/etc'
'B' = X, Y, Z, ETC data. (The current type of data related to the 'A' object.)

Did I get it that time?

(((EDIT - Text below this point is added)))

Just to clarify farther...
Example:
Array(A,B)
'B' = 1 = X
'B' = 2 = Y
'B' = 3 = Z

So a Array(1000,6) where I wanted to store X = 12, Y = 5 & Z = 2 to object 234 would look like:
Array(234,1) = 12
Array(234,2) = 5
Array(234,3) = 2

Is that what you mean?

When I dream,
I carry a sword in one hand,
a gun in the other...
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 2nd Jul 2006 07:22
Thought I'd join in on this heated discussion;

It sounds to me that you're trying to give each viable position in your game (be it a tile, a house, a planet, whatever) an array (excuse the pun) of values.

using the planet example, you might have an array like so;

Planet(Earth,Population,Girls,Teenagers,Intelligent) = 5

Giving 5 Intelligent teenaged girls from the population of Earth to the game. I've not much time to explain now but why not look into using TYPEs to handle this, that is if this is what you're trying to achieve?

(And really, if you give better info on why you want this / what you're trying to achieve, it'd really help. We wont steal a game idea, let alone steel one based on the reasoning behind an array structure.)

Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 2nd Jul 2006 09:38 Edited at: 2nd Jul 2006 09:52
RUCCUS:
Quote: "Planet(Earth,Population,Girls,Teenagers,Intelligent) = 5"

The coordinates in the array are coordinates. This is not stored object, player, speed, stat, health, etc data.

Example:

Don't get confused by my example, that's not how my coordinate sets interrelate. I'm just trying to dislodge the idea that they're storing something like this:
5DTankArrayOfTankness(TankType,PilotType,ArmorType,WeaponType,TreadType)
(Or)
5DTankArrayWithXY(TankX,TankY,TankType,WeaponType,TankHealth)

On a 2D map you need X & Y to find a specific point.
On a 3D map you need X, Y & Z to find that point.
I am using many more dimensional coordinates.

The meanings of Dimensions 3,4,5 in my 5D (Possibly more then 5D if it‘s possible...) still remain shrouded in mystery.
(The exact nature of dimensions 3 and higher would give much away.)

3D is limiting... 5D and higher in 2D is fun...
(Just think about it, the possibilities are almost endless...)
Perhaps I’ve said too much, perhaps not enough...


RUCCUS:
Quote: "why not look into using TYPEs"

I'm using DBC judging from what I’ve read so far it does not allow for TYPEs, although X Trade has mentioned DarkEDIT can allow DBC to use them.




5D array becomes compressed into a 1D array like so:
Array1D(1010107052)

Add data type allowing multiple variables related to the same ‘point’ to be stored in the same array creates this 2D Array: (This second coordinate is set at a maximum of 6,or 7 if 0=1, and isn’t storing coordinate data.)
Array2D(1010107052,6)

In theory (With my current understanding) an almost infinite #D array is possible, example 8D with data types :
Array8D(10101070521010,6)

So by storing the numbers ##-##-##-##-## like ########## this is possible?

So, for example: If I wanted data type 3’s value to be 45 at coordinates 8,7,3,23,43,2,3 of my example 8D array then it would look like this?
Array8D(08070323430203,3) = 45

by using 0#0#0# I can have double digits allowing easy separation of the numbers...
if it is not possible to hold 0 as the first number of an array, example:
DIM Array(1000)
Array(0020) = 43

Than I can store it like this:
Array8D(#10101070521010,6)
where # is any number between 1-9. I’ll ignore the # number, it is only a placeholder to allow for double digit storage elsewhere in the array.

Example of placeholder number:
Array8D(#10101070521010,6) <--- Placeholder number = #
Array8D(110101070521010,6) <--- Placeholder number = 1
Array8D(1 10-10-10-70-52-10-10,6) <---Array Spaced for easy viewing. (Not for use in actual code, just an example.)

Each coordinate can only have a max value of 99(100 if 0=1) in this system. Of course triple digit storage and so on would be possible. This allows infinite #D arrays and infinite coordinate max values. (Limited only by DBC’s line length. (Is that limited?).... unless...

You store your numbers in several variables like this:

Each variable handles the next set of numerical place value. (I just randomly assigned values, there’s no pattern save where the string of zeros begins.)


Then add each variable into one massive variable:
MassiveArrayVariable = PlaceholderVariable + MassiveArrayVariablePart1 + MassiveArrayVariablePart2 + MassiveArrayVariablePart3

Then do this to build it:
DIM VeryMassiveArray(MassiveArrayVariable)

And you have a 1D 93D array if your using double digits.

I’ve created a monster...
*Takes out an old worn leather map and spreads it across desk before pointing to the place.”
“Aye cap’n, coordinates 10,10,10,70,50,10,10,3... there be monsters...”


It’s all simple math... just on a massive scale...


(((POST EDIT INFO)))
My 1st code snippet was messed up, I've fixed it.

(((POST 2ND EDIT INFO)))
What the heck, it keeps removing all '\' from the snippet.

(((POST 3ND EDIT INFO)))
Minor typo fixes...

Lots of editing done on this post.

When I dream,
I carry a sword in one hand,
a gun in the other...
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 2nd Jul 2006 11:26 Edited at: 2nd Jul 2006 11:26
Ok, 5D co-ordinates! I'm impressed!

Reason why - only a few of the top mathematicians and physicists on the planet are able to think/calculate in the (predicted) higher dimensions. Tesseracts are 4D cubes, also called hypercubes. You might need 4D co-ordinates if you are going to map these to 3D to get an approximation. See hypercube for some more info.

You would still only need an array that looks like this though: dim HypercubePoints(num,3) where num is the number of hypercubes you want to model.
HypercubePoints(1,0) gives x coord
HypercubePoints(1,1) gives y coord
HypercubePoints(1,2) gives z coord
HypercubePoints(1,3) gives w coord

Gives us another clue, as I really think you are going badly wrong with this whole array business!

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 3rd Jul 2006 04:42 Edited at: 3rd Jul 2006 04:42
Dream And Death:
Quote: "Tesseracts are 4D cubes, also called hypercubes."

I was unaware of what that term meant until just now, very interesting reading. Thanks for the link. (I've also found another interesting article 'here' at wikipedia.)

Dream And Death:
Quote: "HypercubePoints(1,0) gives x coord
HypercubePoints(1,1) gives y coord
HypercubePoints(1,2) gives z coord
HypercubePoints(1,3) gives w coord"

If I store the data by using one coordinate(D) for each set of spatial coordinates, how would I use them in math as variables?

Example:
DIM 5DExampleArray(10,10,10,10,10)
Array(ArrayX,ArrayY,ArrayZ,ArrayA,ArrayB)

I can change the current coordinate value stored in any of the variables via math or changing the variable to a set number manually.

Is it possible to reference different variables to different coordinate values?



In order to do this, I would need to... *Trails off in thought...*

Dump the variables to separate variables then re-enter them into the array when the calculations are finished?

Example: (I‘m going to use the For/Next loop in this example. I’m still new to this command, so if I get it wrong please point it out.)



Does that make any sense?

When I dream,
I carry a sword in one hand,
a gun in the other...
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 3rd Jul 2006 12:26
@Wandering Swordsman

I'm glad you found some interest in hypercubes!

Your idea at the end is valid, but there is little point. Far easier and efficient to:

Hope this helps!

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
X Trade
20
Years of Service
User Offline
Joined: 19th Feb 2004
Location: near bristol, UK
Posted: 3rd Jul 2006 16:58
Quote: "FOR XYZ = 0 to 2
IF XYZ = 0 THEN ArrayXVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 1 THEN ArrayYVar = ExampleArray2DIsXYZ(1,XYZ)
IF XYZ = 2 THEN ArrayZVar = ExampleArray2DIsXYZ(1,XYZ)
NEXT XYZ
"


i think really it would be easier here just to write:

ArrayXVar = ExampleArray2DIsXYZ(1,0)
ArrayYVar = ExampleArray2DIsXYZ(1,1)
ArayZVar = ExampleArray2DIsXYZ(1,2)


for-next loops are more useful when you need to get through a list of things quickly... like if you were managing a list of space ships, with their health, x, y, z, etc information.. but you woulfn't use the loop for the information, just for the object number/index
e.g.

rem array(n, 0) = x pos
rem array(n, 1) = y pos
rem array(n, 2) = z pos
rem array(n, 3) = shields
rem etc

do
for i = 1 to number_of_spaceships
shields = array(i, 3)
shields = shields - 1
array(i, 3) = shields
position object i, array(i, 0), array(i, 1), array(i, 2)
etc
next i
loop


Quote: "If I store the data by using one coordinate(D) for each set of spatial coordinates, how would I use them in math as variables?"


having said that, it also comes to mind that i should point out, an array is essentially a list of variables, so you do not actually need to get the contents, and can just use the array in a statement normally, e.g. (using types here just to make it easier to read)
position object obj(i).num, obj(i).x, obj(i).y, obj(i).z
or
pos(x, y, z, 3) = pos(x, y, z, 2) + (12*5) - obj(i, 12)

www.AoFP.co.uk
wschramm
21
Years of Service
User Offline
Joined: 22nd Jan 2003
Location: Ohio
Posted: 4th Jul 2006 22:28 Edited at: 4th Jul 2006 23:11
I'll take a stab at the secret. wants to use the array to store a campaign map data. and was hoping to use a 10 element array to simulate a 10 digit grid cooridnte. most likley for a form of navel simulation??



this can track a 5000x5000 map using about 227megs of ram that is 25,000,000 points!!!! on a map or such so use this instead of a 10 element array.


if you wanted a Z coor you could do dim LOCATION(mapsize,mapsize) but that would be a 125,000,000,000 point map and take well over a terrabyte of memory to run


your array as pictured at 7d RFRF(10,10,10,10,10,10,10) would be 10,000,000 points stored in memory and would take about 157mb for the final exe to run.

I think I understand why you want the array this way, kind of a zoom element to the map each level of the map is 10x10 and as it goes down each square on the bigger map has has 10x10 squares of a lower map??

if so it is best to make the map 1 big map and use math to extrapulate the 7d coor to display to player.

Like Science Fiction novels pick up a copy of Gatecrash from publish america. Link is on http://www.gaterunner.com
Crit
18
Years of Service
User Offline
Joined: 24th May 2006
Location:
Posted: 5th Jul 2006 15:52
@Wandering Swordsman, that line of code was just an extra check. You can delete it and it should still run correctly.

Quote: "
(if file exist ("c:test.dba") then delete file "c:test.dba")
"Syntax Error, Unrecognized Parameter"
"


I have enough trouble thinking in 3D, so if you can think in 5D, this should be an interesting project. What does your timeline look like?

CHESS ENCOUNTER
Demo
WIP
Wandering Swordsman
18
Years of Service
User Offline
Joined: 14th Jun 2006
Location:
Posted: 7th Jul 2006 08:23 Edited at: 7th Jul 2006 08:38
@Dream And Death:
*Reads the code snippet*
Ok, I think I see what your saying.
If I understand this correctly by adding the math to the end of the array without placing an = you effect the last digit of the array instead of the value held at the coordinates.

Example:
Array(1,1)+1 Becomes Array(1,2)

If so, how do I alter the coordinates before the last coordinate? I was unaware you could perform math on an array like this.


X Trade:
Quote: "i think really it would be easier here just to write:

ArrayXVar = ExampleArray2DIsXYZ(1,0)
ArrayYVar = ExampleArray2DIsXYZ(1,1)
ArayZVar = ExampleArray2DIsXYZ(1,2)"

I see what you mean, but what if it was much larger in the number of types of data stored in the 2D.

Example: (I'm still using XYZ as the For/Next variable. Changing it to match the letters of the retrieved coordinates would just be cosmetic: XYZABCDEF)



It would then be possible to retrieve specific coordinates only by changing the For/Next loop decay (I don't know the term it's called) variables.

Example: (FNFirst FNLast variables added to For/Next.)


And the current object being worked on by the For/Next could be determined by a For/Next encompassing that, allowing objects to be worked on in sequence.

Example: (Variables CurrentObject, FNCOF & FNCOL added & 2nd For/Next loop.)





X Trade:
Quote: "(using types here just to make it easier to read)"

I don't completely understand types yet. I don't have DBP up and running at the moment. (Not an option, my DX9 capable graphics card needs to be replaced so I'm running off an older DX8 capable card. )

If I understand this correctly:
"pos(x, y, z, 3) = pos(x, y, z, 2) + (12*5) - obj(i, 12)"

The array 'pos(x, y, z, 3)'s stored value is now 'pos(x, y, z, 2)' + 60 - the array 'obj(i,12)

...

I'm not understanding this. Is this changing the value of the array coordinates or the value contained at those coordinates?


wschramm:
Quote: "10 element array to simulate a 10 digit grid cooridnte"

True I am building a form of 10x10 grid for this project.

wschramm:
Quote: "for a form of navel simulation??"

That 'is' on my list of things to do, and I was planning on using arrays to store the map data for it. But it isn't the goal of this project.

For the 'navel simulation' I figure I'll be using some kind of X,Y,DataType 3D Array where the data types hold information such as depth of the water, type of water, temperature of area, etc... (Got sidetracked, Concept design is still rough and no actual code has been written on that project.)


wschramm:
Quote: "this can track a 5000x5000 map using about 227megs of ram that is 25,000,000 points!!!! on a map or such so use this instead of a 10 element array."

*Reads through the code snippet several times... then runs it via DBC.*

Odd, 'DATA retrieved :' always equals 0 when I run the program.

*Scans over the code snippet repeatedly...*
Ack, I can't see why it's doing that.

Alright. I think I see what your doing:


You first assign the size of the total map by giving the value of one of its NW,NE,SW,SE quadrants. This is placed into the variable mapsize.

This value is then expanded to the full map size and a global 1D array is created with that value in it as it's maximum coordinate value.

A set of 'X' & 'Y' coordinates are selected and the variables for them are dumped to XX & YY.

The value of the variable 'datapoints'
is changed to the value of YY * mapsize + XX. datapoints was used previously to determine the maximum value for the 1D array, here it is being used to determine a coordinate set within the already created array.

Then the value stored in the 1D array at the datapoints coordinate(s) is entered.


Now the process of retrieving the information begins.

Two new variables are created NYY & NXX.

NYY's value is that of the variable 'datapoints' divided by the value of 'mapsize'.

Then NXX's value is determined by subtracting the value of 'NYY' multiplied by 'mapsize' from datapoints.

The coordinate(s) to retrieve the data from the 1D array are then placed in the datapoints variable. The value of which is determined by multiplying NYY by mapsize then adding the value of NXX.

The value of the 1D array at the coordinate(s) of datapoints are then printed to the screen.
(Should be anyway... always prints 0 when I run the program?)

After that the program waits for a key press then restarts the loop/process.

Do I have the process of your method correct? (Why doesn't it return the stored data value.)

I found it a little more complicated then a normal Array command, had to work through it slowly to figure out how it was doing everything. I've got to brush up on my math.

If I understand correctly this method uses less RAM then a regular Array command?
*Whips out a calculator and uses the method for finding ram use described in previous posts on this thread.*
25,000,000 (number of positions) * 4(bytes) = 100,000,000(bytes) = (/1024 for Kb) = 97656.25(Kb) (/1024 for Mb)=95.367431640625(Mb)

95.3Mb vs 227Mb

Alright, now I’m confused. Is your method less memory efficient? Or have I calculated the RAM data wrong.

wschramm:
Quote: "I think I understand why you want the array this way, kind of a zoom element to the map each level of the map is 10x10 and as it goes down each square on the bigger map has has 10x10 squares of a lower map??"

So in for example:
DIM Array(10,10,10,10,10,10)
Array(X,Y,A,B,C,D)
So: X,Y would be a coordinate and A,B would be a coordinate in X,Y and C,D would be a coordinate in A,B?

I'm not using a 'zooming' feature of that nature in this project.

wschramm:
Quote: "if so it is best to make the map 1 big map and use math to extrapulate the 7d coor to display to player."

Wouldn't that only be possible in 3D? (I don't mean a 3D array, I mean graphics.)


Crit:
Quote: "You can delete it and it should still run correctly."

Ok.

Code changed to this for convenience:


*File built, opens file in DBC Editor... took a second but no problems. Selects Build Final .Exe and waits... and waits... waiting... Status bar with 10% appears, 20%, 30%, 10%?, 20%, 30%, 40%, 50%, 10%?, 20%, 30%, 40% ,50%, 60%, ETC, 100%... waits... waits, waits... waits some more... 30mins later: Attempts ALT-TAB, ALT-F4, CTRL-ALT-DEL... sadly hits the reset button on his case...*

Alright well that's not going to work.
But if I store the data in an external file there won't be a problem right?

Any suggestions on a way to load the information from an external file into a 5D array in DBC?


Crit:
Quote: "What does your timeline look like?"

Timeline? Do you mean the timeline for the projects completion?
*Thinks about it for a second or two...*
This projects pretty big, a lot still needs to be done. I’ve still got to finish pieces of the engine (Until I get all the data entered there isn’t much point in finishing it.) and enter in all the data from the concept notes/files. Then some stat balancing... the sprites/art... stories not a problem so far, although editing the dialog together could take a bit...

It’s going to take quite sometime before it’s done but it ‘will’ be done eventually.
Three months would be being very optimistic for a working demo of the first areas.
*Shrugs*

Plus, I hope to be releasing other games in the meantime while I work on this project.
(I have a smaller project, an ‘almost-finished’ dungeon crawl/RPG that I may be releasing in a bit. Just need to finish the engine, almost all of the data the engine calls is already entered. )

A few of my other projects designs also call for the use multi-coordinate arrays, although mostly not for the same reasons. And none of the others on this scale (Which is good, because I figure one massive project at a time is enough.)

Going is slow because of the size of it. A lot gets done every day.

When I dream,
I carry a sword in one hand,
a gun in the other...
X Trade
20
Years of Service
User Offline
Joined: 19th Feb 2004
Location: near bristol, UK
Posted: 7th Jul 2006 19:15
I will explain from the start..
but first of all, you example of for-next loops is still partially wrong:


the bit of concern is this:

and the similar chunks.
The main purpose of for-next loops is to save coding space.. if you think about it, writing:

-style statements like you have done, take up more code than simply writing


Thus, there is no difference.. you do not need to use a for next loop for that kind of specific thing.. as you are having to write out the numbers anyway, you are not saving yourself anything at all.
a more correct and time-saving example would be:

if you wrote the same code with your method shown above (the one you did with the 'if xyz =' stuff), it would take upto 4 more lines of code, and multiple if statements which are just using up processing time and thus slowing down the running/loading of your application.

Now, arrays.
you are right in that arrays have co-ordinates.. you can think of this as a row of variables (for a 1d array), or a table or grid (for a 2d array), or even a cube (for a 3d array). or a cube which changes over time (for a 4d array), it gets even more complicated after that.. but you get the point.
But arrays are essentially variables, just big collections of variables, which you can access and address(reference) by co-ordinate or 'index' numbers (like a database table).
Because they are variables, they can be treated the same as any other varaible of that data type, be it a string or an integer..
so, if you understand that the logic of 'a = a + 1' will progress the variable 'a' by one, and 'a = a * b' SET the value of 'a' to become the origional value of 'a' multiplied by 'b', we can apply the same logic to arrays..
using my previous example, we can turn those 6 operational lines within my for-next loop, into a mere three.. much easier to read, takes up less lines, and generally better programming practise, as you are not just shunting memory around for the hell of it.
so my previous example, now becomes this:


of course, when you start using types, this becomes much easier to read and understand still:

if you have ever used VB then understanding types will come quite naturally, as you will be used to doing things like accessing a control's parameters.. (e.g. 'text1.text', 'text1.backcolor', etc) and this becomes even more relevant if you have ever worked with control arrays (where you get things like 'command1(5).caption'

www.AoFP.co.uk
Lord Einstein
19
Years of Service
User Offline
Joined: 22nd Oct 2005
Location: Well here, of course...
Posted: 2nd Aug 2006 00:33 Edited at: 4th Aug 2006 00:36
If you need an array bigger than 5D then you could use many many arrays located inside numbered files. If you had a file named 1,2,3 and so on till 10 and inside each of those you had a files named 1 to 10 you could keep going for ever and still place many arrays inside each of those files. You will just have to tell the computer to load the array:

load array str$(a)+"/"+str$(b)+"/"+str$(c) . . .

The data consumtion is still gigantic but may make you computer run faster without having to store so many variables at the same time and being able to refer to them easily.

I didn't read all of the other posts so I don't know if someone has posted this idea already.
karate man
18
Years of Service
User Offline
Joined: 1st Aug 2006
Location:
Posted: 2nd Aug 2006 06:41
what are you planning on doing???
because that is HUGE!!!!
karate man
18
Years of Service
User Offline
Joined: 1st Aug 2006
Location:
Posted: 2nd Aug 2006 06:41
what are you planning on doing???
because that is HUGE!!!!

Login to post a reply

Server time is: 2024-11-26 14:38:10
Your offset time is: 2024-11-26 14:38:10