Export Data to a txt-File
Export Data to a txt-File
Hello,
I am an ED-beginner. I did the Excel/Active-X Guide and it worked perfectly. My goal is now to write data(for example waiting times in a queue) in a local txt-File, like a log-file. Just add the information to the file.
Are there 4d-script functions or any other atoms that would let me do this?
I am an ED-beginner. I did the Excel/Active-X Guide and it worked perfectly. My goal is now to write data(for example waiting times in a queue) in a local txt-File, like a log-file. Just add the information to the file.
Are there 4d-script functions or any other atoms that would let me do this?
- HarryBunnik
- Posts: 362
- Joined: Monday 07 February, 2011 - 11:22
Re: Export Data to a txt-File
Hello Jufink,
Have you already looked in the example files? For instance:
..\Documents\Enterprise Dynamics 9\Models\Examples\English\Files\Writing Data.mod
might be help you further.
Cheers,
Harry
Have you already looked in the example files? For instance:
..\Documents\Enterprise Dynamics 9\Models\Examples\English\Files\Writing Data.mod
might be help you further.
Cheers,
Harry
Re: Export Data to a txt-File
Harry,
Thank you very much. I looked at your suggested example and it worked!
The data is written into the txt-file and after the 1000 seconds the close-event is triggered and the information is getting saved. Now I ask myself, is there a way to save the information continuously to the file? like every time the Server triggers the event to write, the txt-file is automaticall updated and saved?
I think about triggering all the events every time I write something to the txt-file(open file, write into file, close file. Or is there another solution?
Cheers
Julian
Thank you very much. I looked at your suggested example and it worked!
The data is written into the txt-file and after the 1000 seconds the close-event is triggered and the information is getting saved. Now I ask myself, is there a way to save the information continuously to the file? like every time the Server triggers the event to write, the txt-file is automaticall updated and saved?
I think about triggering all the events every time I write something to the txt-file(open file, write into file, close file. Or is there another solution?
Cheers
Julian
- HarryBunnik
- Posts: 362
- Joined: Monday 07 February, 2011 - 11:22
Re: Export Data to a txt-File
Hallo Julian,
Constantly opening and closing will make it relatively slow. If you open the file at the beginning of the simulation and close it at the end when you're done, you can in between continuously write to it from everywhere in the model. As long as the data that you write away, contains the name of the place where the logging is coming from, you can distinguish in what logging it was. Or am I misunderstanding your problem?
Cheers,
Harry
Constantly opening and closing will make it relatively slow. If you open the file at the beginning of the simulation and close it at the end when you're done, you can in between continuously write to it from everywhere in the model. As long as the data that you write away, contains the name of the place where the logging is coming from, you can distinguish in what logging it was. Or am I misunderstanding your problem?
Cheers,
Harry
Re: Export Data to a txt-File
Hallo Harry,
thank you very much for your fast and detailed reply.
I thought the same thing about constantly closing and opening the file.
My goal is to write and the save the data in 'real-time' to the txt-file.
When I use the example-model the data is written and saved to the txt when the whole simulation has ended. While the simulation is running the file is and stays blank until the end event is triggered and the file gets closed.
Cheers Julian
thank you very much for your fast and detailed reply.
I thought the same thing about constantly closing and opening the file.
My goal is to write and the save the data in 'real-time' to the txt-file.
When I use the example-model the data is written and saved to the txt when the whole simulation has ended. While the simulation is running the file is and stays blank until the end event is triggered and the file gets closed.
Cheers Julian
- HarryBunnik
- Posts: 362
- Joined: Monday 07 February, 2011 - 11:22
Re: Export Data to a txt-File
Hallo Julian,
The data is written constantly, but only once the file is closed, the file is finalized and the data becomes visible (Using the command "Fileclose"). If you want to be able to see the data half way your simulation, you'll have to:
I don't see another option so quickly.
Cheers,
Harry
The data is written constantly, but only once the file is closed, the file is finalized and the data becomes visible (Using the command "Fileclose"). If you want to be able to see the data half way your simulation, you'll have to:
- stop the simulation,
- close the file,
- look at the data,
- close the text file in the editor you're using (most likely this step is not necessary),
- reopen the file from ED
- continue running the simulation
I don't see another option so quickly.
Cheers,
Harry
Re: Export Data to a txt-File
Hallo Harry,
thank you again for your helpful answer.
Cheers
Julian
thank you again for your helpful answer.
Cheers
Julian