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
|
|||
|
|||
Coding assistance needed
I'm trying to write a couple lines of code to change the name of an object from one name to another through an exit method.
Currently this is what I have if (part_name !="Blue") { setname(item,"Red"); } The first line of code is read, but nothing happens. Another item I'm needing help with is how to move a part from the separator to the combiner on certain parts that need to go through my system twice. Not sure how to start the code for this issue. If there is a good place for example code for these type of items I would appreciate some reference documents for I know code in other simulation software, but not FlexSim. Thanks - Heather |
#2
|
||||
|
||||
if you want to compare text you have to use the function "comparetext()". So your lines should read:
if( !comparetext( part_name, "Blue") ) { setname(item,"Red"); } For the other question, can't you just use an output port and send that back to the entry of another object? |
The Following User Says Thank You to Steven Hamoen For This Useful Post: | ||
Sebastian Hemmann (10-20-2015) |
#5
|
||||
|
||||
Hi Heather,
Do you know if the item referenced in your code is the item for which you want the name to change? One thing you could do is step through your code as it's executed and watch the local variables to see if they are actually pointing to the objects you think they are. Put a break point in your trigger code by clicking in the margin left of the code text. This will put a red circle (a break point) in your code. The next time that code is executed, execution will stop at the break point and show you a yellow arrow where the execution is currently paused. New tool panes will also have opened up to show you local variables, watch variables, and the call stack. There will also be code stepping buttons at the top of your paused code window to step to the next line, or into a function, etc. Let us know what you find out. |
The Following 2 Users Say Thank You to Ben Wilson For This Useful Post: | ||
Sebastian Hemmann (10-20-2015) |
#7
|
|||
|
|||
In 7.5 we made a change to make string comparisons work with the standard == operator.
if (getname(item) == "MyItem") This is a valid comparison. |
The Following 4 Users Say Thank You to Matt Long For This Useful Post: | ||
Steven Hamoen (10-20-2015) |
Thread | Thread Starter | Forum | Replies | Last Post |
How to write coding for that? | stmyint | Container Terminal (CT) Library | 5 | 10-29-2012 08:03 PM |
Coding problem | Liang Wen Yin | Q&A | 4 | 08-13-2012 04:49 PM |
Questions on coding | Jack Lai | Q&A | 6 | 02-07-2012 12:04 AM |
Need help for coding on lifts. | chrisquek | Q&A | 5 | 11-25-2008 03:00 AM |
A pitfall in Flexsim coding | AlanZhang | Gripes and Goodies | 7 | 05-16-2008 03:37 PM |