Hi there,
can anybody explain why my for-loop below does not start with i=4 and does not end after i>250?
For ( i = 4 , i= i+12, i < 250,
.....
)
The loop does as required and gives me correct results for i=16,28,40 etc etc. Only --- I don't get results for i=4. First results come for i=16. And the loop never ends. The script crashes when i reaches a value beyond my data limits (somewhere around 1800). I've written plenty of loops by now, but never had this issue?
Cheers,
Kofi
I think your second and third arguments are switched, maybe try this:
For ( i = 4 , i < 250, i = i+12,
...
)
If that doesn't work, you might check whether your iterator variable is used in the loop. You can ensure this is not a problem be adding a local context for that variable, like this:
For ( i = 4 , i < 250, i= i+12,
write( "Starting iteration " || char(i) || "\!n");
local( {i},
...
i = 1
...
)
)
Please open Help --> Scripting index, search for "for" and find the enclosed example.
You see, that arguments need different order.
Also when hover over the command "for" you see the syntax, JMP expects.
Names Default To Here( 1 );
s = "";
For( i = 1, i < 10, i++,
s ||= " " || Char( i )
);
Trim( s );
I think your second and third arguments are switched, maybe try this:
For ( i = 4 , i < 250, i = i+12,
...
)
If that doesn't work, you might check whether your iterator variable is used in the loop. You can ensure this is not a problem be adding a local context for that variable, like this:
For ( i = 4 , i < 250, i= i+12,
write( "Starting iteration " || char(i) || "\!n");
local( {i},
...
i = 1
...
)
)
Ouch! This is quite embarrassing. It's seems I couldn't find the forest because of all the trees around me...!
Thanks nevertheless. Tells me that I've become rusty with my scripting routine.
Cheers,
Kofi