question

xuan-123 avatar image
0 Likes"
xuan-123 asked Julie Weller commented

How to use Flexscript (Python) to create the data into global table

I referred this site, building the following model, getting the error https://answers.flexsim.com/questions/123230/how-to-use-flexscript-python-to-create-the-data-in.html

1690515935747.png

how do i fix the error

example project.fsm

TestScript.py

FlexSim 23.0.8
python connector
1690515935747.png (22.7 KiB)
testscript.py (160 B)
example-project.fsm (25.8 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Julie Weller avatar image Julie Weller commented ·

Hi @xuan-123, was Arun Kr's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Arun Kr avatar image
0 Likes"
Arun Kr answered Arun Kr commented

User command is created as "generateDate" and in the script it is called as "generateData". Make it same it will work.

Array data = generateDate(Table("MyTable").numRows, Table("MyTable").numCols);
for (int i = 1; i < Table("MyTable").numRows+1; i++) {
Array row = data[i];
for (int j = 1; j < Table("MyTable").numCols+1; j++) {
int value = row[j];
Table("MyTable")[i][j] = value;
  }
}
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

xuan-123 avatar image xuan-123 commented ·

Thanks for your reply, but I still can't solve the problem.
Can you help me one more time?
example project.fsm

0 Likes 0 ·
example-project.fsm (25.9 KiB)
Arun Kr avatar image Arun Kr xuan-123 commented ·

1690526021043.png

Do a format for python under the user command and then I wrote the testscript fn and it's working for me.

/**external python: */ /**/"testscript"/**/
/** \nfunction name:*/ /**/"TestFunction"/**/

1690526151864.png

Python version is 3.9

example-project_1.fsm

0 Likes 0 ·
1690526021043.png (47.7 KiB)
1690526151864.png (19.6 KiB)

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.