Strings and objects in Neuron

Anything that doesn't fit elsewhere.
Post Reply
Posts: 45
Joined: Mon Jan 25, 2010 4:49 pm

Strings and objects in Neuron

Post by adamimos »

I would like to create a File object (by the i mean obFile = new File("file_name.txt") ) where file_name.txt is actually a string which is the name of some other object (let's say I have a List object that I have named synList).

What I would like to do is have some function where synList is an input ($o1) and I can somehow say something like:

obFile = new File($o1.string()) or something like that.

Does such a .string() function exist? or maybe .name()? I see the .alias() function, but it doesn't seem right for what I want to do.

Thanks for your time.
Site Admin
Posts: 5935
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: Strings and objects in Neuron

Post by ted »

hoc has no such function. The limited repertoire of related functions includes allobjects(), allobjectvars(), name_declared()--see ... #functions
And you wouldn't benefit much from the fact that
returns the name of the actual instance of a particular object class, e.g.

Code: Select all

oc>objref foo
oc>foo = new Vector()
oc>strdef bar
because I suspect you want a file name that has some semantic content that goes beyond the fact that it is named after a particular instance of a particular object class.
However, you might be able to get the effect you want by approaching whatever the problem is from a different angle. You can generate a command line with sprint(), then execute the command line with execute(). That allows you to create a "meaningful" name for an instance of any object class. And you can also generate a string and pass that as an argument to a statement such as
objref fil
fil = new File("some_string_I_generated")
or for that matter, you could generate a string that contains the entire
fil = new File(" . . .
command, then use execute() to execute that command string.
Post Reply