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 
go to the radio page Live at electro-music.com radio 1 Please visit the chat
poster
 Forum index » DIY Hardware and Software » ChucK programming language
Machine.add Classes - undefined type 'MyClass'
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [4 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
pfuentes



Joined: Nov 25, 2012
Posts: 1
Location: los angeles

PostPosted: Sun Nov 25, 2012 3:12 am    Post subject: Machine.add Classes - undefined type 'MyClass'
Subject description: Problem adding classes
Reply with quote  Mark this post and the followings unread

Hi, this problem has been bugging me for the last three days and i'm pretty sure its a very simple fix, which pisses me off...but I have a Notes class for calling frequencies by their note names and register and that tests out fine within the same chuck file, but when i try to Machine.add("Notes.ck") to use within a new chuck file, which also containing my melodic code, chuck doesn't recognize my class Notes. I have Notes x; set, yet i still get [melody]:line(9): undefined type 'Notes'...

why is this happening? i've tried public/private class, and still get the same response. My miscellaneous is also set accordingly. Any ideas?
Back to top
View user's profile Send private message
pizzas



Joined: Feb 05, 2013
Posts: 4
Location: japan

PostPosted: Tue Feb 05, 2013 7:34 am    Post subject: Reply with quote  Mark this post and the followings unread

hi pfuentes. i know it's been a while since you asked, but if you're still wondering...

looking at this example for classes (from here), it seems that public classes in a separate file need to be called at the same time you start your main program. in other words, you need to say "chuck main.ck class.ck" for it to work. sporking and Machine.add are no good.

but i found your question because i have the same question. the examples are pretty old. is there a better way now?
Back to top
View user's profile Send private message
GrandJu



Joined: Jul 04, 2010
Posts: 32
Location: Rennes France

PostPosted: Thu Feb 07, 2013 10:27 am    Post subject: Reply with quote  Mark this post and the followings unread

Hi and Welcome to ChucK,

I don't know exactly how this is manage internaly but I have some practical knwoledge about it.

It is not possible to add your class in your main program directly:
for example , main.ck:
Code:

Machine.add("Notes.ck")

Notes note;


will not work because the main.ck will be parsed entirely first. Then Notes.ck will be loaded after as it is a child process.

You may have a top script that will call the two process one after the other
top.ck:
Code:

Machine.add("Notes.ck")
Machine.add("main.ck")



Have fun,
Ju
Back to top
View user's profile Send private message
pizzas



Joined: Feb 05, 2013
Posts: 4
Location: japan

PostPosted: Tue Feb 12, 2013 2:21 am    Post subject: Reply with quote  Mark this post and the followings unread

thanks ju! that makes total sense. thanks a lot.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [4 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