Difference between revisions of "ObjectType:string"

From Lavish Software Wiki
Jump to navigation Jump to search
 
(34 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 +
{{ObjectType-Vitals|string|[[LavishScript]]|none|the stored text|[[ObjectType:mutablestring|mutablestring]]|no|const char *}}
 
== Description ==
 
== Description ==
 
A string, also known as <tt>text</tt> is a series of consecutive characters.
 
A string, also known as <tt>text</tt> is a series of consecutive characters.
 +
  
 
== Members ==
 
== Members ==
* [[DataType:string|string]] '''Arg['''#''']''': ''(not yet implemented)''
+
* [[DataType:string|string]] '''Mid['''position''','''length''']:''' Returns a string containing the given length at the given position (1-based) of the original string
* [[DataType:string|string]] '''Mid['''position''','''length''']:''' ''(not yet implemented)''
+
* [[DataType:string|string]] '''Left['''#''']''': Returns a string containing the leftmost # characters of the original string. A negative number can be used to give the leftmost (Length-#)
* [[DataType:string|string]] '''Left['''#''']''':  
+
* [[DataType:string|string]] '''Right['''#''']''': Returns a string containing the rightmost # characters of the original string. A negative number can be used to give the rightmost (Length-#)
* [[DataType:string|string]] '''Right['''#''']''':  
+
* [[DataType:int|int]] '''Find['''text''']''': Returns the 1-based position of a given substring in the original string, or NULL
* [[DataType:int|int]] '''Find['''text''']''':  
+
* [[DataType:int|int]] '''Length''': Returns the length of the string
* [[DataType:int|int]] '''Length''':  
+
* [[DataType:string|string]] '''Upper''': Returns a string containing the original string in all upper case
* [[DataType:string|string]] '''Upper''':  
+
* [[DataType:string|string]] '''Lower''': Returns a string containing the original string in all lower case
* [[DataType:string|string]] '''Lower''':  
+
* [[DataType:int|int]] '''Compare['''text''']''': Compares this string, without regards to case, to the given text. Return value is less than 0 if the text would come before it in the dictionary, 0 if it is equal, or greater than 0 if the text would come after the string
* [[DataType:int|int]] '''Compare[text]:
+
* [[DataType:int|int]] '''CompareCS['''text''']''': Compares this string, ''with'' regards to case, to the given text. Return value is less than 0 if the text would come before it in the dictionary, 0 if it is equal, or greater than 0 if the text would come after the string
* [[DataType:int|int]] '''CompareCS[text]:
+
* [[DataType:bool|bool]] '''Equal['''text''']''': TRUE if the string is equal to, without regards to case, the given text
* [[DataType:bool|bool]] '''Equal[text]:
+
* [[DataType:bool|bool]] '''NotEqual['''text''']''': TRUE if the string is ''not'' equal to, without regards to case, the given text
* [[DataType:bool|bool]] '''NotEqual[text]:
+
* [[DataType:bool|bool]] '''EqualCS['''text''']''': TRUE if the string is equal to, ''with'' regards to case, the given text
* [[DataType:bool|bool]] '''EqualCS[text]:
+
* [[DataType:bool|bool]] '''NotEqualCS['''text''']''': TRUE if the string is ''not'' equal to, ''with'' regards to case, the given text
* [[DataType:bool|bool]] '''NotEqualCS[text]:
+
* [[DataType:int|int]] '''Count['''char''']''': The number of times a specific character appears in the string
* [[DataType:int|int]] '''Count[char]:
+
* [[DataType:string|string]] '''Token['''#''','''separator''']''': "Tokenizes" the string by the given separator and returns the #th token
* [[DataType:string|string]] '''Token['''#''','''separator''']''': ''(not yet implemented)''
+
* [[DataType:string|string]] '''Escape''': Uses slashes to escape '''\''', '''"''', carriage return, line feed, tab, as well as LavishScript data sequences
 +
* [[DataType:string|string]] '''Escape['''bool escapeLavishScript''']''': If escapeLavishScript is false/0, Uses slashes to escape '''\''', '''"''', carriage return, line feed, tab, but NOT LavishScript data sequences
 +
* [[DataType:string|string]] '''EscapeQuotes''': Uses slashes to escape '''"''' only
 +
* [[DataType:string|string]] '''Replace['''character''','''with''',...]''': Performs single-character replacement with any number of character pairs
 +
* [[DataType:string|string]] '''ReplaceSubstring['''needle''','''replacement''']''': Performs in-place replacement of a needle in a haystack. For example, <tt>${String[abcdefg].ReplaceSubstring[def,xyz]}</tt> is <tt>abcxyzg</tt>
 +
* [[ObjectType:byte|byte]] '''GetAt['''#''']''': Retrieves a character at the #th position in the string (1-based)
 +
* [[ObjectType:unistring|unistring]] '''UniString''':
 +
* [[DataType:string|string]] '''URLEncode''': Returns a %u encoded version of the string, suitable for urls
 +
* [[ObjectType:bool|bool]] '''NotNULLOrEmpty''': TRUE if the string is not empty and does not contain the literal NULL. This provides a shortcut for: <tt>if ${MyString.Length} && !${MyString.Equals[NULL]}</tt>
 +
* [[ObjectType:string|string]] '''Trim''': Returns a copy of the string with no leading or trailing whitespace
 +
* [[ObjectType:string|string]] '''AsJSON''': Returns a JSON encoded version of the string, including surrounding quotes
 +
 
 +
== Methods ==
 +
''(none)''
 +
 
 +
 
 +
== Declaring string Variables ==
 +
*Any string '''variable''' is automatically a [[DataType:mutablestring|mutablestring]]
 +
*variable string Food="Pizza"
 +
 
 +
 
 +
== Comparing Strings ==
 +
variable string name1="fred"
 +
variable string name2="george"
 +
if ${name1.Equal[${name2}]}
 +
{
 +
    echo We're both named fred!
 +
}
  
== Examples ==
 
  
 
== See Also ==
 
== See Also ==
 +
{{LavishScript:ObjectType}}

Latest revision as of 00:46, 24 July 2020

Object Type Vitals
string
Defined By LavishScript
Inherits none
Reduces To the stored text
Variable Object Type mutablestring
Uses Sub-Types no
C/C++ Type const char *

Description

A string, also known as text is a series of consecutive characters.


Members

  • string Mid[position,length]: Returns a string containing the given length at the given position (1-based) of the original string
  • string Left[#]: Returns a string containing the leftmost # characters of the original string. A negative number can be used to give the leftmost (Length-#)
  • string Right[#]: Returns a string containing the rightmost # characters of the original string. A negative number can be used to give the rightmost (Length-#)
  • int Find[text]: Returns the 1-based position of a given substring in the original string, or NULL
  • int Length: Returns the length of the string
  • string Upper: Returns a string containing the original string in all upper case
  • string Lower: Returns a string containing the original string in all lower case
  • int Compare[text]: Compares this string, without regards to case, to the given text. Return value is less than 0 if the text would come before it in the dictionary, 0 if it is equal, or greater than 0 if the text would come after the string
  • int CompareCS[text]: Compares this string, with regards to case, to the given text. Return value is less than 0 if the text would come before it in the dictionary, 0 if it is equal, or greater than 0 if the text would come after the string
  • bool Equal[text]: TRUE if the string is equal to, without regards to case, the given text
  • bool NotEqual[text]: TRUE if the string is not equal to, without regards to case, the given text
  • bool EqualCS[text]: TRUE if the string is equal to, with regards to case, the given text
  • bool NotEqualCS[text]: TRUE if the string is not equal to, with regards to case, the given text
  • int Count[char]: The number of times a specific character appears in the string
  • string Token[#,separator]: "Tokenizes" the string by the given separator and returns the #th token
  • string Escape: Uses slashes to escape \, ", carriage return, line feed, tab, as well as LavishScript data sequences
  • string Escape[bool escapeLavishScript]: If escapeLavishScript is false/0, Uses slashes to escape \, ", carriage return, line feed, tab, but NOT LavishScript data sequences
  • string EscapeQuotes: Uses slashes to escape " only
  • string Replace[character,with,...]: Performs single-character replacement with any number of character pairs
  • string ReplaceSubstring[needle,replacement]: Performs in-place replacement of a needle in a haystack. For example, ${String[abcdefg].ReplaceSubstring[def,xyz]} is abcxyzg
  • byte GetAt[#]: Retrieves a character at the #th position in the string (1-based)
  • unistring UniString:
  • string URLEncode: Returns a %u encoded version of the string, suitable for urls
  • bool NotNULLOrEmpty: TRUE if the string is not empty and does not contain the literal NULL. This provides a shortcut for: if ${MyString.Length} && !${MyString.Equals[NULL]}
  • string Trim: Returns a copy of the string with no leading or trailing whitespace
  • string AsJSON: Returns a JSON encoded version of the string, including surrounding quotes

Methods

(none)


Declaring string Variables

  • Any string variable is automatically a mutablestring
  • variable string Food="Pizza"


Comparing Strings

variable string name1="fred"
variable string name2="george"
if ${name1.Equal[${name2}]}
{
    echo We're both named fred!
}


See Also

LavishScript Object Types