$Str: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE:$Str}} <span class="pageSubtitle"><section begin="desc" />Treat a longstring as string<section end="desc" /></span> <p class="warning">Most Sirius $functions have...")
 
(Automatically generated page update)
 
(37 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:$Str}}
{{DISPLAYTITLE:$Str}}
<span class="pageSubtitle"><section begin="desc" />Treat a longstring as string<section end="desc" /></span>
<span class="pageSubtitle">Treat a longstring as string</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="warn"><b>Note: </b>Many $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.  


The $Str function accepts one argument and returns a string result that is the first argument truncated at the $function target's length.  
The <var>$Str</var> 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.
The first argument is an arbitrary string.
==Syntax==
==Syntax==
<p class="syntax"><section begin="syntax" /> %STR = $Str(longstring)
<p class="syntax"><span class="term">%str</span> = <span class="literal">$Str</span>(<span class="term">longstring</span>)
<section end="syntax" /></p>
<p class="caption">$Str Function
</p>
</p>
<p class="caption">%STR is up to the first 255 bytes of '''longstring'''.</p>


For example, if %LINCOLN was a LONGSTRING %variable containing the text of the '''Gettysburg Address''' and %AGE was a STRING LEN 20
<p>
<p class="code"> %AGE = $Str(%LINCOLN)
<var class="term">%str</var> is up to the first 255 bytes of <var class="term">longstring</var>.</p>
 
==Usage notes==
<ul>
<li>The main utility of the <var>$Str</var> function is to prevent the request cancellation that would result from a direct assignment from a <var>Longstring</var> value to a <var>String</var> %variable that is too small to hold the entire value. While the input to <var>$Str</var> could be a regular <var>String</var>, this doesn't really make much sense since a regular <var>String</var> can be assigned to a regular <var>String</var> without request cancellation for truncation, anyway.
<p>
A <var>$Str</var> would upgrade an argument With expression to a <var>Longstring</var> With expression, but this is again rather silly as the result would then simply be truncated at 255 bytes if it exceeds 255 bytes.
</p>
</p>
would result in %AGE containing "Four score and seven".
<li><var>$Str</var> also makes sense as a quick shorthand for the first 255 bytes of a <var>Longstring</var>, even if the target is a <var>Longstring</var>.
 
</ul>
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.
==Products authorizing {{PAGENAMEE}}==
<ul class="smallAndTightList">
<ul class="smallAndTightList">
<li>[[Sirius functions]]</li>
<li>[[List of $functions|Sirius functions]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Janus Open Client]]</li>
<li>[[Media:JoclrNew.pdf|Janus Open Client]]</li>
<li>[[Janus Open Server]]</li>
<li>[[Media:JosrvrNew.pdf|Janus Open Server]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Japanese functions]]</li>
<li>Japanese functions</li>
<li>[[Sir2000 Field Migration Facility]]</li>
<li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]]</li>
 
</ul>
</ul>
<p class="caption">Products authorizing $Str
</p>


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

Latest revision as of 23:28, 20 September 2018

Treat a longstring as string

Note: Many $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

%str = $Str(longstring)

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

Usage notes

  • 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 an argument With expression to a Longstring With expression, but this is again rather silly as the result would then simply be truncated at 255 bytes if it exceeds 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.

Products authorizing $Str