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 03-12-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 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  
Old 03-12-2010
Lars-Olof Leven Lars-Olof Leven is offline
Flexsim Distributor
 
Join Date: Aug 2007
Location: Sweden, Borlnge
Posts: 312
Downloads: 278
Uploads: 2
Thanks: 300
Thanked 256 Times in 139 Posts
Rep Power: 330
Lars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to beholdLars-Olof Leven is a splendid one to behold
Default

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();
Lars-Olof

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  
Old 03-15-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

Thanks you a lot !!
Quote:
Originally Posted by Lars-Olof Leven View Post
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();
Lars-Olof
  #4  
Old 08-21-2011
Nischith Kashyap's Avatar
Nischith Kashyap Nischith Kashyap is offline
Flexsim User
 
Join Date: Nov 2010
Location: Wollongong, Australia
Posts: 51
Downloads: 26
Uploads: 0
Thanks: 19
Thanked 0 Times in 0 Posts
Rep Power: 118
Nischith Kashyap is on a distinguished road
Default 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  
Old 08-21-2011
Kris Geisberger Kris Geisberger is offline
Flexsim Canada, Forum Moderator
 
Join Date: Aug 2007
Location: Canada
Posts: 209
Downloads: 54
Uploads: 1
Thanks: 99
Thanked 389 Times in 133 Posts
Rep Power: 451
Kris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud of
Default

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();
Attached Files
File Type: zip addglobaltable command.zip (781 Bytes, 132 views)
File Type: fsm addglobaltable.fsm (29.7 KB, 141 views)
The Following 3 Users Say Thank You to Kris Geisberger For This Useful Post:
Sung Kim (08-24-2011)
  #6  
Old 09-20-2011
Nischith Kashyap's Avatar
Nischith Kashyap Nischith Kashyap is offline
Flexsim User
 
Join Date: Nov 2010
Location: Wollongong, Australia
Posts: 51
Downloads: 26
Uploads: 0
Thanks: 19
Thanked 0 Times in 0 Posts
Rep Power: 118
Nischith Kashyap is on a distinguished road
Default 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  
Old 09-20-2011
Kris Geisberger Kris Geisberger is offline
Flexsim Canada, Forum Moderator
 
Join Date: Aug 2007
Location: Canada
Posts: 209
Downloads: 54
Uploads: 1
Thanks: 99
Thanked 389 Times in 133 Posts
Rep Power: 451
Kris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud ofKris Geisberger has much to be proud of
Default

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.
Attached Files
File Type: zip addglobaltable command 2.zip (764 Bytes, 124 views)
The Following User Says Thank You to Kris Geisberger For This Useful Post:
David Chan (09-22-2011)
  #8  
Old 09-20-2011
Phil BoBo's Avatar
Phil BoBo Phil BoBo is offline
Flexsim Development
 
Join Date: Jan 2008
Posts: 756
Downloads: 109
Uploads: 18
Thanks: 385
Thanked 1,483 Times in 525 Posts
Rep Power: 1174
Phil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond reputePhil BoBo has a reputation beyond repute
Default

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  
Old 09-22-2011
David Chan David Chan is offline
Flexsim Distributor
 
Join Date: Sep 2007
Posts: 326
Downloads: 74
Uploads: 0
Thanks: 217
Thanked 73 Times in 44 Posts
Rep Power: 218
David Chan has a spectacular aura aboutDavid Chan has a spectacular aura aboutDavid Chan has a spectacular aura about
Default

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



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.