Page 1 of 1

Indexed file

Posted: Tue Oct 02, 2007 9:55 am
by Sandrine
Hello Ted, Michael.

I think i have a very small problem but i did not find the way to fix it!

I would like to save my results in a file which will be indexed by the number of the simulation: "ii" in the following piece of code, so i put "ii" in parameter of plotvsd(), but after (in the plotvsd() function) i don't know how to print in a file like in C langage:
fprintf(filename, "vsd_file-%s", $1).

Code: Select all

proc myRun() {
	preparemyrun()
	for ii = $1, $2 {
		setFreq(ii)
		run()
		postprocess()
		[b]plotvsd(ii)[/b]
        }
}
where

Code: Select all

proc plotvsd() {  
f1.aopen("vsd_file")  [b]//what have i to add here to write in a file indexed by the "ii" parameter???[/b]
f1.printf("%3.2f\n", svsum_moy.x[0])
f1.close()
}
Tell me if you don't understand what i want to do...i am not sure it is very clear ;-)

Thanks,
Sandrine.

Re: Indexed file

Posted: Wed Oct 03, 2007 10:57 am
by ted
Use sprint to create the filename string--see
http://www.neuron.yale.edu/neuron/stati ... tml#sprint

plotvsd() then becomes

Code: Select all

strdef fname
objref f1
f1 = new File()

proc plotvsd() {
  sprint(fname, "vsd_file-%s", $s1)
  f1.wopen(fname)
  . . . stuff to print results to f1 . . .
  f1.close()
}

Posted: Wed Oct 03, 2007 11:35 am
by Sandrine
Thank you Ted. It works perfectly.