ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 07-18-2008
Gavin Douglas Gavin Douglas is offline
Flexsim User
 
Join Date: Feb 2008
Posts: 65
Downloads: 1
Uploads: 0
Thanks: 27
Thanked 1 Time in 1 Post
Rep Power: 152
Gavin Douglas is on a distinguished road
Default Writing to a CSV

Hi,

I have a processor with a processing time of 100 with an output to a sink. Using the OnEntry trigger for the sink I have the code:

fileopen("C:\Models\MachineShopFolder\Q1_03.csv");
fpt("HI");
fpr();
fileclose();


I let the model run 350 time units and I would expect to see three HI entries in the file- I see only one. Even when I leave off fileclose(); I see only one. I guess I’m new to writing data out to csv’s.
__________________
"A bird is an instrument working according to mathematical law, which is within the capacity of man to reproduce." -Leonardo da Vinci, 1502
  #2  
Old 07-18-2008
Anthony Johnson's Avatar
Anthony Johnson Anthony Johnson is offline
Manager of Product Development
 
Join Date: Jul 2007
Posts: 440
Downloads: 86
Uploads: 4
Thanks: 171
Thanked 899 Times in 288 Posts
Rep Power: 735
Anthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond reputeAnthony Johnson has a reputation beyond repute
Default

Gavin,
The fileopen command opens the file and erases the current content. You can add a second parameter to the fileopen command: fileopen(
"C:\\Models\\MachineShopFolder\\Q1_03.csv", "a"); This will append to the file instead of clearing.

My advice, however, would be to simply call fileopen once, at time 0 when the model starts, using a UserEvent, and then call fileclose using another UserEvent that fires on reset, so the file will be opened as soon as you start running the model, and will be closed the next time you reset the model.

The Following User Says Thank You to Anthony Johnson For This Useful Post:
Gavin Douglas (07-18-2008)
  #3  
Old 07-18-2008
Gavin Douglas Gavin Douglas is offline
Flexsim User
 
Join Date: Feb 2008
Posts: 65
Downloads: 1
Uploads: 0
Thanks: 27
Thanked 1 Time in 1 Post
Rep Power: 152
Gavin Douglas is on a distinguished road
Default

Great!! Thanks ..........
__________________
"A bird is an instrument working according to mathematical law, which is within the capacity of man to reproduce." -Leonardo da Vinci, 1502
The Following User Says Thank You to Gavin Douglas For This Useful Post:
RalfGruber (07-31-2008)



All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.