Page 1 of 1

Testing if an Object ID exists

Posted: Thu Feb 24, 2011 2:22 pm
by aluchko
Is there a way to get a list of Objects of a certain type?

Say I create a Foo object, that becomes Foo[0], I create a second, and third, Foo[1] and Foo[2], then delete the second so I now have Foo[0] and Foo[2].

Is there a way to discover the existence of Foo[0] and Foo[2]?

The closest I can see is the SymChooser, but that's a GUI tool and doesn't seem to do what I need.

Re: Testing if an Object ID exists

Posted: Thu Feb 24, 2011 10:53 pm
by ted
Read about allobjects() in the Programmer's Reference.

Re: Testing if an Object ID exists

Posted: Fri Feb 25, 2011 3:25 pm
by aluchko
Thanks that does the trick.


One more question though, is hoc_stdio the only way to capture the output of the function?

http://www.neuron.yale.edu/neuron/stati ... #hoc_stdio

It does the job but I wouldn't mind something a bit cleaner than writing temporary files.

Re: Testing if an Object ID exists

Posted: Fri Feb 25, 2011 6:11 pm
by hines
Since you know the type you can say
objref xxx
xxx = new List("type")
for i=0, xxx.count-1 print xxx.o(i)