Print Page | Close Window

Quick MERL concatenating in MetaEdit+ 5.0

Printed From: MetaCase
Category:
Forum Name: MetaEdit+
Forum Description: All topics relating to MetaEdit+ or DSM
URL: https://www.metacase.com/forums/forum_posts.asp?TID=538
Printed Date: 27.Mar.2026 at 00:26
Software Version: Web Wiz Forums 12.05 - http://www.webwizforums.com


Topic: Quick MERL concatenating in MetaEdit+ 5.0
Posted By: stevek
Subject: Quick MERL concatenating in MetaEdit+ 5.0
Date Posted: 13.Sep.2012 at 14:52
In MERL we can assign variables:
$a = 'foo'
$b = $a
but we can't assign multiple strings in a single assignment:
$c = 'foo' $a
That gets parsed as an assignment $c ='foo', plus an output of $a. In 4.5 for an assignment and a concatenation, you used the full variable command:
variable 'c' write
   'foo'
   $a
close
In 5.0 we can use subgenerators as functions, with parentheses surrounding the comma-separated arguments. Each argument can be formed by the output of multiple commands: just like in Java you can write "foo(name+" "+surname, b)", in MERL you can write "foo($name ' ' $surname, $b)". MERL concatenates the output from all of an argument's commands, then passes the result as the argument.
 
So if we define a MERL generator function that simply outputs its single argument:
concat(@arg)
   @arg
we can use it to concatenate multiple commands. This lets us rewrite our initial example as:
$c = concat('foo' $a) /* NB only one argument, not concat ('foo', $a) */
Or even better, if we rename concat() to __():
$c = __('foo' $a)
which will be ignored because of its __ prefix when building the generator call tree hierarchy display, and so become almost part of the language. And now in all the places where before you could only have a single command (assignment RHS, comparison LHS and RHS...), you can have a concatenation almost for free.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.05 - http://www.webwizforums.com
Copyright ©2001-2022 Web Wiz Ltd. - https://www.webwiz.net