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
|
|||
|
|||
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
|
||||
|
||||
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
|
|||
|
|||
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
|
||||
|
||||
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 |