<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Beinan:<div><br></div><div>Your code is close; the uber-overloaded ChucK operator is your source of grief.</div><div><br></div><div>Overlooking a couple of typos (i.e. "Class MyInstrument" should be "public class MyInstrument", "Public void Play" should be "fun void Play"), the real problem is lurking in line2 of my_chuck.ck:</div><div><br></div><div><div lang="EN-CA" link="blue" vlink="purple"><div><div><span class="Apple-tab-span" style="white-space:pre">  </span>Mandolin man => dummy.m_whatever;</div><div><br></div><div>To the compiler, it appears that you're making a UGen link, when what you really mean to be doing is assigning a *reference* of 'man' to dummy's m_whatever instance variable.   And for that, you want the @=> operator instead:</div><div><br></div><div><div><span class="Apple-tab-span" style="white-space: pre; "> </span>Mandolin man @=> dummy.m_whatever;</div><div><br></div><div>Amended code follows.  Hope this helps.</div><div><br></div><div>- Rob</div><div><br></div><div>// ===== File: instr.ck</div><div><div>public class MyInstrument {</div><div><br></div><div>    StkInstrument @ m_whatever;</div><div><br></div><div>    fun void Play(dur duration) {</div><div>        m_whatever.noteOn(1);</div><div>        duration => now;</div><div>        m_whatever.noteOff(1);</div><div>    }</div><div>}</div><div><div><div>// ===== EOF =====</div></div></div><div><div>// =====- File: my_chuck.ck</div><div>MyInstrument dummy;</div><div>Mandolin man @=> dummy.m_whatever;</div><div>dummy.m_whatever => dac;</div><div> </div><div>1::second => dur d;</div><div>dummy.Play(d);</div><div>// ===== EOF =====</div></div></div></div><div><br></div></div></div></div><div><div><div>On 10 Feb 2010, at 15:40, Beinan Li 2 wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div lang="EN-CA" link="blue" vlink="purple"><div class="Section1"><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">Hi Chuckists,<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">I’d like to dynamically switch instrument as in my small code (chuck instr.ck my_chuck.ck)<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">// instr.ck<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">Class MyInstrument<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">{<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">                StkInstrument@ m_whatever;<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">                Public void Play(dur duration)<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: 36pt; "><span lang="EN-US">{<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: 36pt; "><span lang="EN-US">                m_whatever.noteOn(1);<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 72pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: 36pt; "><span lang="EN-US">duration => now;<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 72pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: 36pt; "><span lang="EN-US">m_whatever.noteOff(1);<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; text-indent: 36pt; "><span lang="EN-US">}<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">}<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">// my_chuck.ck<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">MyInstrument dummy;<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">Mandolin man => dummy.m_whatever;<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">Dummy.m_whatever  => dac;<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">1::second => dur d;<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 36pt; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">dummy.Play(d);<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">Then I got this error:<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">[chuck](VM): NullPointerException: (UGen link) in shred[id=5:my_chuck.ck], PC=[46]<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">Where am I wrong with this late binding?<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US"><o:p> </o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">Thanks,<o:p></o:p></span></div><div style="margin-top: 0cm; margin-right: 0cm; margin-bottom: 0.0001pt; margin-left: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; "><span lang="EN-US">Beinan<o:p></o:p></span></div></div>_______________________________________________<br>chuck-users mailing list<br><a href="mailto:chuck-users@lists.cs.princeton.edu" style="color: blue; text-decoration: underline; ">chuck-users@lists.cs.princeton.edu</a><br><a href="https://lists.cs.princeton.edu/mailman/listinfo/chuck-users" style="color: blue; text-decoration: underline; ">https://lists.cs.princeton.edu/mailman/listinfo/chuck-users</a><br></div></blockquote></div><br><div apple-content-edited="true"> <div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="font-size: 12px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>--:</div><div>Robert Poor</div><div><div>e:<span class="Apple-tab-span" style="white-space: pre; ">        </span><a href="mailto:robert.poor@nbt-ventures.com">robert.poor@nbt-ventures.com</a></div><div>p:<span class="Apple-tab-span" style="white-space: pre; ">    </span>+1 617 818 5115</div><div>b:<span class="Apple-tab-span" style="white-space: pre; "> </span><a href="http://blog.nbt-ventures.com">http://blog.nbt-ventures.com</a></div><div>--:</div></div></div><div>This message and the information it contains are the proprietary and confidential property of NBT Ventures and may be privileged. If you are not the intended recipient, please do not read, copy, disclose or distribute its contents to any party, and notify the sender immediately.</div><div><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>--:</div></div></div></div></span></div></div> </div><br></div></body></html>