StringToValue

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<javascript>" to "<syntaxhighlight lang="javascript">")
Line 7: Line 7:
 
=====Description=====
 
=====Description=====
 
Returns the value in string input between startFlag and endFlag, beginning at startPos.
 
Returns the value in string input between startFlag and endFlag, beginning at startPos.
<javascript>var value : String = GetValue ("[12]gibberish[17]gibberish", "[", "]", 6); // returns 17</javascript>
+
<syntaxhighlight lang="javascript">var value : String = GetValue ("[12]gibberish[17]gibberish", "[", "]", 6); // returns 17</javascript>
 
----
 
----
 
function GetValue(input : String, startFlag : String, endFlag : String) : String
 
function GetValue(input : String, startFlag : String, endFlag : String) : String
Line 13: Line 13:
 
=====Description=====
 
=====Description=====
 
Returns the value in string input between startFlag and endFlag.
 
Returns the value in string input between startFlag and endFlag.
<javascript>var value : String = GetValue ("[12]gibberish[17]gibberish", "[", "]"); // returns 12</javascript>
+
<syntaxhighlight lang="javascript">var value : String = GetValue ("[12]gibberish[17]gibberish", "[", "]"); // returns 12</javascript>
 
----
 
----
  
<javascript>
+
<syntaxhighlight lang="javascript">
 
function GetValue(input : String, startFlag : String, endFlag : String, startPos : int) {
 
function GetValue(input : String, startFlag : String, endFlag : String, startPos : int) {
 
startIndex = input.IndexOf(startFlag,startPos);
 
startIndex = input.IndexOf(startFlag,startPos);

Revision as of 20:48, 10 January 2012

Functions for getting a value in string input between strings startFlag and endFlag, with an optional starting point index. Useful for dynamic import logic.

Author: Danny Lawrence

Usage

function GetValue (input : String, startFlag : String, endFlag : String, startPos : int) : string

Description

Returns the value in string input between startFlag and endFlag, beginning at startPos.

var value : String = GetValue ("[12]gibberish[17]gibberish", "[", "]", 6); // returns 17</javascript>
----
function GetValue(input : String, startFlag : String, endFlag : String) : String
 
=====Description=====
Returns the value in string input between startFlag and endFlag.
<syntaxhighlight lang="javascript">var value : String = GetValue ("[12]gibberish[17]gibberish", "[", "]"); // returns 12</javascript>
----
 
<syntaxhighlight lang="javascript">
function GetValue(input : String, startFlag : String, endFlag : String, startPos : int) {
	startIndex = input.IndexOf(startFlag,startPos);
	endIndex = input.IndexOf(endFlag,startPos);
	valueLength = endIndex - startIndex - 1;
	print (input);
	output = input.Substring(startIndex+1,valueLength);
	return output;
};
 
function GetValue(input : String, startFlag : String, endFlag : String) {
	startIndex = input.IndexOf(startFlag);
	endIndex = input.IndexOf(endFlag);
	valueLength = endIndex - startIndex - 1;
	print (input);
	output = input.Substring(startIndex+1,valueLength);
	return output;
};</javascript>
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox