question

Arimba W avatar image
0 Likes"
Arimba W asked Arimba W commented

Import Excel Table into Flexscript Data for GlobalTable

Hi there, I would like to ask on how to import data from the excel table into flexscript data in GlobalTable...

i've read the latest guide at:
1. https://answers.flexsim.com/articles/19550/excel-interface-75.html?childToView=58954#comment-58954
2. https://tmnsimulation.com.au/flexsimhelp/Reference/Tools/ExcelInterface/ExcelInterface.html

From (1) I still have no idea on the initial value identifier for flexscript data if i want to use option data distinction: Per Coloumn/ Per Row.

From (2) I'm confused with the meaning of excelreadstr() for string data and excelreadstr() for flexscript data cause it's same since i want to import as flexscript, not string... here's the screenshot:

here's my corresponding file where i want to import the excel data into GlobalTable: Global_Routing, where Coloumn 1: Value and Coloumn 2,3 use the Flexscript,

excel-flexscript.zip

Thank you very much for the help!
Best Regards,

FlexSim 18.2.2
flexscriptglobaltableexcelimport
1.jpg (340.0 KiB)
excel-flexscript.zip (330.6 KiB)
5 |100000

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

Logan Gold avatar image
0 Likes"
Logan Gold answered Arimba W commented
@Arimba W

(1) The initial value identifier for any of the data types will be a number 1 through 4, where 1 is used if you want the data to imported as Number Data, 2 for Text Data, 3 for Flexscript Data, and 4 for C++ Data.

(2) You don't need to worry about how excelreadstr() is used in the Excel importer. If you use a 2 or a 3 in conjunction with the Per Column or Per Row option, the importer will use excelreadstr() when importing the rest of the data in that column or row. The difference is if 3 is used, then the importer will also change the cells in that column or row (in the Global Table) to be FlexScript instead of just text data.

In the files that you attached, all you need to do is add a row to your Excel workbook (in the EDD tab) just before the data that is being imported and put a number 1 through 4 in each column that is being imported. When I tested it, I added a row right after row 1, then put a 1 in the second column (B), and 3's in the third (C) and fourth columns (D):

You will also want to change the Starting Row in the Excel Interface to 3, since adding the new row pushes the data to the third row.

Another option for changing data types after import would be to use the Post Import Code option in the Excel Interface. There is a post where the comments section has some information on how to do this, and also includes some examples. That post can be found here:

https://answers.flexsim.com/idea/48507/assign-flexscript-data-type-on-import.html


excel.png (35.3 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.

Arimba W avatar image Arimba W commented ·

Hai Sir, it's working!.. thank you very much! :D

0 Likes 0 ·
Jeff Nordgren avatar image
0 Likes"
Jeff Nordgren answered Arimba W commented

@Arimba W

Attached is your model with the changes that I've made to it.

Rather than trying to import "flexscript" from the Excel file, I just import it as a string. Then in your PF code, when something like "token.From" or "token.To" is referenced, I just added executestring() with the parameter being "token.From" or "token.To". That converts the string to flexscript "on the fly". Seems a lot easier to me to do it that way. Because after all, it is a string in the Excel file.

So, code that looked like this:

token.From
token.To

I changed to this:

executestring(token.From)
executestring(token.To)

I'm not exactly sure how your model is supposed to work but this "fix" should take care of the referencing of the Global_Routing table.

Will something like this work for your situation? @Logan Gold has a good suggestion for solving your problem as well. Just depends on what suits your needs the best.

Thanks.

globaltable-edit-jn1.fsm


· 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.

Arimba W avatar image Arimba W commented ·

Hello Sir, it's working! Thank you very much! :D

0 Likes 0 ·