Double Count

General Macro Scheduler discussion

Moderators: JRL, Dorian (MJT support)

Post Reply
cgg
Newbie
Posts: 6
Joined: Sun Aug 20, 2006 10:38 am

Double Count

Post by cgg » Sun Aug 20, 2006 5:12 pm

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

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Aug 20, 2006 6:14 pm

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?

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Sun Aug 20, 2006 7:25 pm

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...

cgg
Newbie
Posts: 6
Joined: Sun Aug 20, 2006 10:38 am

Post by cgg » Tue Aug 22, 2006 1:11 pm

I'll give that a go - thanks.

By the way, how do I get it to count using the following number format:

0001
0002
0003

When I use count it shortens it to 1,2,3 etc.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Aug 22, 2006 1:21 pm

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.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

cgg
Newbie
Posts: 6
Joined: Sun Aug 20, 2006 10:38 am

Post by cgg » Tue Aug 22, 2006 1:38 pm

Brilliant - thanks

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