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
|
|||
|
|||
treenode compilation error
Hi,
The below code is not getting compiled ------- for loop{ createinstance(node("/NetworkNode",library()),model()); treenode networknode3= last(model()); } contextdragconnection(networknode3,node("/Transporter3",model()),"A"); ------- However this code gets compiled ------- treenode networknode3; for loop{ createinstance(node("/NetworkNode",library()),model()); networknode3= last(model()); } contextdragconnection(networknode3,node("/Transporter3",model()),"A"); ------- Just defining treenode outside for loop, script runs fine. Not sure why, Kindly advise. Regards Shashank Trivedi |
#2
|
|||
|
|||
If you use networknode3 outside of the for loop, then you need to declare it outside of the for loop. If not, then the scope of the variable is limited to the for loop and it will only be able to be used within the for loop and it will need to be initialized every time you go through the loop. That's also how variables behave in C++.
|
The Following User Says Thank You to Alex Christensen For This Useful Post: | ||
shashanktrivedi (06-15-2011) |