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
|
|||
|
|||
GlobalTables
Hello!! I want to know if there is a command to create a global table. I want to create some global tables by code, but I dindn't found any command.
Is there any command for this purpose? Thank you a lot!!! |
#2
|
|||
|
|||
Hi,
What I know, there is no command to create a GlobalTable. You can do your own User Command that creates a GlobalTable. Take a look at the nodefunction addglobaltable, you will find the function under View->nodefunctions->menucommands in the tree. Example code: Code:
string tableName=parstr(1); if (not(objectexists(node("/Tools",model())))) { nodeinsertinto(model()); setname(last(model()),"Tools"); } if (not(objectexists(node("/Tools/GlobalTables",model())))) { nodeinsertinto(node("/Tools",model())); setname(last(node("/Tools",model())),"GlobalTables"); } createinstance( node("/GlobalTable",library()), node("/Tools/GlobalTables",model()) ); treenode table=last( node("/Tools/GlobalTables",model())); setname(table,tableName); settable(var_s(last(node("/Tools/GlobalTables",model())),"data"),1,1,1,0); updatetoolsmenu(); Last edited by Lars-Olof Leven; 03-12-2010 at 07:08 AM. Reason: Added example code |
The Following 4 Users Say Thank You to Lars-Olof Leven For This Useful Post: | ||
Thomas Kirk (11-17-2010) |
#3
|
|||
|
|||
Thanks you a lot !!
Quote:
|
#4
|
||||
|
||||
Could you please explain this with an example
Hi
I would like to create a few gloabl tables by code, and i did have a look at your code mentioned above, but i still havent understood how i could use it. I would like to create global table EXAMPLE: addglobaltable("mytable",2,4,1) where no : of rows = 2 no: of colmns = 4 data type = integer (1) How could i do this with your code.... please help !!!! |
#5
|
|||
|
|||
I copied the code into a user command and added rows, cols, and datatype as parameters.
If you want to create many tables at once, for efficiency maybe don't call updatetoolsmenu() until all have been created. And the first 2 ifs only need to be checked once. Code:
string tablename = parstr(1); int rows = parval(2); int cols = parval(3); int datatype = parval(4); if (not(objectexists(node("/Tools",model())))) { nodeinsertinto(model()); setname(last(model()),"Tools"); } if (not(objectexists(node("/Tools/GlobalTables",model())))) { nodeinsertinto(node("/Tools",model())); setname(last(node("/Tools",model())),"GlobalTables"); } createinstance( node("/GlobalTable",library()), node("/Tools/GlobalTables",model()) ); treenode table = last(node("/Tools/GlobalTables",model())); treenode tabledatanode = var_s(table,"data"); settablesize(tabledatanode,rows,cols,datatype,0); //setname(first(tabledatanode),"Row 1"); //setname(first(first(tabledatanode)),"Col 1"); updatetoolsmenu(); |
The Following 3 Users Say Thank You to Kris Geisberger For This Useful Post: | ||
Sung Kim (08-24-2011) |
#6
|
||||
|
||||
addglobal table warning !!
This is the code what i used -
addglobaltable("PeopleCount",2,3,1); And this is the warning message i am getting Warning VIEW:/active/scriptinputconsole120609472/script>curtext line 2 Too many parameters in call to addglobaltable Warning line 2 Too many parameters in call to addglobaltable Could some one please help me on this, it a bit urgent. Thanks |
#7
|
|||
|
|||
The error indicates that you have an error on line 2 of your script window. When I open a new script window and write only:
addglobaltable("PeopleCount",2,3,1); ...then it works fine. I attached an update that sets the name of the GlobalTable as specified in the first parameter. I don't know why it was not done in the first version. |
The Following User Says Thank You to Kris Geisberger For This Useful Post: | ||
David Chan (09-22-2011) |
#8
|
||||
|
||||
Flexscript is strongly typed now. What you specify as the parameter list for User Commands makes a difference.
Make sure you have the parameters for that user command that Kris has: (str tablename, num rows, num cols, num datatype) |
#9
|
|||
|
|||
Kris, may be you can repose this as Tips in the other section? I really benefit for those who are search for such tips.
Thanks David
__________________
Advent2 Labs David |