VBox.save string length limitation

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:

VBox.save string length limitation

Post by Raj »

Problem: Strings passed to VBox/HBox save method can take a maxlength of about 256 characters.

Description:
To implement the save session mechanism I try to write a big string in which I gathered information from an included object to the session file, however neuron seems to choke on its size.
I tried a little experiment and seem to hit a boundary (segmentation violation) around 264 characters (=256 + epsilon?), see code below.

Solution: Pass the objref of the vbox to the object of which state information needs to be saved and write directly to the session file.

Code: Select all

// This file shows the vbox.save length limitation.
// Just load  and then save a session.

load_file("nrngui.hoc")
begintemplate test 

objref vbox,this
strdef tstr

proc init(){
	vbox=new VBox()
	vbox.ref(this)
	vbox.save("save()")
		vbox.intercept(1)
		xpanel("jsdahlkjf")
		xlabel("Just a label")
		xpanel()
		vbox.intercept(0)
	vbox.map()
}

proc save(){local index
	tstr="0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
	for index=100,2000 {
		printf("index: %d\n",index)
		
		sprint(tstr,"%s%s",tstr,"x")
		printf("%s\n",tstr)
		vbox.save(tstr)
	}
}



endtemplate test

objref mytest 
mytest=new test()
Post Reply