V7.8 changes affecting all or multiple products: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 4: Line 4:
These features are added in Sirius Mods 7.8.
These features are added in Sirius Mods 7.8.
===Tilde directives===
===Tilde directives===
as of Sirius Mods 7.8, certain Text/Html statement directives can be placed after a tilde character (~) inside curly braces ({ }) in any of the [[Targeted text statements|targeted text statements]] (which include AuditText, PrintText, TraceText, SetText, and ReturnText. For example, this statement sets <tt>%ls</tt> to the current time, embedded in hyphens.  
as of Sirius Mods 7.8, certain Text/Html statement directives can be placed after a tilde character (~) inside curly braces ({ }) in any of the [[Targeted text statements|targeted text statements]] (which include AuditText, PrintText, TraceText, and new in V7.8, [[SetText]] and [[ReturnText]]. For example, this statement sets <tt>%ls</tt> to the current time, embedded in hyphens.  
   setText %ls = {~nocont}---{$time}---
   setText %ls = {~nocont}---{$time}---
Because the <tt>~nocont</tt> directive was specified, the terminating hyphen is not treated as a continuation character.  
Because the <tt>~nocont</tt> directive was specified, the terminating hyphen is not treated as a continuation character.  
Line 24: Line 24:
</dl>
</dl>


===~= directives===
As of ''Sirius Mods'' version 7.8, you can use a <tt>~=</tt> directive as a shorthand for <tt>{~}={''expression''}</tt>. For example, <br><tt>printtext {~=%i}, {~=%j}, {~=(%i+%j):toPower(3)}</tt> would display <tt>%i=22, %j=33, (%i + %j):toPower(3)=166375</tt>. <br>Note that in the directive, spaces are optional after the equal sign, and the output produces no spaces before or after the equal sign. If more control of spacing is required, use the {~} directive.
===SetText statement===
The SetText statement works much the same as AuditText, PrintText, and TraceText, but it is used to set a variable instead of outputting a string. That is, its primary intent is to use the text it sets in the current program.
                     
The syntax of the SetText statement is:
  setText %variable = string
Where:
<dl>
<dt>string
<dd>A literal string which may include expressions enclosed by curly braces, just as is used in the Text statement.
<br><br>For example, the following statement sets <tt>%x</tt> to the literal string ''"Patriotism is the last refuge of the scoundrel"''.
  setText %x = Patriotism is the last refuge of the scoundrel
And the following sets <tt>%x</tt> to the literal string ''"The sum of %x and %y is "'' followed by the sum of <tt>%x</tt> and <tt>%y</tt>:
  setText %x = The sum of %x and %y is {%x + %y}
<dt>%variable
<dd>A simple variable, a class variable, a class property, or a collection member (which is really just a special kind of class property). <br><br>For example, the following statement sets the String property of a StringTokenizer object to the literal string ''"Once upon a time"'':
  %toke        is object stringTokenizer
    ...
  setText %toke:string = Once upon a time
A single blank after the equal sign following a SetText is not required and is ignored, though you can use it for readability. The following statements both set %str to ''"Once a jolly swagman camped by a billabong"''.
  setText %str =Once a jolly swagman camped by a billabong
and
  setText %str = Once a jolly swagman camped by a billabong
Any additional blanks beyond the first one are treated as part of the literal source string.
</dl>
Continuations are treated in the normal way: the text continues from the first non-blank character on the next line.
<br><b>Tip</b>: if you need to include blank characters from the next line, use {} (a null expression) to indicate the start of the continuation.  For example:
  setText %str = Once a jolly swagman camped by:-
                  {}  a billabong
The statement above sets <tt>%str</tt> to:
  Once a jolly swagman camped by:  a billabong
However, since trailing blanks before a continuation are '''not''' stripped, you can also include blank characters by putting extra blanks at the end of the first SetText line:
  setText %str = Once a jolly swagman camped by:  -
                  a billabong
If you need to terminate the string with a hyphen, add the {} null expression to the end of a line. For example:
  setText %str = ------------{}
The statement above sets %str to:
  ------------
You can also use the ~noCont directive to indicate that a trailing hyphen is not to be treated as a continuation character:
  setText %str = {~nocont}------------
===ReturnText statement===
The ReturnText statement works much the same as AuditText, PrintText, and TraceText, but instead of outputting a string it is used to return a string value in a User Language function or property Get method. The syntax of the ReturnText statement is:
  ReturnText string
Where:
<dl>
<dt>string
<dd>A literal string which may include expressions enclosed by curly braces, just as in the Text statement.
</dl>
For example, if the Aphorism local function is applied to the number 1 in the following fragment, the function returns the literal string ''"Patriotism is the first refuge of the scoundrel"'':
<pre>
  local function (float):aphorism is longstring
 
  if %this eq 1 then
      returnText Patriotism is the first refuge of the scoundrel
  end if
  ...
  end function
</pre>
The following function returns the literal string ''"The sum of %x and %y is "'' followed by the sum of the <tt>%x</tt> and <tt>%y</tt> parameters passed to the local function:
<pre>
  local function stringAdd(%x is float, %y is float)
      returnText The sum of %x and %y is {%x + %y}
  end function
</pre>
Continuations are treated in the normal way: the text continues from the first non-blank character on the next line.<br>
<b>Tip</b>: if you need to include blank characters from the next line, use {} (a null expression) to indicate the start of the continuation. For example:
  returnText %str = Down came a jumbuck to drink at:-
                    {}  that billabong                   
The statement above returns:
  Down came a jumbuck to drink at:  that billabong
However, since trailing blanks before a continuation are '''not''' stripped, you can also include blank characters by putting extra blanks at the end of the first ReturnText line:
  returnText %str = Down came a jumbuck to drink at:  -
                    that billabong                   
If you need to terminate the string with a hyphen, add the {} null expression to the end of a line. For example:
  returnText ------------{}
The statement above returns:
  ------------
You can also use the ~noCont directive to indicate that a trailing hyphen is not to be treated as a continuation character:
  returnText {~nocont}------------


{{Hierarchy footer}}
{{Hierarchy footer}}

Revision as of 00:19, 18 December 2010

{{#hierarchy-top:}}

Text/Html statement enhancements

These features are added in Sirius Mods 7.8.

Tilde directives

as of Sirius Mods 7.8, certain Text/Html statement directives can be placed after a tilde character (~) inside curly braces ({ }) in any of the targeted text statements (which include AuditText, PrintText, TraceText, and new in V7.8, SetText and ReturnText. For example, this statement sets %ls to the current time, embedded in hyphens.

 setText %ls = {~nocont}---{$time}---

Because the ~nocont directive was specified, the terminating hyphen is not treated as a continuation character.

The tilde directives that are allowed in targeted text statements are:

~exprE
Sets the expression end characters. This directive must be followed by a space and then the expression start characters. For example, {~expre >} sets the expression end characters to a single greater-than sign (>). ~exprE can also be written as ~exprEnd. Note that the ~exprE directive must be ended by the expression end characters in effect before the ~expre directive is processed.
~exprS
Sets the expression start characters. This directive must be followed by a space and then the expression start characters. For example, {~exprs <} sets the expression start characters to a single less-than sign (<). ~exprS can also be written as ~exprStart.
~noCont
Indicates that a trailing hyphen is not treated as a continuation character. ~noCont can also be written as ~noContinuations.
~noEll
Indicates that a trailing ellipsis (...) is not treated as a partial-line indicator. Because it makes no sense to end a SetText or ReturnText with an ellipsis, this is the default for those two statements. So, while allowed, a ~noEll directive is completely unnecessary for SetText and ReturnText. ~noEll can also be written as ~noEllipses.
~noExpr
Indicates that no expressions are to be processed after the directive, and that everything after the ~noExpr directive is treated as literal text. No further tilde directives will be processed after a ~noExpr. ~noExpr can also be written as ~noExpressions.
~raw
Acts as if ~noCont, ~noEll, and ~noExpr are specified simultaneously. Note that this is slightly different from the Raw directive on the Text/Html statement, which also implies NoDum/NoDummy. Because dummy string substitution applies to lines before they are parsed, dummy string substitution would already have happened in any single-line Text statement before the ~raw directive was processed.

~= directives

As of Sirius Mods version 7.8, you can use a ~= directive as a shorthand for {~}={expression}. For example,
printtext {~=%i}, {~=%j}, {~=(%i+%j):toPower(3)} would display %i=22, %j=33, (%i + %j):toPower(3)=166375.
Note that in the directive, spaces are optional after the equal sign, and the output produces no spaces before or after the equal sign. If more control of spacing is required, use the {~} directive.

SetText statement

The SetText statement works much the same as AuditText, PrintText, and TraceText, but it is used to set a variable instead of outputting a string. That is, its primary intent is to use the text it sets in the current program.

The syntax of the SetText statement is:

  setText %variable = string

Where:

string
A literal string which may include expressions enclosed by curly braces, just as is used in the Text statement.

For example, the following statement sets %x to the literal string "Patriotism is the last refuge of the scoundrel". setText %x = Patriotism is the last refuge of the scoundrel And the following sets %x to the literal string "The sum of %x and %y is " followed by the sum of %x and %y: setText %x = The sum of %x and %y is {%x + %y}
%variable
A simple variable, a class variable, a class property, or a collection member (which is really just a special kind of class property).

For example, the following statement sets the String property of a StringTokenizer object to the literal string "Once upon a time": %toke is object stringTokenizer ... setText %toke:string = Once upon a time A single blank after the equal sign following a SetText is not required and is ignored, though you can use it for readability. The following statements both set %str to "Once a jolly swagman camped by a billabong". setText %str =Once a jolly swagman camped by a billabong and setText %str = Once a jolly swagman camped by a billabong Any additional blanks beyond the first one are treated as part of the literal source string.

Continuations are treated in the normal way: the text continues from the first non-blank character on the next line.
Tip: if you need to include blank characters from the next line, use {} (a null expression) to indicate the start of the continuation. For example:

  setText %str = Once a jolly swagman camped by:-
                 {}   a billabong

The statement above sets %str to:

  Once a jolly swagman camped by:   a billabong

However, since trailing blanks before a continuation are not stripped, you can also include blank characters by putting extra blanks at the end of the first SetText line:

  setText %str = Once a jolly swagman camped by:   -
                 a billabong

If you need to terminate the string with a hyphen, add the {} null expression to the end of a line. For example:

  setText %str = ------------{}

The statement above sets %str to:

  ------------

You can also use the ~noCont directive to indicate that a trailing hyphen is not to be treated as a continuation character:

  setText %str = {~nocont}------------

ReturnText statement

The ReturnText statement works much the same as AuditText, PrintText, and TraceText, but instead of outputting a string it is used to return a string value in a User Language function or property Get method. The syntax of the ReturnText statement is:

  ReturnText string

Where:

string
A literal string which may include expressions enclosed by curly braces, just as in the Text statement.

For example, if the Aphorism local function is applied to the number 1 in the following fragment, the function returns the literal string "Patriotism is the first refuge of the scoundrel":

   local function (float):aphorism is longstring
   
   if %this eq 1 then
      returnText Patriotism is the first refuge of the scoundrel
   end if
   ...
   end function

The following function returns the literal string "The sum of %x and %y is " followed by the sum of the %x and %y parameters passed to the local function:

   local function stringAdd(%x is float, %y is float)

      returnText The sum of %x and %y is {%x + %y}

   end function

Continuations are treated in the normal way: the text continues from the first non-blank character on the next line.
Tip: if you need to include blank characters from the next line, use {} (a null expression) to indicate the start of the continuation. For example:

  returnText %str = Down came a jumbuck to drink at:-
                    {}   that billabong                     

The statement above returns:

  Down came a jumbuck to drink at:   that billabong

However, since trailing blanks before a continuation are not stripped, you can also include blank characters by putting extra blanks at the end of the first ReturnText line:

  returnText %str = Down came a jumbuck to drink at:   -
                    that billabong                     

If you need to terminate the string with a hyphen, add the {} null expression to the end of a line. For example:

  returnText ------------{}

The statement above returns:

  ------------

You can also use the ~noCont directive to indicate that a trailing hyphen is not to be treated as a continuation character:

  returnText {~nocont}------------

{{#hierarchy-bottom:}}