It does not work because the Scamp has used I for the FOR NEXT. Defining I again for DO LOOP is not allowed in FlashForth.
So, in Scamp I can only be used by FOR NEXT, there I is just an alias for R@. I asked John not to do that, but he did, so now there is this mess with I and DO LOOP.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
in the rest of forths the firts way is the correct, using i and j, not using always i.
the question is why when i use i and j, the double loop doesnt work well?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hello , i use i and jin the for next loop and ix and jx in the do loop:
I checked these words:
test1 10 0 do ." i " ix . 10 0 do ."j" jx . loop loop ; and doesnt work but (a)
test1 10 0 do ." i" ix . 10 0 do ." j" ix. loop loop ; it works! (b)
the same happen with for next loop. if I use the index i and j or ix and jx, the esult is not ok (a) but if I only use the index i or ix in the nested loops then it works well (b).
Last edit: Pere font vilanova 2025-11-07
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I always thought that when there were two nested loops, the index value of each loop had to be requested using I and J.
But in the last example, I see that I can get the value of each index (inner and outer) using only index I, without needing to use J. I suppose they should only be used if both indices are requested within the same loop.
sorry for a lot of questions, but i'm beginner forth user....
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
that is not standard at all... is it normal?
It does not work because the Scamp has used I for the FOR NEXT. Defining I again for DO LOOP is not allowed in FlashForth.
So, in Scamp I can only be used by FOR NEXT, there I is just an alias for R@. I asked John not to do that, but he did, so now there is this mess with I and DO LOOP.
really in the loop do loop i use the index Ix and Jx , in this way ther is no interference with the i and j of the for next......
So what was your problem ?
in the rest of forths the firts way is the correct, using i and j, not using always i.
the question is why when i use i and j, the double loop doesnt work well?
It is difficult to answer a question if you do not show the real code that you are using. If you use Ix then write it in the code.
For me the do loop works just fine on the scamp 3e.
How did you define J for the FOR NEXT? You cannot use J defined for DO LOOP in the FOR NEXT LOOP.
hello , i use i and jin the for next loop and ix and jx in the do loop:
I checked these words:
test1 10 0 do ." i " ix . 10 0 do ."j" jx . loop loop ; and doesnt work but (a)
test1 10 0 do ." i" ix . 10 0 do ." j" ix. loop loop ; it works! (b)
(a) :
i0 j0 j0 j0 j0 j0 j0 j0 j0 j0 j0
i1 j1 j1 j1 j1 j1 j1 j1 j1 j1 j1
i2 j2 j2 j2 j2 j2 j2 j2 j2 j2 j2
i3 j3 j3 j3 j3 j3 j3 j3 j3 j3 j3
i4 j4 j4 j4 j4 j4 j4 j4 j4 j4 j4
i5 j5 j5 j5 j5 j5 j5 j5 j5 j5 j5
i6 j6 j6 j6 j6 j6 j6 j6 j6 j6 j6
i7 j7 j7 j7 j7 j7 j7 j7 j7 j7 j7
i8 j8 j8 j8 j8 j8 j8 j8 j8 j8 j8
i9 j9 j9 j9 j9 j9 j9 j9 j9 j9 j9
but this is not correct! must be:
(b)
i0 j0 j1 j2 j3 j4 j5 j6 j7 j8 j9
i1 j0 j1 j2 j3 j4 j5 j6 j7 j8 j9
i2 j0 j1 j2 j3 j4 j5 j6 j7 j8 j9
i3 j0 j1 j2 j3 j4 j5 j6 j7 j8 j9
i4 j0 j1 j2 j3 j4 j5 j6 j7 j8 j9
i5 j0 j1 j2 j3 j4 j5 j6 j7 j8 j9
i6 j0 j1 j2 j3 j4 j5 j6 j7 j8 j9
i7 j0 j1 j2 j3 j4 j5 j6 j7 j8 j9
i8 j0 j1 j2 j3 j4 j5 j6 j7 j8 j9
i9 j0 j1 j2 j3 j4 j5 j6 j7 j8 j9
the same happen with for next loop. if I use the index i and j or ix and jx, the esult is not ok (a) but if I only use the index i or ix in the nested loops then it works well (b).
Last edit: Pere font vilanova 2025-11-07
(a) is correct. You need to think about what the function of the word J is.
J gets you the value of the index of the outer loop.
oh oh totally true, i had a wrong idea. really i is inner loop and j is outer loop. thank you again.....
curiously if i use only i . the nested loop runs ok........
Why ? That is normal. I accesses the current loop index, J the outer loop index, K 2 levels up.
\ but also checked in my scamp
ok
qq
0 0 1 2 3 4 5 6 7 8 9
1 0 1 2 3 4 5 6 7 8 9
2 0 1 2 3 4 5 6 7 8 9
3 0 1 2 3 4 5 6 7 8 9
4 0 1 2 3 4 5 6 7 8 9
5 0 1 2 3 4 5 6 7 8 9
6 0 1 2 3 4 5 6 7 8 9
7 0 1 2 3 4 5 6 7 8 9
8 0 1 2 3 4 5 6 7 8 9
9 0 1 2 3 4 5 6 7 8 9
ok
Last edit: Pere font vilanova 2025-11-07
You need J when you in the inner loop want to use the index of the outer loop.
also : tt 10 for i . 10 for i . next cr next ;
ok
tt
10 10 9 8 7 6 5 4 3 2 1 0
9 10 9 8 7 6 5 4 3 2 1 0
8 10 9 8 7 6 5 4 3 2 1 0
7 10 9 8 7 6 5 4 3 2 1 0
6 10 9 8 7 6 5 4 3 2 1 0
5 10 9 8 7 6 5 4 3 2 1 0
4 10 9 8 7 6 5 4 3 2 1 0
3 10 9 8 7 6 5 4 3 2 1 0
2 10 9 8 7 6 5 4 3 2 1 0
1 10 9 8 7 6 5 4 3 2 1 0
0 10 9 8 7 6 5 4 3 2 1 0
ok
Your code does not match the result in FF. Maybe in gforth ?
This is correct. What do you think it was supposed to do ?
Last edit: Mikael Nordman 2025-11-07
I always thought that when there were two nested loops, the index value of each loop had to be requested using I and J.
But in the last example, I see that I can get the value of each index (inner and outer) using only index I, without needing to use J. I suppose they should only be used if both indices are requested within the same loop.
sorry for a lot of questions, but i'm beginner forth user....