If FileChanged Problem

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
tony_smith
Pro Scripter
Posts: 70
Joined: Wed May 14, 2003 8:25 pm
Location: Vancouver BC Canada

If FileChanged Problem

Post by tony_smith » Wed Nov 12, 2003 11:43 pm

What is wrong with this code? It returns an invalid file name at the IFFileChanged line.

GetFileList>U:\Reports\EDIF_BATCH\*.txt,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
IfFileChanged>U:\Reports\EDIF_BATCH\file_names_%k%,NOPE
Label>YUP
Messagemodal>file_names_%k% YUP, less than 1
Goto>SKIPNO
Label>NOPE
MessageModal>file_names_%k% NOPE, more than 1
Label>SKIPNO
Until>k,file_names_count
Label>End

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Nov 13, 2003 12:50 am

Hi Tony.....thanks for the clear example to work with. Made it easy.

Your original code is provided below with comments in bold blue, and modifications in bold red:
GetFileList>U:\Reports\EDIF_BATCH\*.txt,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
//Remove the file path, it is already included in file_names_%k% variable.
//IfFileChanged>
U:\Reports\EDIF_BATCH\file_names_%k%,file_names_%k%,NOPE
Label>YUP
Messagemodal>file_names_%k% YUP, less than 1
Goto>SKIPNO
Label>NOPE
MessageModal>file_names_%k% NOPE, more than 1
Label>SKIPNO
Until>k,file_names_count
Label>End

If you single step through the code, you can see the values of file_names_%k% in the Show Watch List window.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
tony_smith
Pro Scripter
Posts: 70
Joined: Wed May 14, 2003 8:25 pm
Location: Vancouver BC Canada

Post by tony_smith » Thu Nov 13, 2003 8:47 pm

Thanks Bob, that worked fine.

Instead of outputting the file number in the loop, how would I output the file name. Thought I might ouput the separate to a file and readline, but that seems klunky.

T

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Nov 13, 2003 11:20 pm

If I understand you, here is a suggestion, no time for good code now.

Use Position, and MidStr to parse out the file name.
1. Assume no underscore (_) in filenames.
2. Find position of _ in the current filename.
3. Subtract 1 from that position to locate the last character of the name.
4. Use MidStr to pull out the filename

Something like this:
Position>_,filename_%k%,1,Stop
Let>Stop=%Stop%-1
MidStr>filename_%k%,1,%Stop%,filename
MessageModal>Filename is %filename%.
NOTE: The code above is quick and dirty, not tested, just wanted to pass on the idea....
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
tony_smith
Pro Scripter
Posts: 70
Joined: Wed May 14, 2003 8:25 pm
Location: Vancouver BC Canada

Post by tony_smith » Fri Nov 14, 2003 10:45 pm

I messed with variations of all this and did not get the results I wanted, so I started from scratch and came up with this which works. Thanks for your help, Bob.

GetFileList>U:\Reports\EDIF_BATCH\*.txt,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
IfFileChanged>file_names_%k%,NOPE
Label>YUP
Let>FYUP=file_names_%k%
Messagemodal>Yes-More than 1%CRLF%%FYUP%
Goto>SKIPNO
Label>NOPE
Let>FNOPE=file_names_%k%
Messagemodal>No-Less than 1%CRLF%%FNOPE%
Label>SKIPNO
Until>k,file_names_count

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts