Name of object references

Using the graphical user interface to build and exercise models. Includes customizing the GUI by writing a little bit of hoc or Python
Post Reply
Raj
Posts: 220
Joined: Thu Jun 09, 2005 1:09 pm
Location: Groningen, The Netherlands
Contact:

Name of object references

Post by Raj »

I have a GUI-element which uses an object passed as an argument during creation. I would like to be able to store the window in a session file, including the name of the objref passed when creating it.

My code is something like this:

Code: Select all

begintemplate myGUI
 objref myObject
proc init{
myObject =$o1
}

// More code among them the creation of a VBox or HBox called box

proc save(){
   box.save("load_file(\"myGUI.hoc\")\n}")
   // This is the kind of thing I would like to do (ocbox_ is an object created by the save (session) mechanism of the VBox or HBox )
    sprint(tstr, "{%s = new myGUI(%s)}", "ocbox_",name(myObject))   
    box.save(tstr)
}	
endtemplate myGUI


I had a look at the StringFunctions class. Which prints the desired information to screen with the references method, but gives no further access to them. There are some obvious workarounds, like passing both the objref and its name during creation, but that puts on us the burden of either deciding up front we are going to save the window or always specifying a string we might not use.

Does anybody have some ideas as to how to get to this information?
hines
Site Admin
Posts: 1691
Joined: Wed May 18, 2005 3:32 pm

Re: Name of object references

Post by hines »

Code: Select all

sprint(tstr, "%s", obj)
gives you the name of the object in
type[index] form. sscanf could be used to
parse it into base, index variables.
Or, see the classname() procedure in nrn/lib/hoc/stdlib.hoc as well
as object_index.
Raj
Posts: 220
Joined: Thu Jun 09, 2005 1:09 pm
Location: Groningen, The Netherlands
Contact:

Re: Name of object references

Post by Raj »

Dear Michael,

That is not quite what I want. I think I would like to get my hands on the first name printed by the StringFunctions references method, which seems to be the name of the references in which the list was first stored in the global namespace.

Regards,
Ronald
Post Reply