Indexed file

Anything that doesn't fit elsewhere.
Post Reply
Sandrine

Indexed file

Post 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.
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Indexed file

Post 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()
}
Sandrine

Post by Sandrine »

Thank you Ted. It works perfectly.
Post Reply