electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
Setting global array lengths in classes after loading
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [3 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
witt0191



Joined: Feb 13, 2008
Posts: 23
Location: UK

PostPosted: Tue Mar 23, 2010 8:48 pm    Post subject: Setting global array lengths in classes after loading Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Tue Mar 23, 2010 9:04 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Thu Mar 25, 2010 7:36 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [3 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use