### Variable file name

Posted:

**Mon May 20, 2019 2:21 pm**I want to make an axon and shift its position according to the z coordinates in Vector d. Also, I want to store the coordinates of the axon compartments in separate files. I have defined the geometry using a function "define_geometry" written outside this code. So, I called the function in a loop and tried saving the coordinates in files with variable name, ending with the z coordinate to help differentiate them. But I am getting a syntax error in the line where I define f2 as new File(). I think there maybe syntax error in the way I defined the variable file name, but I am not sure what is the syntax error. Please suggest what could be the error here.

Code: Select all

```
objref d
d = new Vector(8)
d.x[0] = 5
d.x[1] = 10
d.x[2] = 25
d.x[3] = 50
d.x[4] = 75
d.x[5] = 100
d.x[6] = 125
d.x[7] = 150
for i=0, 7 {
xs=-18750.5
ys=0
zs=d.x[i]
define_geometry()
setpointers()
initialize()
// RECORD SECTION POSITIONS
objref f2
f2 = new File()
fname = printf("%s%d","coordinates",d.x[i])
f2.wopen(fname) // coordinate file name
forall{
for (x) if(x!=0 && x!=1){
f2.printf("%s(%g)\t%f\t%f\t%f\n", secname(), x, x_xtra(x), y_xtra(x), z_xtra(x))
}
}
f2.close()
}
```