01-17-2012 06:53 AM
Hello all,
in C# (.NET) there is a good class: String
There it is possible e.g. to get information, if the string startswith a special substring.
Is there such possibility in LabView? Is there such LabView vi, which offers this functionality? (Some snippet?)
Why I am asking:
I want to create a switch/case-block (case-structure) in labview for this code:
if(string.startswith("XYZ")) step into case1
else if(string.startswith("DEF")) step into case2
...
BTW:
It would be so nice if anybody could create polymorphic VI with these functions:
(from C# string class)
public object Clone();
public static int Compare(string strA, string strB);
public static int Compare(string strA, string strB, bool ignoreCase);
public static int Compare(string strA, string strB, StringComparison comparisonType);
public static int Compare(string strA, string strB, bool ignoreCase, CultureInfo culture);
public static int Compare(string strA, string strB, CultureInfo culture, CompareOptions options);
public static int Compare(string strA, int indexA, string strB, int indexB, int length);
public static int Compare(string strA, int indexA, string strB, int indexB, int length, bool ignoreCase);
public static int Compare(string strA, int indexA, string strB, int indexB, int length, StringComparison comparisonType);
public static int Compare(string strA, int indexA, string strB, int indexB, int length, bool ignoreCase, CultureInfo culture);
public static int Compare(string strA, int indexA, string strB, int indexB, int length, CultureInfo culture, CompareOptions options);
public static int CompareOrdinal(string strA, string strB);
public static int CompareOrdinal(string strA, int indexA, string strB, int indexB, int length);
public int CompareTo(object value);
public int CompareTo(string strB);
public static string Concat(IEnumerable<string> values);
public static string Concat<T>(IEnumerable<T> values);
public static string Concat(object arg0);
public static string Concat(params object[] args);
public static string Concat(params string[] values);
public static string Concat(object arg0, object arg1);
public static string Concat(string str0, string str1);
public static string Concat(object arg0, object arg1, object arg2);
public static string Concat(string str0, string str1, string str2);
public static string Concat(object arg0, object arg1, object arg2, object arg3);
public static string Concat(string str0, string str1, string str2, string str3);
public bool Contains(string value);
public static string Copy(string str);
public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count);
public bool EndsWith(string value);
public bool EndsWith(string value, StringComparison comparisonType);
public bool EndsWith(string value, bool ignoreCase, CultureInfo culture);
public override bool Equals(object obj);
public bool Equals(string value);
public static bool Equals(string a, string b);
public bool Equals(string value, StringComparison comparisonType);
public static bool Equals(string a, string b, StringComparison comparisonType);
public static string Format(string format, object arg0);
public static string Format(string format, params object[] args);
public static string Format(IFormatProvider provider, string format, params object[] args);
public static string Format(string format, object arg0, object arg1);
public static string Format(string format, object arg0, object arg1, object arg2);
public CharEnumerator GetEnumerator();
public override int GetHashCode();
public TypeCode GetTypeCode();
public int IndexOf(char value);
public int IndexOf(string value);
public int IndexOf(char value, int startIndex);
public int IndexOf(string value, int startIndex);
public int IndexOf(string value, StringComparison comparisonType);
public int IndexOf(char value, int startIndex, int count);
public int IndexOf(string value, int startIndex, int count);
public int IndexOf(string value, int startIndex, StringComparison comparisonType);
public int IndexOf(string value, int startIndex, int count, StringComparison comparisonType);
public int IndexOfAny(char[] anyOf);
public int IndexOfAny(char[] anyOf, int startIndex);
public int IndexOfAny(char[] anyOf, int startIndex, int count);
public string Insert(int startIndex, string value);
public static string Intern(string str);
public static string IsInterned(string str);
public bool IsNormalized();
public bool IsNormalized(NormalizationForm normalizationForm);
public static bool IsNullOrEmpty(string value);
public static bool IsNullOrWhiteSpace(string value);
public static string Join(string separator, IEnumerable<string> values);
public static string Join<T>(string separator, IEnumerable<T> values);
public static string Join(string separator, params object[] values);
public static string Join(string separator, params string[] value);
public static string Join(string separator, string[] value, int startIndex, int count);
public int LastIndexOf(char value);
public int LastIndexOf(string value);
public int LastIndexOf(char value, int startIndex);
public int LastIndexOf(string value, int startIndex);
public int LastIndexOf(string value, StringComparison comparisonType);
public int LastIndexOf(char value, int startIndex, int count);
public int LastIndexOf(string value, int startIndex, int count);
public int LastIndexOf(string value, int startIndex, StringComparison comparisonType);
public int LastIndexOf(string value, int startIndex, int count, StringComparison comparisonType);
public int LastIndexOfAny(char[] anyOf);
public int LastIndexOfAny(char[] anyOf, int startIndex);
public int LastIndexOfAny(char[] anyOf, int startIndex, int count);
public string Normalize();
public string Normalize(NormalizationForm normalizationForm);
public string PadLeft(int totalWidth);
public string PadLeft(int totalWidth, char paddingChar);
public string PadRight(int totalWidth);
public string PadRight(int totalWidth, char paddingChar);
public string Remove(int startIndex);
public string Remove(int startIndex, int count);
public string Replace(char oldChar, char newChar);
public string Replace(string oldValue, string newValue);
public string[] Split(params char[] separator);
public string[] Split(char[] separator, int count);
public string[] Split(char[] separator, StringSplitOptions options);
public string[] Split(string[] separator, StringSplitOptions options);
public string[] Split(char[] separator, int count, StringSplitOptions options);
public string[] Split(string[] separator, int count, StringSplitOptions options);
public bool StartsWith(string value);
public bool StartsWith(string value, StringComparison comparisonType);
public bool StartsWith(string value, bool ignoreCase, CultureInfo culture);
public string Substring(int startIndex);
public string Substring(int startIndex, int length);
public char[] ToCharArray();
public char[] ToCharArray(int startIndex, int length);
public string ToLower();
public string ToLower(CultureInfo culture);
public string ToLowerInvariant();
public override string ToString();
public string ToString(IFormatProvider provider);
public string ToUpper();
public string ToUpper(CultureInfo culture);
public string ToUpperInvariant();
public string Trim();
public string Trim(params char[] trimChars);
public string TrimEnd(params char[] trimChars);
public string TrimStart(params char[] trimChars);
Solved! Go to Solution.
01-17-2012 07:17 AM
I recommend you study the string primitives. This is elementary stuff really.
01-17-2012 07:53 AM
Why I am asking:
I want to create a switch/case-block (case-structure) in labview for this code:
This can be done already with the case structure, you can do simple parsing in the case selector, which takes a string as an input.
Type into the case for first case "XYZ....XYZ~"
Type into next case "DEF...DEF~"
Next case is empty string, default.
How does this work:
The "XYZ...XYZ~" matches all strings that start with XYZ and have any ascii value after the ~ is the highest printable 7bit ascii value so this catches all other characters.
Option 2 is parse (there are very good reg expression vi in the string palette) the string and create interger value if a matched then habdle the unique integers in the case structure.
There are so many ways to do it without making a wrapper for the .net string class, I provided a few quick methods
01-17-2012 08:19 AM
THANK YOU VERY MUCH !
It works with case structure "XYZ~", but it must be like that: "XYZ".."XYZ~" (otherwise it will not work) !
BR
EWiebe
01-17-2012 09:56 AM
"XYZ~" only does an exact match,
"XYZ"..."XYZ~" matches the string range between XYZ and XYZ followed by any ascii character.
This is the very simple parser I mentioned it is similar to an optional wildcard after the matched XYZ