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
FAQ Downloads Calendar Search Mark Forums Read

Q&A Using Flexsim and building models

Reply
 
Thread Tools Display Modes
  #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: 136
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!
Reply With Quote
  #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: 732
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.
Reply With Quote
  #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: 136
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 ?
Reply With Quote
  #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: 732
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.
Reply With Quote
The Following 2 Users Say Thank You to Anthony Johnson For This Useful Post:
Phil BoBo (12-22-2010), RalfGruber (12-24-2010)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
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. The time now is 11:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.