Scripting: Overview

 

Scripting vs. Batch Processing

Using scripting for automated processes offers a number of advantages over batch processing, including:

familiar syntax- VBScript is very similar to the highly popular Visual Basic language.

a readable program structure through language elements such as classes, loops, error handling etc.

direct access to the RC-WinTrans component object model and other scripting-enabled COM objects (e.g., a Microsoft Excel spreadsheet).

 

For simplification, only the VBScript language will be discussed here since it is the most widely used in Windows scripting.

 

A set of sample script files can be found in the RC-WinTrans directory under "Samples" -> "Commandline" -> "Scripting."

 

 

Script Application Structure

RC-WinTrans' component object model was created with scripting languages in mind.  To make it easier to work with this model, there is a VBScript class called "RWTComWrapper" which hides some of the more complex data types from the script writer.  This is done with the goal of making a VBScript as easy to write as a DOS batch file.

 

The use of such a class is as simple as:

               set RWT = new RWTComWrapper
            If Not RWT.HasLanguage("myProject.rwtproject", "fr") Then
               RWT.AddLanguage "myProject.rwtproject", "fr"
            End If

The "RWTComWrapper" class comes as a separate file and needs to be "included" into your script. In the Windows Script Host environment, this is made possible with WSF (Windows Script Host File).  Here is an example:

               <job id="RWTScr">

              <script language="VBScript" src="RWTComWrapper.vbs"/>

              <script code="VBScript" src="mycaller.vbs"/>

              </job>

A WSF file acts as a container for any file format understood by the Windows Script Host; it must have the extension ".wsf" to be recognized correctly (e.g., "MyScript.wsf").

 

An inclusion of script code has the following format:

<script language="(langspec)" src="(filename)"/>

 

The first inclusion is the "RWTComWrapper" class file that comes with the RC-WinTrans installation. The second inclusion is your own VBScript code- this may be either a separate file ("mycaller.vbs") or the VBScript code written directly into the WSF file, as in the following example:

              <job id="RWTScr">

            
<script language="VBScript" src="RWTComWrapper.vbs"/>

            
script code="VBScript">
            
<![CDATA[
              set RWT = new RWTComWrapper
            If Not RWT.HasLanguage("myProject.rwtproject", "fr") Then
          
     RWT.AddLanguage "myProject.rwtproject", "fr"
            End If
           
]]>
           
</script>

           
</job>

The green text is your VBScript code.

 

Note the additional <![CDATA[ ... ]]> written around the VBScript code- this is due to the fact that a WSF file is technically an XML file: a CDATA section is read "as is" by the XML parser without being XML code itself.

 

This combination of XML and VBScript may look confusing; as an alternative, it is entirely suitable to use the file inclusion mechanism discussed previously.

 

No specialized knowledge of the XML file format is required to use WSF files.  For your own script, simply take our sample code and replace either the file reference with your own script file name or replace the VBScript source code with your own.

 

For additional tips and information about scripting usage please refer to the topic entitled "Scripting Tips."

 

A complete list of commands can be found in the "Scripting: Reference" topic.

 

 

^ TOP ^