:orphan: .. **************************************************************************** .. CUI .. .. The Advanced Framework for Simulation, Integration, and Modeling (AFSIM) .. .. The use, dissemination or disclosure of data in this file is subject to .. limitation or restriction. See accompanying README and LICENSE for details. .. **************************************************************************** string ------ .. class:: string :class:`string` is a basic type in the scripting language that encapsulates a sequence of characters. Conversions =========== Strings may be converted back and forth between numeric types and strings by using 'casting' operators:: string sValue; int iValue = 42; iValue = iValue + 4; sValue = (string) iValue; // sValue now contains the string "46" iValue = (int) sValue; // iValue now contains the integer 46 double dValue = 12.345; dValue = dValue - 2.0; sValue = (string) dValue; // sValue now contains the string "10.345" dValue = (double) sValue; // dValue now contains the double 10.345 Methods ======= .. method:: int Length() The current number of characters in the string. .. method:: bool Contains(string aSubString) Returns true if the string contains the provided sub-string. .. method:: bool StartsWith(string aSubString) Returns true if the string starts with the provided sub-string. .. method:: bool EndsWith(string aSubString) Returns true if the string ends with the provided sub-string. .. method:: string Substring(int aStart) string Substring(int aStart, int aEnd) Returns a substring of the string. aStart and aEnd define the index range of the substring returned. If aEnd is not specified, it is the length of the string. Indices should be in the range [-length + 1, length - 1]. A negative index is the index from the end of the string.:: "abcd".Substring(1,-1); # Returns "bc" "abcd".Substring(3); # Returns "d" "abcd".Substring(-1); # Returns "d" .. method:: Array Split() Array Split(string aDelimiter) Returns an array of strings containing substrings which are divided by a delimiter.:: "a,b,c".Split(","); # Returns {"a", "b", "c"} If no delimiter is provided, contiguous whitespace is used:: "a b c".Split(); # Returns {"a", "b", "c"} .. method:: string Join(Array aWords) Concatenates an array of strings into one single string, using this string as the delimiter.:: Array words = {"a", "b", "c"}; "<".Join(words); # Returns "a