Sorry below is a more complete code snippet:
rDistance = 5.4;
radiusInc = N[Pi]/10;
planeDepth = 0.5;
zField = {}
For[rPos = 0, rPos<=(2 N[Pi]), rPos += radiusInc,
zPotential = 0;
Print@ToString@rPos;
xPos = rDistance Cos[rPos];
yPos = rDistance Sin[rPos];
zPos = planeDepth;
AppendTo[zField, {xPos,yPos, zPotential}];
Print@ToString@Length[zField]
];
The Print statements show no output. When I step into the loop in the Wolfram Workbench, the only line executed is:
zPotential = 0;
The debugger hits this line twice and falls out. It does not appear that rPos is incremented, although the value of radiusInc is 0.31415...
Also - if I transpose the first two lines in the body of the For[] - so that the Print@ToString@rPos precedes the assignment of zPotential as shown below, the debugger does not hit the Print@ToString@rPos and no output is produced. Oddly it goes to the zPotential=0; line and loops back to the For[]:
For[rPos = 0, rPos<=(2 N[Pi]), rPos += radiusInc,
Print@ToString@rPos;
zPotential = 0;
xPos = rDistance Cos[rPos];
yPos = rDistance Sin[rPos];
zPos = planeDepth;
AppendTo[zField, {xPos,yPos, zPotential}];
Print@ToString@Length[zField]
];
This one has me completely stumped.
Changing to a While[] loop produces the same result.
rPos = 0;
MAXRPOS = (2 N[Pi]);
While[rPos<=MAXPOS,
Print@ToString@rPos;
zPotential = 0;
xPos = rDistance Cos[rPos];
yPos = rDistance Sin[rPos];
zPos = planeDepth;
AppendTo[zField, {xPos,yPos, zPotential}];
Print@ToString@Length[zField];
rPos += radiusInc
];
Once again, the first line in the body that the debugger hits is zPotential=0; This line is hit twice and the loop is exited.