re: while loop
I try to stay away from while loops as they seem more prone to endless loop (they are easier to code badly ) but i see the logic behind your example. I wouldn't have thought of grouping the condition and the increment/decrement. Thanks.
@Falstaff
I already have some console output, thought not at this place. But i can't look at the console as fb2k itself will hang, not just the panel
EDIT : never mind, just found the "write log" checkbox in the console.
EDIT 2 : nay, even with "write log" checked, i don't get any console output at all when hangs occur. Not even output from statements that are executed before the loop goes crazy (actually : write log is not kept when fb2k restarts.
I tried to compare strings directly with what looks like simpler code, but i still have an endless hang. Got it working!
FINAL EDIT
OK, i got it working, but can someone explain me why :
var i=0;
do {
if (__path.charAt(i) != __pathOld.charAt(i)) break; // path no longer common, break the loop
} while(i++ < __pathLen);
__path = __path.substr(0,i); // keep only the common part
__path = __path.substr(0,__path.lastIndexOf("\\")); // don't consider path after the last backslash
...
Does not work, but
var __totoIsBack=0;
do {
if (__path.charAt(__totoIsBack) != __pathOld.charAt(__totoIsBack)) break; // path no longer common, break the loop
} while(__totoIsBack++ < __pathLen);
__path = __path.substr(0,__totoIsBack); // keep only the common part
__path = __path.substr(0,__path.lastIndexOf("\\")); // don't consider path after the last backslash
...
does