ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 02-15-2012
JMEngelhart's Avatar
JMEngelhart JMEngelhart is offline
Flexsim User
 
Join Date: Sep 2008
Posts: 44
Downloads: 9
Uploads: 0
Thanks: 1
Thanked 7 Times in 6 Posts
Rep Power: 148
JMEngelhart is on a distinguished road
Unhappy 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  
Old 02-15-2012
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

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  
Old 02-20-2012
JMEngelhart's Avatar
JMEngelhart JMEngelhart is offline
Flexsim User
 
Join Date: Sep 2008
Posts: 44
Downloads: 9
Uploads: 0
Thanks: 1
Thanked 7 Times in 6 Posts
Rep Power: 148
JMEngelhart is on a distinguished road
Thumbs down 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  
Old 02-20-2012
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

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)



All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.