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 12-21-2010
juan alberto juan alberto is offline
Flexsim User
 
Join Date: May 2009
Location: Valencia, Spain
Posts: 74
Downloads: 14
Uploads: 0
Thanks: 19
Thanked 3 Times in 2 Posts
Rep Power: 138
juan alberto is on a distinguished road
Exclamation return treenodearray

Hi people,

I have a user command that returns a treenodearray. I have tested it and it works correctly. But when I assign a treenodearray variable to this function, for instance:

treenodearray x = usercommand();
//usercommand returns a treenodearray

It never works, and I don't know why. Can a user command return an treenodearray? Can a user command return an object? Or it only can return simple types like int, double, string....

Thank you!
  #2  
Old 12-21-2010
Anthony Johnson's Avatar
Anthony Johnson Anthony Johnson is offline
Manager of Product Development
 
Join Date: Jul 2007
Posts: 440
Downloads: 86
Uploads: 4
Thanks: 171
Thanked 899 Times in 288 Posts
Rep Power: 735
Anthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond repute
Default

A user command can only return simple types. This is for memory management purposes. The flexscript engine does not have a sophisticated garbage collector, so dynamically allocated memory must remain within the scope of one function. You can instead use flexsim's tree structure to store values that are passed between functions.
  #3  
Old 12-22-2010
juan alberto juan alberto is offline
Flexsim User
 
Join Date: May 2009
Location: Valencia, Spain
Posts: 74
Downloads: 14
Uploads: 0
Thanks: 19
Thanked 3 Times in 2 Posts
Rep Power: 138
juan alberto is on a distinguished road
Default

then, why exist one command to create dinamic arrays if you can't use it whitout knowing their size and neither you can work with this type of variables if you use it in functions ?
  #4  
Old 12-22-2010
Anthony Johnson's Avatar
Anthony Johnson Anthony Johnson is offline
Manager of Product Development
 
Join Date: Jul 2007
Posts: 440
Downloads: 86
Uploads: 4
Thanks: 171
Thanked 899 Times in 288 Posts
Rep Power: 735
Anthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond repute
Default

You can use the arrays all you want within the scope of the function that they are created in. Obviously they are limited, but there are many use cases where they are useful. And since arrays are always used within the scope of the function that created them, you can always just keep track of the size of the array yourself.
The Following 2 Users Say Thank You to Anthony Johnson For This Useful Post:
RalfGruber (12-24-2010)


Thread Thread Starter Forum Replies Last Post
Return 0; shafizad Q&A 0 12-13-2010 03:50 AM
5.0 return problem? LINWEIXU Q&A 1 04-22-2010 09:05 AM
is there a command which will return the port no. of a connected object? KelvinHo Q&A 6 04-22-2010 02:13 AM
return 1 in entry trigger? qin tian Q&A 1 05-07-2008 04:05 PM


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.