• My Pages
  • Comments
  • Add Link
  • Subscribe
  • Subscribe User
  • Edit (GUI)
  • Edit (Text)
  • Rename Page
  • Copy Page
  • Load Page
  • Save Page
  • Delete Page
  • Attachments
  • Check Spelling
  • Diffs
  • Info
  • Revert to this revision
  • XML
  • Render as Docbook
  • Print View
  • Raw Text
  • Delete Cache
  • Like Pages
  • Local Site Map
  • Remove Spam
  • Package Pages
  • Sync Pages
    • Diff for "Strings"
    Differences between revisions 32 and 44 (spanning 12 versions)
    Revision 32 as of 2014-02-12 01:14:44
    Size: 11349
    Editor: Inanna
    Comment:
    Revision 44 as of 2015-02-08 06:30:49
    Size: 14133
    Editor: LKD70
    Comment:
    Deletions are marked like this. Additions are marked like this.
    Line 3: Line 3:
    These should be written in the following formats: 
     .''variable.function(arguments)'', example - ''myVar.subStr(3,2)'' if your variable name was "myVar" and you wanted to use subStr() to find the 2 characters that begin 3 from the left.

     .''object.function(arguments)'', example - ''city.coords.split(",")'' if you wanted to split the coordinates of your city into an array to determine the seperate x and y values using the split() function.
    These should be written in the following formats:

     .
    ''variable.function(arguments)'', example - ''myVar.subStr(3,2)'' if your variable name was "myVar" and you wanted to use subStr() to find the 2 characters that begin 3 from the left.

     . ''object.function(arguments)'', example - ''city.coords.split(",")'' if you wanted to split the coordinates of your city into an array to determine the seperate x and y values using the split() function.
    Line 11: Line 12:
    ||<tablewidth="796px" tableheight="123px"#cccccc>'''Function ''' ||<#cccccc>'''Type''' ||<#cccccc>'''Description '''||||<style="text-align:center"> || || ||<tablewidth="796px" tableheight="123px"#cccccc>'''Function ''' ||<#cccccc>'''Type''' ||<#cccccc>'''Description ''' ||||<style="text-align:center"> || ||
    Line 24: Line 25:
    ||[[#rightpad|RightPad]] ||String ||Appends spaces (or specified character) to a string to form string of the desired length. || ||[[#RightPad|RightPad]] ||String ||Appends spaces (or specified character) to a string to form string of the desired length. ||
    Line 29: Line 30:
    ||[[#StringToObj|StringToObject]] ||String ||Parses and converts strings with parameters into object. || ||[[#StringToObject|StringToObject]] ||String ||Parses and converts strings with parameters into object. ||
    Line 32: Line 33:
    ||[[#ToCSV|ToCSV]] ||String ||Converts arguments to comma-separated string with values enclosedi in qouble quotes. || ||[[#ToCSV|ToCSV]] ||String ||Converts arguments to comma-separated string with values enclosed in qouble quotes. ||
    Line 39: Line 40:
    ||[[#FormatMiles|FormatMiles]] ||int ||Converts number to a string, e.g. "2.34 miles". ||
    ||[[#FormatNumber|FormatNumber]] ||int ||Formats number with specified precision, e.g. "2,346". ||
    ||[[#FormatNumber2|FormatNumber2]] ||int ||Formats numbers with 2 decimal places, e.g. "2,345.56". ||
    ||[[#FormatPercent|FormatPercent]] ||int ||Formats number as percentage, e.g. "9.1%". ||

    Line 47: Line 54:
     .echo !CenterPad("This is a test", 25, ".")

    '''Result:'''
     .19:33:49 (5) - .....This is a test......

    . echo !CenterPad("This is a test", 25, ".")

    '''Result:'''

    . .....This is a test......
    Line 58: Line 67:
     .// Don't forget almost all internal "counting" starts at 0, not at 1...
     .// so the 5th character would actually be 0, 1, 2, 3, '''4''' <--- 4!   .var="hello"
     .echo "The 5th letter in the word hello is: " + var.charAt(4)

    '''Result:'''
     .00:49:44 The 5th letter in the word hello is: o
     .00:49:45 Script stopped

     .
    // Don't forget almost all internal "counting" starts at 0, not at 1...
     . // so the 5th character would actually be 0, 1, 2, 3, '''4''' <--- 4!
     .
    var="hello"
     . echo "The 5th letter in the word hello is: " + var.charAt(4)

    '''Result:'''

     . The 5th letter in the word hello is
    : o
    Line 73: Line 83:
     .var="hello"
     .echo "The numeric code of the 5th letter in the word hello is: " + var.charCodeAt(4)

    '''Result:'''
     .01:04:27 The numeric code of the 5th letter in the word hello is: 111
     .01:04:28 Script stopped

    . var="hello"
     . echo "The numeric code of the 5th letter in the word hello is: " + var.charCodeAt(4)

    '''Result:'''

    . The numeric code of the 5th letter in the word hello is: 111
    Line 86: Line 97:
     .var="oompa"
     .var2="loompa"
     .var3="dance"
     .echo var.concat(var2," ",var3)

    '''Result:'''
     .01:06:48 oompaloompa dance
     .01:06:49 Script stopped

    . var="oompa"
     . var2="loompa"
     . var3="dance"
     . echo var.concat(var2," ",var3)

    '''Result:'''

    . oompaloompa dance
    Line 96: Line 108:
    '''Usage:''' '''Usage:''' fromCharCode()
    Line 101: Line 113:
     .

    '''Result:'''
     .

    .echo String.fromCharCode(70)

    '''Result:'''

    .F
    Line 107: Line 121:
    '''Usage:''' '''Usage:''' IndexOf()
    Line 112: Line 126:
     .

    '''Result:'''
     .

     .string = "this is a test string."
     .echo string.indexOf("test")

    '''Result:'''

     .10
    Line 118: Line 135:
    '''Usage:''' '''Usage:''' lastIndexOf()
    Line 123: Line 140:
     .

    '''Result:'''
     .

     .string = "this is another test string."
     .echo string.lastIndexOf("test")

    '''Result:'''

     .16
    Line 134: Line 154:
     .echo !LeftPad("This is a test", 25, ".")

    '''Result:'''
     .19:45:24 ...........This is a test

    . echo !LeftPad("This is a test", 25, ".")

    '''Result:'''

    . ...........This is a test
    Line 140: Line 162:
    '''Usage:''' '''Usage:''' localeCompare()
    Line 145: Line 167:
     .

    '''Result:'''
     .

     .string = "abc"
     .echo "def".localeCompare(string)


    '''Result:'''

     .3
    Line 151: Line 177:
    '''Usage:'''

    Matches the specifed pattern against the string.

    '''Example:'''
     .

    '''Result:'''
     .
    '''Usage:''' match()

    Matches the specified pattern against the string. Usage of "/g" allows global search (returns multiple results if there's multiple instances).

    '''Example:'''

     .string = "This is just a simple test string."
     .echo string.match(/is/g)


    '''Result:'''

     .is,is
    Line 167: Line 196:
     .echo Merge("This is a test", "of the Emergency Broadcast System")
     .echo Merge("One plus One", "Two", " = ")

    '''Result:'''
     .19:47:50 (5) - This is a test of the Emergency Broadcast System
     .19:47:54 (5) - One plus One = Two

     .
    echo Merge("This is a test", "of the Emergency Broadcast System")
     . echo Merge("One plus One", "Two", " = ")

    '''Result:'''

     .
    This is a test of the Emergency Broadcast System
     . One plus One = Two
    Line 180: Line 211:
     .echo !RightPad("This is a test", 25, ".")

    '''Result:'''
     .19:46:25 This is a test...........

    . echo !RightPad("This is a test", 25, ".")

    '''Result:'''

    . This is a test...........
    Line 186: Line 219:
    '''Usage:'''

    Matches the specifed pattern against the string and returns a new string in which the first match of pattern is replaced with the content specified by repl.

    '''Example:'''
     .

    '''Result:'''
     .
    '''Usage:''' replace( , )

    Matches the specified pattern against the string and returns a new string in which the first match of pattern is replaced with the content specified.

    '''Example:'''

     .string = "yet another test string"
     .echo string.replace("test", "dull test")


    '''Result:'''

     .yet another dull test string
    Line 197: Line 233:
    '''Usage:'''

    Searches for the specifed pattern and returns the index of the first matching substring.

    '''Example:'''
     .

    '''Result:'''
     .
    '''Usage:''' search()

    Searches for the specified pattern and returns the index of the first matching sub-string.

    '''Example:'''

     .string = "yet another test string"
     .echo string.search("another")


    '''Result:'''

     .4
    Line 208: Line 247:
    '''Usage:''' '''Usage:''' slice( , )
    Line 213: Line 252:
     .

    '''Result:'''
     .

     .string = "Hello World!"
     .echo string.slice(1,5)

    '''Result:'''

     .ello
    Line 224: Line 266:
     .mycoords=city.coords.split(",")
     .echo "x:" + mycoords[0] + " y:" + mycoords[1]

    '''Result:'''
     .01:08:42 x:746 y:34
     .01:08:43 Script stopped

    . mycoords=city.coords.split(",")
     . echo "x:" + mycoords[0] + " y:" + mycoords[1]

    '''Result:'''

    . x:746 y:34
    Line 237: Line 280:
     .echo StringRepeat(25, ".")
     .echo StringRepeat(25, "Test")
     .echo StringRepeat(25, "Test ")

    '''Result:'''
     .20:12:25 (5) - .........................
     .20:12:30 (5) - TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest
     .20:13:17 (5) - Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test

     . echo !StringRepeat(25, ".")
     . echo !StringRepeat(25, "Test")
     . echo !StringRepeat(25, "Test ")

    '''Result:'''

     . .........................
     . !TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest
     . Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test
    Line 252: Line 297:
     .

    '''Result:'''
     .

     . str = "test1:no1,test2:no2"
     . o = !StringToObject(str,",",":")
     . echo o.test2

    '''Result:'''

     . no2
    Line 258: Line 307:
    '''Usage:''' '''Usage:''' substr(first, last)
    Line 263: Line 312:
     .

    '''Result:'''
     .

     .string = "Hello World!"
     .echo string.substr(1,4)

    '''Result:'''

     .ello
    Line 269: Line 321:
    '''Usage:''' '''Usage:''' substring(first, last)
    Line 274: Line 326:
     .

    '''Result:'''
     .

     .string = "Hello World!"
     .echo string.substring(1,4)

    '''Result:'''

     .ell
    Line 285: Line 340:
     .who = "Bob"
     .what = "Cap his city"
     .when = date()
     .echo ToCSV(who, what, when)

    '''Result:'''
     .19:59:39 (5) - "Bob","Cap his city","Tue Feb 11 19:59:38 GMT-0500 2014"

    . who = "Bob"
     . what = "Cap his city"
     . when = date()
     . echo ToCSV(who, what, when)

    '''Result:'''

    . "Bob","Cap his city","Tue Feb 11 19:59:38 GMT-0500 2014"
    Line 294: Line 351:
    '''Usage:''' '''Usage:''' toLocaleLowerCase()
    Line 299: Line 356:
     .

    '''Result:'''
     .

     .string = "tHIs Is a mEssAge."
     .echo string.toLocaleLowerCase()

    '''Result:'''

     .this is a message.
    Line 305: Line 365:
    '''Usage:''' '''Usage:''' toLocaleUpperCase()
    Line 310: Line 370:
     .

    '''Result:'''
     .

     .string = "tHIs Is a mEssAge."
     .echo string.toLocaleUpperCase()

    '''Result:'''

     .THIS IS A MESSAGE.
    Line 316: Line 379:
    '''Usage:''' '''Usage:''' toLowerCase()
    Line 321: Line 384:
     .

    '''Result:'''
     .

     .string = "tHIs Is a mEssAge."
     .echo string.toLowerCase()

    '''Result:'''

     .this is a message.
    Line 327: Line 393:
    '''Usage:'''  '''Usage:'''
    Line 332: Line 398:
     .

    '''Result:'''
     .

     .string = "tHIs Is a mEssAge."
     .echo string.toupperCase()

    '''Result:'''

     .THIS IS A MESSAGE.
    Line 343: Line 412:
     .echo Upper1("testing")

    '''Result:'''
     .19:53:50 (5) - Testing

    . echo Upper1("testing")

    '''Result:'''

    . Testing
    Line 349: Line 420:
    '''Usage:''' '''Usage:''' valueOf()
    Line 354: Line 425:
     .

    '''Result:'''
     .
    ----

     .string = "this is a message."
     .echo string.valueOf()

    '''Result:'''

     .this is a message.

    = FormatMiles =
    '''Usage:''' !FormatMiles(number)

    Converts number to a string like "2.34 miles".

    '''Example:'''

     . echo !FormatMiles(123)
     . echo !FormatMiles(123.4)

    '''Result:'''

     . 123.00 miles
     . 123.40 miles

    = FormatNumber =
    '''Usage:''' !FormatNumber(number, optional precision = 0, optional useThousandsSeparator = true)

    Formats number with specified precision. Default has no decimal places, e.g. "2,346"

    '''Example:'''

     . echo !FormatNumber("1234567")
     . echo !FormatNumber("1234567","2")

    '''Result:'''

     . 1,234,567
     . 1,234,567.00

    = FormatNumber2 =
    '''Usage:''' !FormatNumber2(number, optional precision = 0, optional useThousandsSeparator = true)

    Formats number with 2 decimal places, e.g. "2,345.56".

    '''Example:'''

     . echo !FormatNumber2("1234567")

    '''Result:'''

     . 1,234,567.00

    = FormatPercent =
    '''Usage:''' !FormatPercent(number, optional presision = 1)

    Formats number as percentage.

    '''Example:'''

     . echo !FormatPercent("1")
     . echo !FormatPercent("0.25","0")
     . echo !FormatPercent("0.25","2")

    '''Result:'''

     . 100.0%
     . 25%
     . 25.00%

    The following functions can be used to manipulate and retrieve string details from objects and variables.

    These should be written in the following formats:

    • variable.function(arguments), example - myVar.subStr(3,2) if your variable name was "myVar" and you wanted to use subStr() to find the 2 characters that begin 3 from the left.

    • object.function(arguments), example - city.coords.split(",") if you wanted to split the coordinates of your city into an array to determine the seperate x and y values using the split() function.

    Click each function name in the table below for more details of it, with examples.

    Functions

    Function

    Type

    Description

    CenterPad

    String

    Prepends and appends spaces (or specified character) to a string to form string of the desired length.

    charAt

    String

    Returns the character in the position specified by the index parameter.

    charCodeAt

    Number

    Returns the numeric Unicode character code of the character at the specified index.

    concat

    String

    Appends the supplied arguments to the end of the String object, converting them to strings if necessary, and returns the resulting string.

    fromCharCode

    String

    Returns a string comprising the characters represented by the Unicode character codes in the parameters.

    indexOf

    int

    Searches the string and returns the position of the first occurrence of val found at or after startIndex within the calling string.

    lastIndexOf

    int

    Searches the string from right to left and returns the index of the last occurrence of val found before startIndex.

    LeftPad

    String

    Prepends spaces (or specified character) to a string to form string of the desired length.

    localeCompare

    int

    Compares the sort order of two or more strings and returns the result of the comparison as an integer.

    match

    Array

    Matches the specifed pattern against the string.

    Merge

    String

    Concatenate str1 and str2 together, delim is inserted between strings if both strings are not empty

    replace

    String

    Matches the specifed pattern against the string and returns a new string in which the first match of pattern is replaced with the content specified by repl.

    RightPad

    String

    Appends spaces (or specified character) to a string to form string of the desired length.

    search

    int

    Searches for the specifed pattern and returns the index of the first matching substring.

    slice

    String

    Returns a string that includes the startIndex character and all characters up to, but not including, the endIndex character.

    split

    Array

    Splits a String object into an array of substrings by dividing it wherever the specified delimiter parameter occurs.

    StringRepeat

    String

    Makes a string consisting of spaces (or of specified string) repeated count times.

    StringToObject

    String

    Parses and converts strings with parameters into object.

    substr

    String

    Returns a substring consisting of the characters that start at the specified startIndex and with a length specified by len.

    substring

    String

    Returns a string consisting of the character specified by startIndex and all characters up to endIndex - 1.

    ToCSV

    String

    Converts arguments to comma-separated string with values enclosed in qouble quotes.

    toLocaleLowerCase

    String

    Returns a copy of this string, with all uppercase characters converted to lowercase.

    toLocaleUpperCase

    String

    Returns a copy of this string, with all lowercase characters converted to uppercase.

    toLowerCase

    String

    Returns a copy of this string, with all uppercase characters converted to lowercase.

    toUpperCase

    String

    Returns a copy of this string, with all lowercase characters converted to uppercase.

    Upper1

    String

    Upper cases the first letter of a string.

    valueOf

    String

    Returns the primitive value of a String instance.

    FormatMiles

    int

    Converts number to a string, e.g. "2.34 miles".

    FormatNumber

    int

    Formats number with specified precision, e.g. "2,346".

    FormatNumber2

    int

    Formats numbers with 2 decimal places, e.g. "2,345.56".

    FormatPercent

    int

    Formats number as percentage, e.g. "9.1%".

    CenterPad

    Usage: CenterPad(str, targetLength, optional padChar = " ")

    Prepends and appends spaces (or specified character) to a string to form string of the desired length.

    Example:

    • echo CenterPad("This is a test", 25, ".")

    Result:

    • .....This is a test......

    charAt

    Usage: charAt(#)

    Returns the character in the position specified by the index parameter.

    Example:

    • // Don't forget almost all internal "counting" starts at 0, not at 1...
    • // so the 5th character would actually be 0, 1, 2, 3, 4 <--- 4!

    • var="hello"
    • echo "The 5th letter in the word hello is: " + var.charAt(4)

    Result:

    • The 5th letter in the word hello is: o

    charCodeAt

    Usage: charCodeAt(#)

    Returns the numeric Unicode character code of the character at the specified index.

    Example:

    • var="hello"
    • echo "The numeric code of the 5th letter in the word hello is: " + var.charCodeAt(4)

    Result:

    • The numeric code of the 5th letter in the word hello is: 111

    concat

    Usage: concat(arg1,arg2,...,argN)

    Appends the supplied arguments to the end of the String object, converting them to strings if necessary, and returns the resulting string.

    Example:

    • var="oompa"
    • var2="loompa"
    • var3="dance"
    • echo var.concat(var2," ",var3)

    Result:

    • oompaloompa dance

    fromCharCode

    Usage: fromCharCode()

    Returns a string comprising the characters represented by the Unicode character codes in the parameters.

    Example:

    • echo String.fromCharCode(70)

    Result:

    • F

    indexOf

    Usage: IndexOf()

    Searches the string and returns the position of the first occurrence of val found at or after startIndex within the calling string.

    Example:

    • string = "this is a test string."
    • echo string.indexOf("test")

    Result:

    • 10

    lastIndexOf

    Usage: lastIndexOf()

    Searches the string from right to left and returns the index of the last occurrence of val found before startIndex.

    Example:

    • string = "this is another test string."
    • echo string.lastIndexOf("test")

    Result:

    • 16

    LeftPad

    Usage: LeftPad(str, targetLength, optional padChar = " ")

    Prepends spaces (or specified character) to a string to form string of the desired length.

    Example:

    • echo LeftPad("This is a test", 25, ".")

    Result:

    • ...........This is a test

    localeCompare

    Usage: localeCompare()

    Compares the sort order of two or more strings and returns the result of the comparison as an integer.

    Example:

    • string = "abc"
    • echo "def".localeCompare(string)

    Result:

    • 3

    match

    Usage: match()

    Matches the specified pattern against the string. Usage of "/g" allows global search (returns multiple results if there's multiple instances).

    Example:

    • string = "This is just a simple test string."
    • echo string.match(/is/g)

    Result:

    • is,is

    Merge

    Usage: Merge(str1, str2, optional delim = " ")

    Concatenate str1 and str2 together, delim is inserted between strings if both strings are not empty.

    Example:

    • echo Merge("This is a test", "of the Emergency Broadcast System")
    • echo Merge("One plus One", "Two", " = ")

    Result:

    • This is a test of the Emergency Broadcast System
    • One plus One = Two

    RightPad

    Usage: RightPad(str, targetLength, optional padChar = " ")

    Appends spaces (or specified character) to a string to form string of the desired length.

    Example:

    • echo RightPad("This is a test", 25, ".")

    Result:

    • This is a test...........

    replace

    Usage: replace( , )

    Matches the specified pattern against the string and returns a new string in which the first match of pattern is replaced with the content specified.

    Example:

    • string = "yet another test string"
    • echo string.replace("test", "dull test")

    Result:

    • yet another dull test string

    search

    Usage: search()

    Searches for the specified pattern and returns the index of the first matching sub-string.

    Example:

    • string = "yet another test string"
    • echo string.search("another")

    Result:

    • 4

    slice

    Usage: slice( , )

    Returns a string that includes the startIndex character and all characters up to, but not including, the endIndex character.

    Example:

    • string = "Hello World!"
    • echo string.slice(1,5)

    Result:

    • ello

    split

    Usage: split("delimiter")

    Splits a String object into an array of substrings by dividing it wherever the specified delimiter parameter occurs.

    Example:

    • mycoords=city.coords.split(",")
    • echo "x:" + mycoords[0] + " y:" + mycoords[1]

    Result:

    • x:746 y:34

    StringRepeat

    Usage: StringRepeat(count, optional str = " ")

    Makes a string consisting of spaces (or of specified string) repeated count times.

    Example:

    • echo StringRepeat(25, ".")

    • echo StringRepeat(25, "Test")

    • echo StringRepeat(25, "Test ")

    Result:

    • .........................
    • TestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTest

    • Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test

    StringToObject

    Usage: StringToObject(str, delim1, delim2, optional result = null)

    Parses and converts strings with parameters into object.

    Example:

    • str = "test1:no1,test2:no2"
    • o = StringToObject(str,",",":")

    • echo o.test2

    Result:

    • no2

    substr

    Usage: substr(first, last)

    Returns a substring consisting of the characters that start at the specified startIndex and with a length specified by len.

    Example:

    • string = "Hello World!"
    • echo string.substr(1,4)

    Result:

    • ello

    substring

    Usage: substring(first, last)

    Returns a string consisting of the character specified by startIndex and all characters up to endIndex - 1.

    Example:

    • string = "Hello World!"
    • echo string.substring(1,4)

    Result:

    • ell

    ToCSV

    Usage: ToCSV(...args)

    Converts arguments to comma-separated string with values enclosedi in qouble quotes.

    Example:

    • who = "Bob"
    • what = "Cap his city"
    • when = date()
    • echo ToCSV(who, what, when)

    Result:

    • "Bob","Cap his city","Tue Feb 11 19:59:38 GMT-0500 2014"

    toLocaleLowerCase

    Usage: toLocaleLowerCase()

    Returns a copy of this string, with all uppercase characters converted to lowercase.

    Example:

    • string = "tHIs Is a mEssAge."
    • echo string.toLocaleLowerCase()

    Result:

    • this is a message.

    toLocaleUpperCase

    Usage: toLocaleUpperCase()

    Returns a copy of this string, with all lowercase characters converted to uppercase.

    Example:

    • string = "tHIs Is a mEssAge."
    • echo string.toLocaleUpperCase()

    Result:

    • THIS IS A MESSAGE.

    toLowerCase

    Usage: toLowerCase()

    Returns a copy of this string, with all uppercase characters converted to lowercase.

    Example:

    • string = "tHIs Is a mEssAge."
    • echo string.toLowerCase()

    Result:

    • this is a message.

    toUpperCase

    Usage:

    Returns a copy of this string, with all lowercase characters converted to uppercase.

    Example:

    • string = "tHIs Is a mEssAge."
    • echo string.toupperCase()

    Result:

    • THIS IS A MESSAGE.

    Upper1

    Usage: Upper1(str)

    Upper cases the first letter of a string.

    Example:

    • echo Upper1("testing")

    Result:

    • Testing

    valueOf

    Usage: valueOf()

    Returns the primitive value of a String instance.

    Example:

    • string = "this is a message."
    • echo string.valueOf()

    Result:

    • this is a message.

    FormatMiles

    Usage: FormatMiles(number)

    Converts number to a string like "2.34 miles".

    Example:

    • echo FormatMiles(123)

    • echo FormatMiles(123.4)

    Result:

    • 123.00 miles
    • 123.40 miles

    FormatNumber

    Usage: FormatNumber(number, optional precision = 0, optional useThousandsSeparator = true)

    Formats number with specified precision. Default has no decimal places, e.g. "2,346"

    Example:

    • echo FormatNumber("1234567")

    • echo FormatNumber("1234567","2")

    Result:

    • 1,234,567
    • 1,234,567.00

    FormatNumber2

    Usage: FormatNumber2(number, optional precision = 0, optional useThousandsSeparator = true)

    Formats number with 2 decimal places, e.g. "2,345.56".

    Example:

    • echo FormatNumber2("1234567")

    Result:

    • 1,234,567.00

    FormatPercent

    Usage: FormatPercent(number, optional presision = 1)

    Formats number as percentage.

    Example:

    • echo FormatPercent("1")

    • echo FormatPercent("0.25","0")

    • echo FormatPercent("0.25","2")

    Result:

    • 100.0%
    • 25%
    • 25.00%


    CategoryFunctions

    Strings (last edited 2015-02-08 06:30:49 by LKD70)