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
|
||||
|
||||
Create tables on the fly
I did not find a Flexsim command to create a Global table on the fly. I write a user command to accomplish this. Here is the command:
createGlobalTable(string tableName,num row, num col, num dataType, num reset) PARAMETERS: tableName - table name row - number of rows col - number of columns dataType - data type of the table, see settablesize() reset - 1, clear on rest; 0, no clear on reset EXAMPLE: createGlobalTable("mytable",2,4,1,1) CODE: Code:
string tableName = parstr(1); int row = parval(2); int col = parval(3); int dataType = parval(4); int reset = parval(5); pt("createTable ");pt(tableName);pt("\t");pd(row);pt("\t");pd(col);pt("\t");pd(dataType);pt("\t");pd(reset);pr(); if(content(reftable(tableName))!=0){ pt(tableName);pt(" already exists!");pr(); }else{ createinstance( node("/GlobalTable",library()), node("/Tools/GlobalTables",model()) ); setnodename(last(node("/Tools/GlobalTables",model())),tableName); settablesize(tableName,row,col,dataType,0); setvarnum(last(node("/Tools/GlobalTables",model())),"initonreset",reset); updatetoolsmenu(); // add the table into Tools menu } |