I upgraded to the latest version yesterday. The new version has a fix for the Separate command.People have been using work-arounds.
Overnight, I had a system crash because an old script, containing the Separate command looped infinitely. I have not had a chance to debug the macro yet (Still cleaning up data), however I thought I should post a heads-up on this in case anyone else was having a problem.
Here is the section of my code that I believe needs debugging...
Remark>Get File List Loop
GetFileList>TP,files
Separate>files,;,file_names
Let>k=0
Repeat>k
Let>k=k+1
FileSize>file_names_%k%,size
FileDate>file_names_%k%,date
WriteLn>LFILE,result,file_names_%k%
WriteLn>LFILE,Size: %size% Date: %date%
WriteLn>LFILE,
Until>k,file_names_count
Caution: Separate Command in version 7.2 050
Moderators: JRL, Dorian (MJT support)
- tony_smith
- Pro Scripter
- Posts: 70
- Joined: Wed May 14, 2003 8:25 pm
- Location: Vancouver BC Canada
Hi,
I've been unable to duplicate this. Your code works fine and I have made other tests of a similar nature and no problems found. Anyone else?
I've been unable to duplicate this. Your code works fine and I have made other tests of a similar nature and no problems found. Anyone else?
MJT Net Support
[email protected]
[email protected]
- tony_smith
- Pro Scripter
- Posts: 70
- Joined: Wed May 14, 2003 8:25 pm
- Location: Vancouver BC Canada
- tony_smith
- Pro Scripter
- Posts: 70
- Joined: Wed May 14, 2003 8:25 pm
- Location: Vancouver BC Canada
The Answer is...
Support sent me this reply... sometimes the answers are too obvious.
I see what the problem is. file_names_count used to incorrectly report 1 when there were in fact zero files in the list. The loop starts with k being equal to 1 and tries to loop until k = file_names_count. Therefore before the bug was fixed you used to get one iteration with an error on the filesize and filedate because there is no such file called file_names_1. Now that that file_names_count correctly reports 0 your loop will now try to iterate k from 1 to 0. Clearly it can iterate k from here until eternity but if it starts at 1 it will never reach 0 by adding 1 each time!
The elegant solution is to not do the loop if file_names_count is zero (only do it if there are files in the list). So you could do something like:
If>file_names_count>0,doloop,skiploop
Or in your case just jump back to loop1:
Separate>files,;,file_names
If>file_names_count=0,loop1
Let>k=0
Repeat>k
etc...
A dirtier fix if you want it to act like it used to and give you those filesize/filedate file not found errors is to loop until k = file_names_count+1 :
Let>fc=file_names_count+1
Repeat>k
...
...
Until>k,fc
You are a victim of an earlier bug letting you down gracefully (By allowing filesize/filedate to report on errors when no such file exists). I'm sure you'll appreciate that file_names_count *should* report zero when there are zero files in the list. And one should only loop through a list of files if there is indeed a list of files to loop through. One can't loop through an empty list.
I see what the problem is. file_names_count used to incorrectly report 1 when there were in fact zero files in the list. The loop starts with k being equal to 1 and tries to loop until k = file_names_count. Therefore before the bug was fixed you used to get one iteration with an error on the filesize and filedate because there is no such file called file_names_1. Now that that file_names_count correctly reports 0 your loop will now try to iterate k from 1 to 0. Clearly it can iterate k from here until eternity but if it starts at 1 it will never reach 0 by adding 1 each time!
The elegant solution is to not do the loop if file_names_count is zero (only do it if there are files in the list). So you could do something like:
If>file_names_count>0,doloop,skiploop
Or in your case just jump back to loop1:
Separate>files,;,file_names
If>file_names_count=0,loop1
Let>k=0
Repeat>k
etc...
A dirtier fix if you want it to act like it used to and give you those filesize/filedate file not found errors is to loop until k = file_names_count+1 :
Let>fc=file_names_count+1
Repeat>k
...
...
Until>k,fc
You are a victim of an earlier bug letting you down gracefully (By allowing filesize/filedate to report on errors when no such file exists). I'm sure you'll appreciate that file_names_count *should* report zero when there are zero files in the list. And one should only loop through a list of files if there is indeed a list of files to loop through. One can't loop through an empty list.