$Str: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
Line 2: Line 2:
<span class="pageSubtitle"><section begin="desc" />Treat a longstring as string<section end="desc" /></span>
<span class="pageSubtitle"><section begin="desc" />Treat a longstring as string<section end="desc" /></span>


<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Str function is [[to be entered]].</p>
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the $Str function.</p>


This function takes a longstring input and produces a string output, silently truncating the result at 255 bytes or shorter if the target is shorter.  
This function takes a longstring input and produces a string output, silently truncating the result at 255 bytes or shorter if the target is shorter.  
Line 9: Line 9:


The first argument is an arbitrary string.
The first argument is an arbitrary string.
==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %STR = $Str(longstring)
<p class="syntax"><section begin="syntax" /> %STR = $Str(longstring)
Line 17: Line 18:


For example, if %LINCOLN was a LONGSTRING %variable containing the text of the '''Gettysburg Address''' and %AGE was a STRING LEN 20
For example, if %LINCOLN was a LONGSTRING %variable containing the text of the '''Gettysburg Address''' and %AGE was a STRING LEN 20
<p class="code"> %AGE = $Str(%LINCOLN)
<p class="code"> %AGE = $Str(%LINCOLN)
</p>
</p>
Line 23: Line 25:
The main utility of the $Str function is to prevent the request cancellation that would result from a direct assignment from a LONGSTRING value to a STRING %variable that is too small to hold the entire value. While the input to $Str could be a regular STRING this doesn't really make much sense since a regular STRING can be assigned to a regular STRING without request cancellation for truncation, anyway. A $Str would upgrade a WITH expression that's its argument to a LONGSTRING WITH expression but this is again rather silly as the result would then simply be truncated at 255 bytes should it exceed 255 bytes. $Str also makes sense as a quick shorthand for the first 255 bytes of a LONGSTRING, even if the target is a LONGSTRING.  
The main utility of the $Str function is to prevent the request cancellation that would result from a direct assignment from a LONGSTRING value to a STRING %variable that is too small to hold the entire value. While the input to $Str could be a regular STRING this doesn't really make much sense since a regular STRING can be assigned to a regular STRING without request cancellation for truncation, anyway. A $Str would upgrade a WITH expression that's its argument to a LONGSTRING WITH expression but this is again rather silly as the result would then simply be truncated at 255 bytes should it exceed 255 bytes. $Str also makes sense as a quick shorthand for the first 255 bytes of a LONGSTRING, even if the target is a LONGSTRING.  


For more information
$Str is only available in ''[[Sirius Mods]]'' Version 6.2 and later.


$Str is only available in ''[[Sirius Mods]]'' Version 6.2 and later.
<ul class="smallAndTightList">
<ul class="smallAndTightList">
<li>[[Sirius functions]]</li>
<li>[[Sirius functions]]</li>
Line 35: Line 36:
<li>[[Japanese functions]]</li>
<li>[[Japanese functions]]</li>
<li>[[Sir2000 Field Migration Facility]]</li>
<li>[[Sir2000 Field Migration Facility]]</li>
</ul>
</ul>
<p class="caption">Products authorizing $Str
<p class="caption">Products authorizing $Str
</p>
</p>


[[Category:$Functions|$Str]]
[[Category:$Functions|$Str]]

Revision as of 19:55, 8 February 2011

<section begin="desc" />Treat a longstring as string<section end="desc" />

Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the $Str function.

This function takes a longstring input and produces a string output, silently truncating the result at 255 bytes or shorter if the target is shorter.

The $Str function accepts one argument and returns a string result that is the first argument truncated at the $function target's length.

The first argument is an arbitrary string.

Syntax

<section begin="syntax" /> %STR = $Str(longstring) <section end="syntax" />

$Str Function

%STR is up to the first 255 bytes of longstring.

For example, if %LINCOLN was a LONGSTRING %variable containing the text of the Gettysburg Address and %AGE was a STRING LEN 20

%AGE = $Str(%LINCOLN)

would result in %AGE containing "Four score and seven".

The main utility of the $Str function is to prevent the request cancellation that would result from a direct assignment from a LONGSTRING value to a STRING %variable that is too small to hold the entire value. While the input to $Str could be a regular STRING this doesn't really make much sense since a regular STRING can be assigned to a regular STRING without request cancellation for truncation, anyway. A $Str would upgrade a WITH expression that's its argument to a LONGSTRING WITH expression but this is again rather silly as the result would then simply be truncated at 255 bytes should it exceed 255 bytes. $Str also makes sense as a quick shorthand for the first 255 bytes of a LONGSTRING, even if the target is a LONGSTRING.

$Str is only available in Sirius Mods Version 6.2 and later.

Products authorizing $Str