Author Topic: [JavaScript] execution as Post processing script in Simulation script  (Read 1217 times)

rsksharath

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Hello,

I have created a simple Javascript to store simulation variables (sim.xx) in a csv file.
Then I referenced this Javascript as post processing script in a simulation script, expecting that this Javascript executes once simulation is stopped.
But this Javascript is never executed in my opinion.

When I tested Javascript in Javascript console to store a string in csv, it worked.
Is there any procedure or part of scripting I am missing here?

My Javascript:

// Get the current EA file path
var eaFilePath = Repository.ConnectionString;

// Extract the directory path from the EA file path
var directoryPath = eaFilePath.substring(0, eaFilePath.lastIndexOf("\\") + 1);

// Create a CSV content
var csvContent = "data1,data2\r\n"; // Replace with your simulation data

// Create a file path for the CSV file
var csvFilePath = directoryPath + "simulation_data.csv";

//var csvFilePath = "C:\Users\HFR1KOR\SW_repo\poc_behavioural_sim\simulation_data.csv"


// Create the CSV content
var csvContent = "data1,data2,data3\r\n"; // Replace with your simulation data


// Save the CSV content to a text file
var fileSystem = new COMObject("Scripting.FileSystemObject");
var file = fileSystem.CreateTextFile(csvFilePath, true);
file.Write(csvContent);
file.Close();