Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/jerdew5/orbworks.com/forum/includes/bbcode.php on line 472
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3368: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3370: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3371: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3372: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:472)
OrbWorks Community Forum • View topic - Using a variable when defining a Multi Dim Array
Page 1 of 1

PostPosted: Wed Mar 19, 2003 1:25 am
by olmy
I wanted to be able to use a variable when calling the Array function such as this:

x=5;
pointer y;
y = array("i,x,4");

Obviously, as Ptoolbox arrays use data from a string for their definition, the "x" isn't recognized and screws things up (my whole PDA crashes).

Is there some way to create a multi dimensional array using a variable in the definition.

What I actaully want to do is load data, from a database, into a multi dimensional array, so I can use the sort() function to alphabatize it. I was thinking if I could use the following:

pointer rec;
rec Array("s, dbnres(), 4); //There are 4 feilds in each record

I could load however many records I had at any given time, into an array and then use the PtoolboxLib sort() function to alphabetize the data. I'm sure there is a better way to alphabetize the database (which I would love to hear about if anyone has any suggestions) but I still am curious if you can somehow create a multi dimensional array (in Pocket C) using a variable to define it's elements.

Thanks!

PostPosted: Wed Mar 19, 2003 2:13 am
by jstadolnik
Just do this...

y = Array("i,"+x+",4");

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm

PostPosted: Tue Apr 22, 2003 6:32 pm
by cable_guy_67
Another Array() question.

If I have an array, Array("iciss,7,6,5") where one integer, the char, and one string is static while one integer and one string will be changing from time to time. Does it matter how they are placed in the array? Is it better to put the values that will be changing from time to time toward the end? The array gets read from often and about 50% of the time one integer and/or one string will have its value changed. I didn't see anything in the PToolBox documentation about this but I only print out the sections for the functions I am actually using so it's possible I missed it.

Thanks.

PostPosted: Tue Apr 22, 2003 7:07 pm
by jstadolnik
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
Does it matter how they are placed in the array? Is it better to put the values that will be changing from time to time toward the end?
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

The positions of the values in the array have no performance impact.

However, it is slightly more efficient memory-wise to do: Array("iciss,6,7,5"). Put the smaller values first.

Joe

The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm

PostPosted: Tue Apr 22, 2003 9:29 pm
by cable_guy_67
Thanks Joe. If you don't mind, why is it better to put the smaller value first. Will it save me on space with the pointer to the array? From the explanation in the doc's I assumed the internal pointers referred to would add up to the same for the first two dimensions. I guess this is not the case. Anyhow, I will change my array to reflect the 6,7,5 aspect and not be so concerned as to why.

For ours is not to wonder Why...

:D

Mark

Oh yes, I assume when I stuff my array the proper syntax is to use

Array("iciss,"+y+","+x+","+z)

PostPosted: Tue Apr 22, 2003 10:06 pm
by jstadolnik
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
If you don't mind, why is it better to put the smaller value first. Will it save me on space with the pointer to the array? From the explanation in the doc's I assumed the internal pointers referred to would add up to the same for the first two dimensions.
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

There ends up being fewer internal pointer elements. "iciss,6,7,5" results in: 6 + (6*7) pointer elements and (6*7*5) data elements. Where as "iciss,7,6,5" results in 7 + (6*7) pointer elements... 2 fewer.

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
Array("iciss,"+y+","+x+","+z)
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

The z parameter must be 5 though (or a multiple of 5). Array("iciss,"+y+","+x+",5") would be better.

Joe


The PToolboxLib guy.
http://www.geocities.com/retro_01775/PToolboxLib.htm

PostPosted: Wed Apr 23, 2003 12:32 am
by cable_guy_67
Yes, it was just an example to check syntax. I was thinking in flip flops. It would just be:

board_data=Array(iciss,6,7,5);
for(y=0; y<7; y++) {
for(x=0; x<8; x++) {
for(z=0; z<6; z++) {
board_data[y][x][z]=foo(1);//a call to read a data string
}
}
}

Or something to that nature. I think I would have to use a switch to call foo(2) or foo(4) keyed off of z for my requirements of different legnths. But that was not the question here. What it boils down to is I don't have the same requirements for an open ended array. I got caught up in the moment of how to use variables in the Array() call. I'm still discovering all the good stuff in PToolBoxLib. Thanks for the legwork. It keeps on removing big hunks of code I dug off the net doing it the hard way.
:D

Mark