Hints, tips and tricks for newbies
Moderators: Dorian (MJT support), JRL
-
Dexter1
- Pro Scripter
- Posts: 64
- Joined: Mon Jun 19, 2006 3:28 pm
Post
by Dexter1 » Fri Jun 23, 2006 3:03 pm
Each week I have a bunch of files that are generated from a database. I create a new folder for that week, then copy the files to the new week's location. I always use the same naming convention for the folders.
In the below code, I'm Inputting a Week Number which will then be inserted into the new folder's name. This part works fine.
I want to make sure the directory the macro creates doesn't automatically replace an existing folder, but I want the option to do so. My IfDirExists statement works as it should, but the If statement below it does not.
Code: Select all
Input>WeekNumber, Enter Week Number
IfDirExists>\\rnodata01\scrub$\Production_Issues_Clarify\WK%WeekNumber%_2006
ask>This directory already exists. Do you want to replace it?, continue
Endif
If continue=Yes
DeleteFile>\\rnodata01\scrub$\Production_Issues_Clarify\WK%WeekNumber%_2006
CreateDir>\\rnodata01\scrub$\Production_Issues_Clarify\WK%WeekNumber%_2006
Endif
CreateDir>\\rnodata01\scrub$\Production_Issues_Clarify\WK%WeekNumber%_2006
Thanks,
Josh
-
JRL
- Automation Wizard
- Posts: 3526
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
Post
by JRL » Fri Jun 23, 2006 3:15 pm
Try changing the line:
If continue=Yes
To:
If>continue=YES
adding the greater than symbol and making the "YES" all upper case.
Later,
Dick
-
pgriffin
- Automation Wizard
- Posts: 460
- Joined: Wed Apr 06, 2005 5:56 pm
- Location: US and Europe
Post
by pgriffin » Fri Jun 23, 2006 3:22 pm
JRL is correct that the 'yes' should be YES. Also, I tested your code and found that you included a space just before the Input variable.
in MacroScript continue is not the same as continue.
simple to find these type problems if you open the Watch list and step through the program so you can watch the value of the variables.
hang in there, we'll be here to help...
-
pgriffin
- Automation Wizard
- Posts: 460
- Joined: Wed Apr 06, 2005 5:56 pm
- Location: US and Europe
Post
by pgriffin » Fri Jun 23, 2006 3:24 pm
sorry, I should have included a code snippet that works. All I did was remove the space just before continue in your Ask> line.
ask>This directory already exists. Do you want to replace it?,continue
If>continue=YES
mdl>it works
else>
mdl>not working
endif>
-
Dexter1
- Pro Scripter
- Posts: 64
- Joined: Mon Jun 19, 2006 3:28 pm
Post
by Dexter1 » Fri Jun 23, 2006 3:56 pm
Perfect! It works like a charm.
I appreciate everyone's help.
Thanks,
Josh