I found myself such a cycle to translate into B4X. And I can't understand what the final condition is for which the cycle stops. Usually it's a boolean condition now I find the negation of an integer, so what does that mean?
Java:
int i = 0;
for (; !i; i = 0 + i + 1) {
System.out.println(i);
// other
}
PS the problem is that the condition is not a boolean and I don't understand how it is satisfied
I found myself such a cycle to translate into B4X. And I can't understand what the final condition is for which the cycle stops. Usually it's a boolean condition now I find the negation of an integer, so what does that mean?
Java:
int i = 0;
for (; !i; i = 0 + i + 1) {
System.out.println(i);
}
!i is equivalent, in some languages, to i==0
In other words, the for loop will only execute while i==0 (or until i<>0)
So if I'm not mistaken, the example code of the first post should only loop once.
In this case, the equivalent code would be
B4X:
for i=0 to 0
...
Next
(although some 'for' loops with more complex statements fit better into a Do..while..loop structure)
!i is equivalent, in some languages, to i==0
In other words, the for loop will only execute while i==0 (or until i<>0)
So if I'm not mistaken, the example code of the first post should only loop once.
In this case, the equivalent code would be
B4X:
for i=0 to 0
...
Next
(although some 'for' loops with more complex statements fit better into a Do..while..loop structure)
After researching on the web I suspected exactly what you told me.
I did some experiments but in java but the compiler doesn't accept it and yet it is definitely a working code.
int i = 1; for (; i==10; i = 0 + i + 1) { System.out.println(i); }
The condition specified above seems to be like "Loop WHILE i==10". The second parameter of a for loop must be True for the loop to execute and, in that case, the initial value of i is 1 and the loop should never run this way.