question

Jeremy R avatar image
0 Likes"
Jeremy R asked Jordan Johnson commented

Checking success of export to CSV

Is there a way to test if an export to CSV was successful?

We have discovered that if the user has the CSV file open when they try and overwrite it from FlexSim using the exporttable command, FlexSim continues without any kind of warning. Is there a way to validate that the export was successful? I tried returning the value of exporttable, but it is always 0 regardless of whether it succeeds or not.

Ideally, we would want to be able to check if the export failed, and display a warning message to the user if this was the case.

Choose One
FlexSim 18.2.0
exportcsv
· 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.

tannerp avatar image tannerp commented ·

Could you try using the FlexScript Code Profile? Just an idea..

0 Likes 0 ·
Jeremy R avatar image Jeremy R tannerp commented ·

I'm not sure how this helps. How do you use the code profile to detect if the export was successful?

0 Likes 0 ·

1 Answer

Jordan Johnson avatar image
3 Likes"
Jordan Johnson answered

You can check if FlexSim has permission to write to it by using the file API in FlexSim:

int success = fileopen(fileName, "a"); // open in append mode
if (success) {
    fileclose();
} else {
    print("Could not open file ", fileName);
}
exporttable(...);

It should catch whether exporttable will be able to actually write to the file.

5 |100000

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