Did you know that you can write dos batch files to execute your mrs and dms scripts , Ace asked us the other day how he could sucessfully parameterise these scripts to make them generic and easy to use for multiple projects. In this post we will show you how this can be done. To be honest , it took me a while to remind myself how to do this, but the main thing that you have to remeber is that you need a define statement in your mrs script to strore the value that gets passed in. Anyway , hopefully you will understand all that by the end of this post, here is a typical example of a dos batch file.
d: cd D:\DATA\SD\Library\BatchFiles mrscriptcl Report.mrs Pause
if you don’t know how to make dos batch files then you can look at these posts to help you.
Once you have a batch file you may want to Parameterise it. To do this we can use the % command , for example. To run the above batch file we would type the following in a command prompt.
If we changed our batch file to look like this,
c: cd c:\data\MyReports mrscriptcl %a
and then typed this to run it
the script will run the Report.mrs file. So how do we make our DataCollection MRS scripts parameterised. well , if we use the following
in our batch file,
echo off D: cd D:\DATA\SD\Library\BatchFiles mrscriptcl Report.mrs /d:RunType=""1"" mrscriptcl Report.mrs /d:RunType=""2"" mrscriptcl Report.mrs /d:RunType=""3""
and your mrs looks something like this,
#define ReportType RunType if ( ReportType = "1" ) then debug.Echo("Report Type 1") Else debug.Echo("Report Type Other") End if
when you run the batch file you will see that we first of all get the words that we specified when RunType is set to 1, so “” and “” for the other two values passed in. So there you have it you know have some ways to paramatise your scripts to make them more generic and robust for your everyday work.