MERL and openArchitectureWare's Xpand languages are rather similar in approach and functionality. The main differences are in syntax and keywords, so learning one if you know the other is easy. Here's a quick primer of how to translate from Xpand to MERL, with comments after the respective row where necessary.
Xpand |
MERL |
SomeFixedText |
'SomeFixedText' |
«SOMECOMMAND» |
SOMECOMMAND |
In XPand commands are quoted, whereas in MERL fixed text is quoted. |
«DEFINE foo ... ENDDEFINE» |
Report 'foo' ... EndReport |
In MERL, each report is defined on its own, not with several reports one after another in a single text. Each report is defined on a particular Graph type (or the supertype of all, Graph itself). |
«FILE Name + ".java" ... ENDFILE» |
filename :Name '.java' write ... close |
«EXPAND foo FOREACH Bar» |
foreach .Bar { subreport 'foo' run } |
You don't need to define a subreport, you can just put the commands from foo in the {}. This often makes more sense, e.g. if you're not going to call foo from elsewhere. foreach is for navigation from a graph to its elements. For navigation between elements use "do" or "dowhile" (which covers SEPARATOR): |
«EXPAND foo FOREACH Bar» |
do .Bar { subreport 'foo' run } |
«EXPAND foo FOREACH Bar SEPARATOR ","» |
dowhile .Bar { subreport 'foo' run ','} |
«this.name» |
:name |
«LET ... AS var ..<var>.. ENDLET» |
variable 'var' write ... close ..$var.. |
For assignments with a single element on the right-hand side, you can use the shorter form: $var = 'foo', $var = :foo etc. |
«REM...ENDREM» |
/*...*/ |
«PROTECT ID ... ... ENDPROTECT» |
md5id ... md5block ... md5sum |
«CSTART ... CEND ...» |
filename 'bar.java' md5start ... md5stop ... merge .. .. .. close |
The start and end sequences are specified in the filename command, since they will be the same for the whole file |
«this.name.toUpper()» |
:Name%upper |
For text manipulation, e.g. with Java in oAW, you can use MERL translators. Many are defined in _translators, such as %upper a-z A-Z, and you can define your own to convert any combination of characters, strings and regular expressions. |
Edited by stevek - 31.Aug.2009 at 11:37