<div dir="ltr"><div><div><div>Wow, never would have thought about that...<br></div>Tried it out right out, worked like a charm!<br><br></div>Thanks a lot, Martin!<br><br></div>Alex<br><div class="gmail_extra"><br><div class="gmail_quote">On 14 June 2015 at 21:44, Martin Peach <span dir="ltr"><<a href="mailto:chakekatzil@gmail.com" target="_blank">chakekatzil@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class="">On Sun, Jun 14, 2015 at 3:36 PM, Alexandre Clément <span dir="ltr"><<a href="mailto:alexandre.r.clement@gmail.com" target="_blank">alexandre.r.clement@gmail.com</a>></span> wrote:<br></span><div class="gmail_extra"><div class="gmail_quote"><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>Hello all!<br><br></div>I'm creating an external which should only allow one copy loaded at the same time.<br></div>Is there a way to check this upon creation?<br><br></div>I tried going the same approach as checking if a receiver exists before attempting to send, but it doesn't seem to work.<br><br>if (gensym("class_name")->s_thing) {<br>    post("Exists!");<br>    return false;<br>}<br><br></div></div></div></div></blockquote></span><div>Because gensym generates the symbol if it wasn't already in the list.<br></div><div>What I do is have a global variable outside the class struct and check if it is not zero before instantiating a new object.<br></div><div>Since c is guaranteed to initialize globals to zero, the first object created can set it to some other value. Maybe some more trickery will be needed if the object is deleted and recreated, possibly the code is still in memory and the global will have the non-zero value; in this case the free routine should zero the global,<br><br></div><div>Martin <br></div><div><br></div></div></div></div>
</blockquote></div><br></div></div>