ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
||||
|
||||
Help with stringtoken
Is there a way to specifically tell stringtoken() to return a specific entry from a line?
Example: string Text = "Goodbye Forever Cruel World" If i use stringtoken(Text," ") it will return "Goodbye". How do I set it to return "Cruel" for example? Thanks, Clueless in MN |
#2
|
||||
|
||||
Have you read the commandlist helpfile?
anyway, paste the following code in the scriptwindow, open a output console and watch string Text = "Goodbye Forever Cruel World"; pt( stringtoken(Text," ") );pr(); pt(stringtoken(NULL," ") );pr(); pt(stringtoken(NULL," ") );pr(); pt(stringtoken(NULL," ") );pr(); |
The Following 3 Users Say Thank You to Steven Hamoen For This Useful Post: | ||
RalfGruber (02-18-2012) |
#3
|
||||
|
||||
Still Unclear on Stringtoken
I get how to do each in sucession, what I can't figure out is how to ONLY print the third for exampel.
How would I specify the word "Cruel" out of that string without first spec'in Goodbye and Forever? I suspect it is something quite obvious, but it eludes me. |
#4
|
||||
|
||||
Code:
string Text = "Goodbye Forever Cruel World"; string substr = stringtoken(Text," "); int index = 3; for(int r=1; r<index; r++) substr = stringtoken(NULL," "); pt(substr);pr(); |
The Following User Says Thank You to Phil BoBo For This Useful Post: | ||
JMEngelhart (02-24-2012) |