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.

DarkBASIC Discussion / Array Length & Depth...?

Author
Message
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 16th Oct 2003 15:14
Howdy, ya'll

Is it possible to find out how many dimensions an array has?

I have an array which has its dimensions set due to a variable wich can be anywhere between 10 to 100. and i was wondering if there is anyway to find out how long the array is?

Here is some code:



How could i find the lenght of that array.

I know i could find the size of the variable used to set it, but i want to find the lenght of the array inside a function so therefore i cant use my_variable to find it out.

Thanks in Advance...

Knowladge Belongs To The People...
JSCskycap
21
Years of Service
User Offline
Joined: 22nd Sep 2003
Location: Townsend, MA, USA
Posted: 17th Oct 2003 06:48
Not sure I understand the question.

The variable "my_variable will not be constant and you want to know, at any given time what the value is? How do you want to know? I guess, you could just output the variable at the start of the function. The array can only be as long as the variable in the dim statement, right? Maybe I still don't get the question.
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 17th Oct 2003 08:02 Edited at: 17th Oct 2003 08:08
Um, no, sorry, i didnt explain it properly... ill try explaining it in code;



Now, how do i find the length of this array from within the function, bcause i cant find the lenght of my_variable from within the function (the way i have my actual function set-up, i cant use anthing like _my_function(my_variable) )

Is there like a command such as Get Array Lenght(my_array()) or anyhing?

Or, if not, is there a way of finding the length of the array from within the function in a round-about-way??

Hope I Explained it Better...

Knowladge Belongs To The People...
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 17th Oct 2003 11:02
Well, if you coded it, you'll know what my_variable is, and you can pass it in to your function.



BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 17th Oct 2003 13:26
Erm, no, that's what i said...

Quote: "the way i have my actual function set-up, i cant use anthing like _my_function(my_variable) "


sorry, its just that the code i have is kinda confusing (even to me, and i wrote it!) and the function set-up cannot be passed the variable (in-fact, the variable changes before the program reaches the function, and if i move either the function or the variable, it wont work properly)

So, my question stil stands, is there a way to find the lengh/depth of an array?

Thanks to those for helping so far...

Knowladge Belongs To The People...
JSCskycap
21
Years of Service
User Offline
Joined: 22nd Sep 2003
Location: Townsend, MA, USA
Posted: 18th Oct 2003 08:29
Hmm. Maybe it would help if you explained exactly what your program is doing here. (?) I'm trying to get a handle on it. Let's start by clarifying a few things:

You are defining the value of my_variable in this example as 20.
You then DIMension an array with a max size of 20x2.
Now, between here and the actual call to the function, that first dimension can change and be anything up to 20, or whatever you initially DIMensioned, right?
What are you using for a variable in place of the ??? in the For/Next loop? There has to be something there. If I understand it correctly, this value must be no greater than my_variable or the array will crash. So whatever you use here will tell you the size of the array, at the time the function is used, right?

Maybe by detailing everything, one of use will get a lightbulb -
JSCskycap
21
Years of Service
User Offline
Joined: 22nd Sep 2003
Location: Townsend, MA, USA
Posted: 18th Oct 2003 08:32
In this example, x * 2 is the size of the array where x <= my_variable
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 18th Oct 2003 12:40 Edited at: 18th Oct 2003 12:41
Ok, what i have is a string parser...
this is it:


And what i want to do it is change it to:


Note that i have changed the dimensions of the array, that is the only difference so far.

Now, the reason i didnt this, is so i can change the value of no_of_types byt finding out the lenght of an array.

To explain the array which i need to find the length of;
I am giong to read the file "gamedata.txt" to find out how much information it holds, and then store that data in an array, then read the length of that array and use that to set the length of the array "item_data$(1,2,3)"

In code:


Knowladge Belongs To The People...
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 18th Oct 2003 12:42
Hmm, i just realised, i dont need to know the length of the array...

Sorry...

But thanks for your help

I feel like an idiot now

Knowladge Belongs To The People...

Login to post a reply

Server time is: 2025-05-21 14:36:55
Your offset time is: 2025-05-21 14:36:55