| Author |
Message |
witt0191
Joined: Feb 13, 2008 Posts: 23 Location: UK
|
Posted: Tue Mar 23, 2010 8:48 pm Post subject:
Setting global array lengths in classes after loading |
 |
|
Playing with the graphics within the mini audicle but keep hitting a problem when building arrays of interface objects.
I think the problem I am having is to do with my understanding of using arrays.
The code I have works fine when I declare the length of the array with the class code. However it errors when I try and set this value after instantiating.
This works fine
!!!!!!!!!!!!!!!!
class demo
{
//GUI
MAUI_View cip_eff_gui;
MAUI_Slider slider[3];
function void effectinterface(int k)
{
for (0 => int j; j < k; j++)
{
<<<"test">>>;
cip_eff_gui.addElement (slider[j]);
slider[j].precision(3);
slider[j].range(0., 10.0);
slider[j].position(0, (j * 100 + 50));
}
cip_eff_gui.display();
}
}
demo d;
d.effectinterface(3);
!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This does not work
!!!!!!!!!!!!!!!!!
class demo
{
int numsliders;
<<<numsliders>>>;
//GUI
MAUI_View cip_eff_gui;
MAUI_Slider slider[numsliders];
function void effectinterface(int k)
{
for (0 => int j; j < k; j++)
{
<<<"test">>>;
<<<numsliders>>>;
cip_eff_gui.addElement (slider[j]);
slider[j].precision(3);
slider[j].range(0., 10.0);
slider[j].position(0, (j * 100 + 50));
}
cip_eff_gui.display();
}
}
demo d;
3 => d.numsliders;
d.effectinterface(3);
!!!!!!!!!!!!!!!
So any ideas how I can set numsliders after loading it.
MAUI_Slider slider[numsliders];
Thanks in advance for any help. |
|
|
Back to top
|
|
 |
Inventor
Stream Operator

Joined: Oct 13, 2007 Posts: 6221 Location: near Austin, Tx, USA
Audio files: 267
|
Posted: Tue Mar 23, 2010 9:04 pm Post subject:
|
 |
|
I'm not really sure, but I think if you try MAUI_Slider sliders[]; that will work. Try it anyway.
Les _________________ "Let's make noise for peace." - Kijjaz |
|
|
Back to top
|
|
 |
Kassen
Janitor


Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Thu Mar 25, 2010 7:36 am Post subject:
|
 |
|
If you'd like to change the size of a array after the array has been instantiated then you'll need to use the .size() member function that all arrays have.
As it is the variable for setting the initial length of the array is just 0, the default value of a new int, at the time the array is instantiated. _________________ Kassen |
|
|
Back to top
|
|
 |
|