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 |
|
Downloads |
User Development User developed add-ons to Flexsim |
I would use it all of the time | 3 | 50.00% | |
I would use it sometimes | 3 | 50.00% | |
I would not use it | 0 | 0% | |
Voters: 6. You may not vote on this poll |
#1
|
||||
|
||||
InputBox in Flexsim script
A missing (as far as I know) but very useful feature in Flexsim script is a simple InputBox. You may wonder why we need a simple InputBox since we can create all kinds of GUIs. Well, if you use createview to display a window, the code after the createview will continue to execute and sometimes you do not want that.
In the attached model, I created user commands to show a simple InputBox and get the user inputs as a string. Flexsim DLL is used to create the commands. Two user commands are provided. Basically they works the same but using slightly different methods to create. The dllinputbox command using parstr to passing strings as parameters. According to a post by Anthony(http://www.flexsim.com/community/for...command+string), you can use parstr to parse strings but you may get memory leaking. Keeping that in mind, the other user command, inputbox, uses treenodes to hold strings so there is definitely no memory leaking problem. So you should use inputbox command to be safe. Both user commands returns a treenode (returned as a double since user command can only return double) which stores the user inputs as a string. Then you have to use gets(tonode(inputbox())) to get the result. The attached DLL InputBox.zip includes the demo model and the dll file. Unzip the files to the same directory. The demo model has a script window open. Simply click the Execute button and type something in the inputbox. The retured user inputs will be printed out in the Output window. If you want user input numbers, you can use stringtonum command to cast the results to numbers. The attached DLL Project.zip includes a Visual Studio 2008 project which has all C++ source code. The InputBox is not perfect yet since when the InputBox is open, the Flexsim main window still response to mouse actions. I do not know how to fix it. Maybe Anthony or some other guy in Flexsim can do something about it.
__________________
Best, Alan |
The Following 9 Users Say Thank You to AlanZhang For This Useful Post: | ||
Yongbin Kim (09-30-2010) |
Thread | Thread Starter | Forum | Replies | Last Post |
Dynamic script generation: Good Example with a User Command | Naresh Yamani | Tips and Tricks | 2 | 05-16-2008 06:54 PM |