Difference between revisions of "Extensions.Util.StringFormat"

From emotive
Jump to navigation Jump to search
(Created page with "{{DISPLAYTITLE: '''StringFormat'''}}Category:Util == Classification == {{ClassificationActivity | StringFormat | UPDATING...<!--Create an event source for change event-->...")
 
Line 1: Line 1:
 
{{DISPLAYTITLE:  '''StringFormat'''}}[[Category:Util]]
 
{{DISPLAYTITLE:  '''StringFormat'''}}[[Category:Util]]
 
== Classification ==
 
== Classification ==
{{ClassificationActivity | StringFormat | UPDATING...<!--Create an event source for change event--> | [[Term]] | [[Extensions.Util|OTX Util extension]] | UPDATING... | UPDATING... | UPDATING... }}
+
{{ClassificationActivity | StringFormat| Converts the given terms to format specified strings | [[Term]] | [[Extensions.Util|OTX Util extension]] | [[Extensions.Util#Terms|Util related terms]] | [[Extensions.Util.StringFormatException|StringFormatException]] | - }}
  
 
== OTL Syntax ==
 
== OTL Syntax ==
UPDATING...<!--
 
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
EventSourceTerm = EventHandling.MonitorChangeEventSource(Variable);
+
StringTerm = Util.StringFormat(StringTerm, StringTerm, SimpleTerm);
 
</syntaxhighlight>
 
</syntaxhighlight>
-->
 
  
 
== Description ==
 
== Description ==
UPDATING...<!--
+
The OTX '''StringFormat''' term converts the given terms to format specified strings and inserts them into another string.
The OTX '''MonitorChangeEventSource''' term creates an event source that monitors the value of a variable and an event triggers when the value changed. Event queue should start immediately as soon as the event source is created.
 
  
{{Note|The case when a value to a previously uninitialized variable is assigned to count as a change event and make no mistake.}}
+
{{TermReturnValue| [[Core.DataTypes.SimpleDataType.String|String]] | The string is created from the given terms and format specified strings.}}
 
 
{{TermReturnValue| [[Extensions.EventHandling.EventSource|EventSource]] | '''The EventSource''', the changes in the value of a variable monitored.}}
 
  
 
== Properties ==
 
== Properties ==
UPDATING...//
 
 
{| {{TableHeader}}
 
{| {{TableHeader}}
 
{{TableRowPropertiesHeader}}
 
{{TableRowPropertiesHeader}}
{{TableRowPropertie1| Variable | - | [[Variable]] | - | [1] | The variable which has to be monitored.}}
+
{{TableRowPropertie2| Format| [[Core.DataTypes.SimpleDataType.String|String]] | [[Term]] | - | [1..1] | The format is a StringTerm that can contain one or more format specifiers.}}
 +
{{TableRowPropertie1|Locale| [[Core.DataTypes.SimpleDataType.String|String]] | [[Term]] | - | [0..1] | The locale to apply during formatting. The format is identical to that used in [[Extensions.I18n.GetCurrentLocale|'''i18n:GetCurrentLocale''']]. If the locale is not given, empty or not supported, the default locale of the runtime system is taken. The current language can be identified by calling [[Extensions.I18n.GetCurrentLocale|'''i18n:GetCurrentLocale''']].}}
 +
{{TableRowPropertie2| Argument| [[Core.DataTypes.SimpleDataType|Simple]] | [[Term]] | - | [0..*] | Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. If more identical format specifiers are used in the format string, the appropriate arguments are inserted multiple.
 +
 
 +
The maximum number of arguments is limited of resources of the used run time system. A recommendation is not to use more than 10 arguments.}}
 
|}
 
|}
-->
 
  
 
== OTL Examples ==
 
== OTL Examples ==
UPDATING...<!--
 
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
Boolean Bool1 = false;
+
String String1;
EventHandling.EventSource EventSource1;
+
String Locale = "";
EventHandling.Event Event1;
+
 
 +
/// Flow
  
EventSource1 = EventHandling.MonitorChangeEventSource(Bool1);
+
Locale = I18n.GetCurrentLocale();
parallel
+
String1 = Util.StringFormat("{0} Peter, {0} {1} {0}", Locale, {"Hello", "Klaus"});
{
 
  lane
 
  {
 
      Bool1 = true;
 
  }
 
  lane
 
  {
 
      EventHandling.WaitForEvent({EventSource1}, Event1);
 
  }
 
}
 
 
</syntaxhighlight>
 
</syntaxhighlight>
-->
 
  
 
== See also ==
 
== See also ==
 
[[Extensions.Util.Compare|Compare]] <br/>
 
[[Extensions.Util.Compare|Compare]] <br/>
 
[[Extensions.Util.CopyByteField|CopyByteField]] <br/>
 
[[Extensions.Util.CopyByteField|CopyByteField]] <br/>
 +
[[Extensions.Util.GetRandomNumber|GetRandomNumber]] <br/>
 
[[Extensions.Util.IsInitialized|IsInitialized]] <br/>
 
[[Extensions.Util.IsInitialized|IsInitialized]] <br/>
 
[[Extensions.Util.ListIndexOf|ListIndexOf]] <br/>
 
[[Extensions.Util.ListIndexOf|ListIndexOf]] <br/>

Revision as of 09:01, 5 October 2018

Classification

Name StringFormat
Short Description Converts the given terms to format specified strings
Class Term
Extension OTX Util extension
Group Util related terms
Exceptions StringFormatException
Checker Rules -
Standard Compliant Yes

OTL Syntax

StringTerm = Util.StringFormat(StringTerm, StringTerm, SimpleTerm);

Description

The OTX StringFormat term converts the given terms to format specified strings and inserts them into another string.

Return Value

The Term returns the value, see table below.

Icons Note.png In OTX, Terms are categorized according to its return data type!
Data Type Description
String The string is created from the given terms and format specified strings.

Properties

Name Data Type Class Default Cardinality Description
Format String Term - [1..1] The format is a StringTerm that can contain one or more format specifiers.
Locale String Term - [0..1] The locale to apply during formatting. The format is identical to that used in i18n:GetCurrentLocale. If the locale is not given, empty or not supported, the default locale of the runtime system is taken. The current language can be identified by calling i18n:GetCurrentLocale.
Argument Simple Term - [0..*] Arguments referenced by the format specifiers in the format string. If there are more arguments than format specifiers, the extra arguments are ignored. The number of arguments is variable and may be zero. If more identical format specifiers are used in the format string, the appropriate arguments are inserted multiple.

The maximum number of arguments is limited of resources of the used run time system. A recommendation is not to use more than 10 arguments.

OTL Examples

String String1;
String Locale = "";

/// Flow

Locale = I18n.GetCurrentLocale();
String1 = Util.StringFormat("{0} Peter, {0} {1} {0}", Locale, {"Hello", "Klaus"});

See also

Compare
CopyByteField
GetRandomNumber
IsInitialized
ListIndexOf
ListIndexOfAny
ListReverse
ListSort
Max
Min