...
Most of the documentation for using ScriptRules is maintained in the sample ScriptRules file distributed with the product and listed below. To you this file, add it to your user folder, modify it with the rules you need, and reference it from your main script template.
Code Block | ||
---|---|---|
| ||
<!-- ScriptRule FileOverview Syntax AThe ScriptRule.xml file defines named iscollections anof XMLscript documentcommands that may contain onemay orbe moreconditionally ScriptRulemerged with the template translation elements.script creating These elements and their attributesdifferent areactual describedtranslation belowscripts. This <ScriptRule id="name" Condition="condition" > elementsmakes it possible, with one ScriptRuletemplate, elementsto containautomate nameda scriptvariety commandof collectionscommon and task-specific upgrade options. The idScriptRule attributefiles isare thealso nameneeded offor theAPI-based ScriptRuleupgrade andtasks. is alsoThese used tasks inuse youran translationEXE scriptimplemented tousing activategmAPI therather rule.than a XML script template. The Condition attribute is used toThe controlgmAPI whichframework rulesincludes area mergedScriptRule intoclass providing services to to the actualintegrate translationScriptRule script.file content <Command Condition="condition"> elements Command elements are children of a ScriptRule that specify the content that should be merged into the translation script template. The following types of Command elements are currently supported: Option Inserts commands that replace the <ScriptRule> tag in the merged transcript, typically Select, Reference, and Registry commandswith other gmAPI services. ScriptRule File Syntax A ScriptRule file is an XML document that may contain one or more ScriptRule elements. These elements and their attributes are described below. <ScriptRule id="name" Condition="condition" > elements ScriptRule elements contain named script command collections The id attribute is the name of the ScriptRule and is also used in your translation script to activate the rule. The Condition attribute is used to control which rules are merged into Compile to the actual Insertstranslation commandsscript. as children of the Compile block. Typically <Command Condition="condition"> elements Command elements are children of a ScriptRule that specify the content that should be Select,merged Reference,into Fix,the andtranslation Refactorscript commandstemplate. The following types of Command elements are currently supported: Analyse Option Inserts commands as children of the Analyse block that replace the <ScriptRule> tag in the PreAnalyse Inserts commands before the Analysemerged blocktranscript, typically refactor commands Select, Reference, and Registry commands. PostAnalyse Inserts commands after the Analyse block, typically refactor commands Load Author InsertsInsert commands as children of the AuthorLoad block, typically Fix commands . Typically Fixcommands. Compile PostAuthor Inserts commands as children afterof the AuthorCompile block,. typicallyTypically top level gmPL commands The Condition attribute is used to control which commandsSelect, areReference, mergedFix, intoand Refactor commands. to the actual translation script. Condition attributesAnalyse A ConditionInserts attributecommands mayas bechildren appliedof tothe any other element. It specifies the Analyse block PreAnalyse Inserts conditioncommands under whichbefore the elementAnalyse andblock, itstypically childrenrefactor willcommands be merged with thePostAnalyse Inserts commands after templatethe scriptAnalyse toblock, createtypically therefactor actualcommands script. Syntax Author Inserts commands as children of the Author %variable_expression% op 'value_expression' block, typically Fix commands PostAuthor where Inserts commands after the Author block, typically top variable_expressionlevel gmPL commands all script variables and otherThe charactersCondition attribute is used to control opwhich commands are merged into to the actual translation script. Condition attributes == trueA ifCondition %variable_expression% == value_expression attribute may be applied to any other element. It specifies the condition under which the element and its children will be merged with the != true if %variable_expression% != value_expression template script to create the actual script. Syntax =~ true if %variable_expression% matchesop regex 'value_expression' where variable_expression all script variables and other characters !~ true if %variable_expression%op does not match regex value_expression == true if %variable_expression% == value_expression value_expression a constant string or regex pattern != true if Comparisons are case insensitive using trimmed strings.%variable_expression% != value_expression =~ true if %variable_expression% matches Relational operators are not supported, but you can useregex value_expression Condition="var1.var2=='val1.val2'" to simulate locical AND Condition="var=~'val1|val2'" to simulate logical OR!~ true if %variable_expression% does not match regex value_expression For example Condition="%SrcName%=='ScanToolUI'" indicates that the associated value_expression element will only be mergeda forconstant upgradestring tasksor havingregex SrcNamepattern equal Comparisons are case insensitive using trimmed strings. to the string "ScanToolUI". <ForEach>, <Iterator>, and <Each> elements Relational operators are ForEachnot elementssupported, arebut childrenyou ofcan theuse ScriptRule. They allow repeating Condition="var1.var2=='val1.val2'" to Commandsimulate elementslocical forAND each file in the source project folder that meet Condition="var=~'val1|val2'" certainto criteria.simulate logical ThisOR element may also be usedFor toexample copy files from the source project folder to the .NET project folder. Condition="%SrcName%=='ScanToolUI'" indicates that the associated The setelement ofwill filesonly tobe iteratemerged overfor isupgrade definedtasks byhaving aSrcName <Iterator/FileInfo>equal element according to its attributes: to the The FileInfo Criteria attribute is a search pattern (e.g. *.wav) used tostring "ScanToolUI". get files from<ForEach>, the<Iterator>, sourceand folder.<Each> elements ForEach elements are children Theof FileInfothe FilesScriptRule. attributeThey mayallow berepeating "All" or "Top". TheCommand defaultelements is "All". If Files="All", the root of the source folder and all of its sub-folders are searched; if Files="Top", only the root of the source folder is searchedfor each file in a specified folder that meets certain criteria. This element may also be used to copy files from the specified folder to the .NET project folder. The set CopyFilesof attributefiles mayto beiterate "On"over or "Off". The default is "On". Ifis defined by a <Iterator/FileInfo> element according CopyFiles="on", the files found in the source project folder will be copied to the corresponding .NET project folder with directory structure preserved. The folders and files are copied prior to the translation process.to its attributes: The FileInfo@Criteria attribute is a search pattern (e.g. *.wav) used to get files from the source folder. The FileInfo@Folder attribute Withinspecifies the <Each>folder block,to thesearch notationfor %FileInfofiles.member% may be used to referThe default is the source tofolder informationassociated aboutwith the filesupgrade foundtask. in the source folder: %FileInfo.RelativeName%: path relative to the source project root %FileInfo.Name%: file name %FileInfo.FullName%: full path %FileInfo.DirectoryName%: parent folder name Activating a ScriptRule Adding a <ScriptRule> tag to the script requests the merging of the named script collection. <ScriptRule id="name" attributeList /> The id attribute specifies the command collection to add. The attributeList specifies variables that may be referenced elsewhere in the ScriptRule. Variable references are case insensitive. For example the following ScriptRule tag: <ScriptRule id="IncludeResources" Criteria="*.wav" /> requests loading the command collection named IncludeResouces and creates a ScriptRule variable named %Criteria% with value = "*.wav" Specifying the ScriptRule file By default, the ScriptRule XML is located in a file called ScriptRule.xml and is typically kept in the workspace\usr folder. If desired, you may specify an alternate location using a FileName attribute%SrcFolder%, %UserFolder%, and %ProjFolder% script variables may also be used. The FileInfo@Recurse attribute may be "All" or "Top". The default is "All". If Files="All", the root of the source folder and all of its sub-folders are searched; if Files="Top", only the root of the source folder is searched. The FileInfo@CopyFiles attribute may be "On" or "Off". The default is "On". If CopyFiles="on", the files found in the source project folder will be copied to the corresponding .NET project folder with directory structure preserved. The folders and files are copied prior to the translation process. Within the <Each> block, the notation %FileInfo.member% may be used to refer to information about the files found in the source folder: %FileInfo.RelativeName%: path relative to the source project root %FileInfo.Name%: file name %FileInfo.FullName%: full path %FileInfo.DirectoryName%: parent folder name Activating a ScriptRule Adding a <ScriptRule> tag to the script requests the merging of the named script collection. <ScriptRule id="name" attributeList /> The id attribute specifies the command collection to add. The attributeList specifies variables that may be referenced elsewhere in the ScriptRule. Variable references are case insensitive. For example the following ScriptRule tag: <ScriptRule id="IncludeResources" Criteria="*.wav" /> requests loading the command collection named IncludeResouces and creates a ScriptRule variable named %Criteria% with value = "*.wav" Specifying the ScriptRule file By default, the ScriptRule XML is located in a file called ScriptRule.xml and is typically kept in the workspace\usr folder. If desired, you may specify an alternate location using a FileName attribute for example: <ScriptRule id="ADODBUpgrade" FileName="..\usr\ADODB.Rules.xml" /> The above loads the ScriptRule file named ..\usr\ADODB.Rules.xml (relative to the workspace log folder). And then merges in the ScriptRule element having id="ADODBUpgrade": <ScriptRule id="ADODBUpgrade" Condition="%TaskTag%=='upg'" > ... rules to perform ADODBUpgrade for tasks having TaskTag=='upg' ... </ScriptRule> See Also: For more information, see the "Eval" VB6 Upgrade sample here https://portal.greatmigrations.com/display/GMG/Samples --> <ScriptRules> <!-- Here is a sample of the ScriptRule syntax --> <ScriptRule id="BasicRulesStandardUpgrade"> <Option> <!-- directories for configuration files --> <select Target="%UserFolder%" /> <Select Local="%IdfFromCodeFolder%" /> <Select System="%IdfFromIdlFolder%" /> <!-- translation options --> <Select Progress="1" /> <Select DevEnv="%DevEnv%" /> <Select Dialect="%Dialect%" /> <Select BuildFile="local" /> <!-- directories for deployment and external assemblies --> <select VirtualRoot="%VirtualRoot%" /> <Select DeployLocation="%NetProjFolder%" /> <Select Library="%RuntimeFolder%" /> <!-- custom processing commands --> </Option> <Compile Condition="%SrcName%=~'Project1|Project2'" > <!-- pre-edits --> <!-- compile refactors commands--> </Compile> <PreAnalyse> <!-- pre-analyse refactor commands --> </PreAnalyse> <PostAnalyse> <!-- post-analyse refactors commands--> </PostAnalyse> <Author Condition="%SrcName%=~'Project1|Project2'" > <!-- post-edits --> </Author> <PostAuthor> <!-- post-author refactors commands--> </PostAuthor> </ScriptRule> </ScriptRules> |