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.

Name of object references

Postby Raj » Fri Jul 25, 2008 5:57 am

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?
Raj
 
Posts: 218
Joined: Thu Jun 09, 2005 1:09 pm
Location: Rijksuniversiteit Groningen

Re: Name of object references

Postby hines » Fri Jul 25, 2008 1:04 pm

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.
hines
Site Admin
 
Posts: 980
Joined: Wed May 18, 2005 3:32 pm

Re: Name of object references

Postby Raj » Wed Jul 30, 2008 11:45 am

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
Raj
 
Posts: 218
Joined: Thu Jun 09, 2005 1:09 pm
Location: Rijksuniversiteit Groningen


Return to The GUI

Who is online

Users browsing this forum: No registered users and 1 guest