Implicit concatenation: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Created page with "{{Template: New feature in 7.9 mods}} ?? blah blah")
 
mNo edit summary
 
(8 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{Template: New feature in 7.9 mods}}
{{Template: New feature in 7.9 mods}}
[[??]] blah blah
 
Implicit concatenation eliminates the need to precede <var class="product">User Language</var> variables (including methods chained off a variable) and literals with the operator <code>With</code> to indicate concatenation. For example, the following statement sets <code>%foo</code> to the contents of <code>%test</code> enclosed within parentheses:
<p class="code">%foo = "(" %test ")"</p>
 
And the following statement sets <code>%foo</code> to the reversed, right-most 4 characters of <code>%test</code> enclosed within parentheses:
<p class="code">%foo = "(" %test:right(4):reverse ")"</p>
 
If <code>%nal</code> is a <var>Named Arraylist</var> of <var>String</var>, implicit concatenation lets you assign to <code>%foo</code> value of item <code>%x +1</code> embedded inside single quotes:
<p class="code">%foo = "'" %nal(%x + 1) "'"</p>
 
The [[At sign (@) on right side of assignment|at sign (@)]] will also be implicitly concatenated if not preceded by an operator. For example, the follow concatenates a "==>" to the current contents of <code>%string</code> and assigns it to <code>%string</code>:
<p class="code">%string = '==>' @</p>
 
In <var class="product">Sirius Mods</var> 8.1 and later, the results of a $function will also be implicitly concatenated with the preceding expression results:
<p class="code">%message = "The problem happened at " $time " on " $date "."</p>
 
<var>With</var> is still required before field names:
<p class="code">%foo = '>>' with FIELD NAME</p>                                   
                                                                       
And <var>With</var> is still required before expressions in parentheses:
<p class="code">%foo = '>>' with (%x + 2) </p>                                           
 
[[Category:User Language syntax enhancements]]

Latest revision as of 03:39, 3 October 2012

This feature is new in version 7.9 of the Sirius Mods.

Implicit concatenation eliminates the need to precede User Language variables (including methods chained off a variable) and literals with the operator With to indicate concatenation. For example, the following statement sets %foo to the contents of %test enclosed within parentheses:

%foo = "(" %test ")"

And the following statement sets %foo to the reversed, right-most 4 characters of %test enclosed within parentheses:

%foo = "(" %test:right(4):reverse ")"

If %nal is a Named Arraylist of String, implicit concatenation lets you assign to %foo value of item %x +1 embedded inside single quotes:

%foo = "'" %nal(%x + 1) "'"

The at sign (@) will also be implicitly concatenated if not preceded by an operator. For example, the follow concatenates a "==>" to the current contents of %string and assigns it to %string:

%string = '==>' @

In Sirius Mods 8.1 and later, the results of a $function will also be implicitly concatenated with the preceding expression results:

%message = "The problem happened at " $time " on " $date "."

With is still required before field names:

%foo = '>>' with FIELD NAME

And With is still required before expressions in parentheses:

%foo = '>>' with (%x + 2)