hi is there a way to keep track of the number of opened instances of an external? if so, can anyone point me to an example object? thanks olli
_________________________________________________________________ Testen Sie Live.com - das Zentrum Ihrer Online-Welt, das Sie mit aktuellen Nachrichten, Sport- und Wetterinfos und vielem mehr versorgt. http://www.live.com/getstarted
Check out nqpoly4 or polypoly, they are both included in Pd-extended and in SVN.
.hc
On Mar 22, 2008, at 11:33 PM, best boy wrote:
hi is there a way to keep track of the number of opened instances of an external? if so, can anyone point me to an example object? thanks olli
Kostenlos bloggen + eigene Homepage + Fotospeicher = MSN Spaces Kostenlos! _______________________________________________ PD-dev mailing list PD-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
------------------------------------------------------------------------ ----
As we enjoy great advantages from inventions of others, we should be glad of an opportunity to serve others by any invention of ours; and this we should do freely and generously. - Benjamin Franklin
hi thanks for your help. i checked out nopoly4 and polypoly, but they both seem to be abstractions and are not very helpful in my case. i need a working solution that prevents the user from creating more than one instance of an external i'm writing. thanks anyway olli
CC: pd-dev@iem.at From: hans@eds.org Subject: Re: [PD-dev] allow only one instance of external object Date: Sat, 22 Mar 2008 23:43:23 -0400 To: ladataxi@hotmail.de
Check out nqpoly4 or polypoly, they are both included in Pd-extended and in SVN..hc On Mar 22, 2008, at 11:33 PM, best boy wrote: hi is there a way to keep track of the number of opened instances of an external? if so, can anyone point me to an example object? thanks olli
Kostenlos bloggen + eigene Homepage + Fotospeicher = MSN Spaces Kostenlos!_______________________________________________PD-dev mailing listPD-dev@iem.athttp://lists.puredata.info/listinfo/pd-dev
---------------------------------------------------------------------------- As we enjoy great advantages from inventions of others, we should be glad of an opportunity to serve others by any invention of ours; and this we should do freely and generously. - Benjamin Franklin
_________________________________________________________________ Testen Sie Live.com - das Zentrum Ihrer Online-Welt, das Sie mit aktuellen Nachrichten, Sport- und Wetterinfos und vielem mehr versorgt. http://www.live.com/getstarted
Check out [singleton] and search the archives for discussions on that:
http://lists.puredata.info/pipermail/pd-list/2007-03/048424.html
.hc
On Mar 23, 2008, at 4:13 PM, best boy wrote:
hi thanks for your help. i checked out nopoly4 and polypoly, but they both seem to be abstractions and are not very helpful in my case. i need a working solution that prevents the user from creating more than one instance of an external i'm writing. thanks anyway olli
CC: pd-dev@iem.at From: hans@eds.org Subject: Re: [PD-dev] allow only one instance of external object Date: Sat, 22 Mar 2008 23:43:23 -0400 To: ladataxi@hotmail.de
Check out nqpoly4 or polypoly, they are both included in Pd- extended and in SVN.
.hc
On Mar 22, 2008, at 11:33 PM, best boy wrote:
hi is there a way to keep track of the number of opened instances of an external? if so, can anyone point me to an example object? thanks olli
Kostenlos bloggen + eigene Homepage + Fotospeicher = MSN Spaces Kostenlos! _______________________________________________ PD-dev mailing list PD-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
As we enjoy great advantages from inventions of others, we should be glad of an opportunity to serve others by any invention of ours; and this we should do freely and generously. - Benjamin Franklin
Jetzt dabei sein und Windows Live Mail testen. Windows Live Mail.
------------------------------------------------------------------------ ----
Terrorism is not an enemy. It cannot be defeated. It's a tactic. It's about as sensible to say we declare war on night attacks and expect we're going to win that war. We're not going to win the war on terrorism. - retired U.S. Army general, William Odom
best boy wrote:
hi is there a way to keep track of the number of opened instances of an external?
Is this an external you are writing? Then yes. Otherwise there's weird tricks you can probably do to keep track, but not control.
if so, can anyone point me to an example object?
Just have a global counter variable that you initialise to 0 in foo_setup(), and in foo_new() you increment it, and in foo_free() you decrement it.
thanks olli
Claude
hi yes, it's for an external i'm writing. i tried the global counter variable thing you recommended and it works, except for when the first instance is duplicated, or copy/pasted in a patcher. this crashes pd.
do you, or anyone else, know of a working example of the global counter variable thing?
thanks olli
Date: Sun, 23 Mar 2008 10:43:36 +0000 From: claudiusmaximus@goto10.org To: ladataxi@hotmail.de CC: pd-dev@iem.at Subject: Re: [PD-dev] allow only one instance of external object
best boy wrote:
hi is there a way to keep track of the number of opened instances of an external?
Is this an external you are writing? Then yes. Otherwise there's weird tricks you can probably do to keep track, but not control.
if so, can anyone point me to an example object?
Just have a global counter variable that you initialise to 0 in foo_setup(), and in foo_new() you increment it, and in foo_free() you decrement it.
thanks olli
Claude
_________________________________________________________________ Testen Sie Live.com - das Zentrum Ihrer Online-Welt, das Sie mit aktuellen Nachrichten, Sport- und Wetterinfos und vielem mehr versorgt. http://www.live.com/getstarted
Hi,
Try this:
----------------------------------------
#include "m_pd.h"
static t_class *counter_class; static int instance;
typedef struct _counter { t_object x_obj; } t_counter;
static void *counter_new(t_symbol *s, t_int argc, t_atom *argv) { t_counter *x = (t_counter *)pd_new(counter_class); instance++; post("Instance %d", instance); return (void *)x; }
static void counter_free(t_counter *x){ instance--; }
void counter_setup(void) { counter_class = class_new(gensym("counter"), (t_newmethod)counter_new, (t_method)counter_free, sizeof(t_counter), CLASS_DEFAULT, 0);
instance = 0; }
-------------------------
That implements Claude's suggestion, and definitely works. If your external still crashes, then perhaps think about debugging it:
http://puredata.info/docs/developer/DebuggingPdExternals
Jamie
-- www.postlude.co.uk
On Mon, 2008-03-24 at 00:07 +0400, best boy wrote:
hi yes, it's for an external i'm writing. i tried the global counter variable thing you recommended and it works, except for when the first instance is duplicated, or copy/pasted in a patcher. this crashes pd.
do you, or anyone else, know of a working example of the global counter variable thing?
thanks olli
Date: Sun, 23 Mar 2008 10:43:36 +0000 From: claudiusmaximus@goto10.org To: ladataxi@hotmail.de CC: pd-dev@iem.at Subject: Re: [PD-dev] allow only one instance of external object
best boy wrote:
hi is there a way to keep track of the number of opened instances of
an
external?
Is this an external you are writing? Then yes. Otherwise there's
weird
tricks you can probably do to keep track, but not control.
if so, can anyone point me to an example object?
Just have a global counter variable that you initialise to 0 in foo_setup(), and in foo_new() you increment it, and in foo_free()
you
decrement it.
thanks olli
Claude
Jetzt dabei sein und Windows Live Mail testen. Windows Live Mail. _______________________________________________ PD-dev mailing list PD-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
Hallo, best boy hat gesagt: // best boy wrote:
is there a way to keep track of the number of opened instances of an external? if so, can anyone point me to an example object?
You could wrap it inside an abstraction which has a running counter stored in a [value MYOBJECTCOUNT] object. "MYOBJECTCOUNT" should be unique. The counter then gets incremented with each new instance of your abstraction. You cannot delete objects though without the counter getting out of sync unless you use a Pd with [closebang] or so.
For various obvious reasons, this is not a very good general solution, though.
Ciao