write-infor-to-txt-file.fsmHello
I would like to know how to write a string data to a txt file that do not overlape the previous data and write to a newline everytime.(The result I need as following pic).
My model as attachment. Thank you so much.
write-infor-to-txt-file.fsmHello
I would like to know how to write a string data to a txt file that do not overlape the previous data and write to a newline everytime.(The result I need as following pic).
My model as attachment. Thank you so much.
Adding on to Joshua's answer, you can first write the data into a global table whenever the token enters the custom code activity in the process flow. And then you can print the whole global table into the text. The code will look like this.
Table GlobalTable = Table("GlobalTable1");// Table Reference GlobalTable.addRow(); int NumRows = GlobalTable.numRows; GlobalTable[NumRows][1]= "Time"; GlobalTable[NumRows][2]= Model.time; GlobalTable[NumRows][3]= "Hello World"; fileopen("C:/Users/Arun/Desktop/Data.txt"); for (int i = 1; i <= GlobalTable.numRows; i++){ fpt(GlobalTable[i][1]); fpf(GlobalTable[i][2]); fpt(GlobalTable[i][3]); fpr(); } fileclose();
Also, set the global table to delete all rows on reset.
Pls, see the attached model.support.fsmdata.txt
Regards,
Arun KR
There is a list of commands you can use to perform different file edits. You can find them under Help>Commands, and in the section called "Output". Here is a simple example for what you want:
fileopen("C:/Users/joshua.stevens/Documents/testtext.txt"); for (int i = 1; i <= 3; i++){ fpt("Time:"); fpd(i * 10); fpt(" Hello World"); fpr(); } fileclose();
HI @Joshua S
Thanks for your help. But it is not what I want. My ideal as below.
It will print hello word In time 0, and after a 10 second delay time in processflow, when it run to this custom code in processflow, it will print hello wrod again in time 10 and so on...everytime it print in a newline and do not overlape the word last time it printed. I would like to record the what time it run to this custom code in the model everytime.
11 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved