T1 = "Hello"
It comes from a script file which I load into my gui app. It loads fine and I am currently using the split() function to get the word out. I have a problem using that because the way I have it setup, it only gets one word. So if it was
T1 = " Hello World"
then only Hello would be grabbed. Also I don't know why but there has to be a space in between the first quotation and Hello or else it will not work correctly. I thought of a different algorithm of acheiving the same solution.
Expand|Select|Wrap|Line Numbers
- int num, num1, num2;
- String * temp;
- for (int x = 0; x <= line->Length; x++)
- {
- line = line->Trim();
- }
- num1 = line->IndexOf("\"");
- num2 = line->LastIndexOf("\"");
- num = num2-num1;
- temp = line->Substring(num1, num);
- richTextBox2->Text = temp;
Here is the complete current code that does work, but only for one word inside quotations.
Expand|Select|Wrap|Line Numbers
- scriptString = richTextBox1->Text;
- scriptReader = new StringReader(scriptString);
- String* delimStr = S"=() :[] {} \t \" ";
- Char delimiter[] = delimStr->ToCharArray();
- String* split[] = 0;
- int nextChar = 0;
- String* line = "";
- String* str;
- //String* str2;// = str1->Trim(delim->ToCharArray());
- //str2 = str2->ToString(str1->Trim(delim->ToCharArray()));
- //iterate over the string using the StringReader, printing each line.
- while(nextChar >= 0)
- {
- //reading line by line
- line = scriptReader->ReadLine();
- //making sure it read correctly
- line = line->TrimStart(NULL);
- for (int x = 0; x <= line->Length; x++)
- {
- //line = line->Trim(NULL);
- split = line->Split(delimiter, x);
- richTextBox1->AppendText(S"\ncount = {0, 2} ..............");
- richTextBox1->AppendText(__box(x)->ToString());
- IEnumerator* myEnum = split->GetEnumerator();
- while (myEnum->MoveNext())
- { //line = line->TrimStart(NULL);
- String* s = __try_cast<String*>(myEnum->Current);
- richTextBox1->AppendText(S" ");
- richTextBox1->AppendText("Last s: ");
- richTextBox1->AppendText(s);
- //if (myEnum->MoveNext()) //save the last s (which is the name)
- if(myEnum->MoveNext() && s != NULL)
- {
- str = s;
- }
- }
- }
- if(line->StartsWith("T1"))
- {
- top1->Text = str;
- defaultText(sender, e, top1);
- }
- //check if there's any more lines
- nextChar = scriptReader->Peek();
Thanks in advance, in the meantime I am going to be trying to figure out this myself as well.