Author |
Message |
pfuentes
Joined: Nov 25, 2012 Posts: 1 Location: los angeles
|
Posted: Sun Nov 25, 2012 3:12 am Post subject:
Machine.add Classes - undefined type 'MyClass' Subject description: Problem adding classes |
|
|
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
|
|
|
pizzas
Joined: Feb 05, 2013 Posts: 4 Location: japan
|
Posted: Tue Feb 05, 2013 7:34 am Post subject:
|
|
|
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
|
|
|
GrandJu
Joined: Jul 04, 2010 Posts: 32 Location: Rennes France
|
Posted: Thu Feb 07, 2013 10:27 am Post subject:
|
|
|
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
|
|
|
pizzas
Joined: Feb 05, 2013 Posts: 4 Location: japan
|
Posted: Tue Feb 12, 2013 2:21 am Post subject:
|
|
|
thanks ju! that makes total sense. thanks a lot. |
|
Back to top
|
|
|
|