I am probably doing something stupid but here goes.....
Here is part of a script that I am using that looks in a directory for a specific file - the name is ConiferousTile_nnnn.bmp. If the file is not present I want the scipt to look for the next file - ConiferousTile_(nnnn+1).bmp.
t is the variable I am using for the file nnnn number.
Below is the code that I have scripted to do it using the Iffileexists..
//Enter the name of the file
Send Character/Text>ConiferousTile_%t%.bmp
Press Enter
//Check if it Exists
Label>filecheck
IfFileExists>%filespath%ConiferousTile_%t%.bmp,decid_tile,nextconf_tile
//Try again for the next one
Label>nextconf_tile
Let>t=t+1
Send Character/Text>ConiferousTile_%t%.bmp
wait>0.5
Press Enter
Goto>filecheck
Label>decid_tile
//Carry on with the found file
.....
The problems are as follows:
1. I cant get the Iffileexists to find the file if it does exist so it doesn't leave the loop
2. Its counting up in twos 1000,1002,1004
Can anyone help?
Many thanks
Chris
Double Count
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Much easier to just do:
Code: Select all
//Enter the name of the file
Send Character/Text>ConiferousTile_%t%.bmp
Press Enter
//Check if it Exists
Label>filecheck
IfFileExists>%filespath%ConiferousTile_%t%.bmp
//Do whatever with found file ...
Else
//Try again for the next one
Label>nextconf_tile
Let>t=t+1
Send Character/Text>ConiferousTile_%t%.bmp
wait>0.5
Press Enter
Goto>filecheck
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Check out the GetFileList> command...seems like it might be able automate whatever it is you are trying to do.
GetFileList>c:\Conifer*.*,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
Message>file_names_%k%
Until>k,file_names_count
this way you get a count of all files fitting the result of the list. You can easily move up or down the list, display, copy, whatever...
GetFileList>c:\Conifer*.*,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%
Let>k=0
Repeat>k
Let>k=k+1
Message>file_names_%k%
Until>k,file_names_count
this way you get a count of all files fitting the result of the list. You can easily move up or down the list, display, copy, whatever...
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
To do that you need to create a string prepended with zeros to the right length. E.g.:
Let>b=11
Let>MyNumber=000%b%
Let>MyNumber={Copy("%MyNumber%",Length("%MyNumber%")-3,4)}
This ensures the string is always 4 characters long, prepended with zeros. In this case 0011. Change b to 2 and you'd get 0002. Etc.
Let>b=11
Let>MyNumber=000%b%
Let>MyNumber={Copy("%MyNumber%",Length("%MyNumber%")-3,4)}
This ensures the string is always 4 characters long, prepended with zeros. In this case 0011. Change b to 2 and you'd get 0002. Etc.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?