ATTENTIONThis 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 |
#1
|
||||
|
||||
Multiple files open
Hello,
For a large model I would like to have multiple text files open to write my results during the simulation run. Preferable by using a dll. I know how to open/close files in a dll. Also multiple files is possible, but only within 1 function. I would like to have some kind of reference to the files, so that I do not have to open and close the files each time. Is this possible and does anyone know how? Thanks, Lolke |
#2
|
||||
|
||||
You can use the C library's fopen command, which returns a FILE * type. Then you just need to globally define your FILE* variables.
Code:
FILE* myglobalfile1; FILE* myglobalfile2; double myfileopenfunc() { myglobalfile1 = fopen("C:\\log1.txt", "w"); myglobalfile2 = fopen("C:\\log2.txt", "w"); } ... |
The Following 3 Users Say Thank You to Anthony Johnson For This Useful Post: | ||
RalfGruber (01-30-2009) |
#4
|
||||
|
||||
Steven,
I think you're confusing Flexsim's "Global Variables" feature with a standard C++ global variable. A dll can have as many C++ global variables as you want to have, which is what was being used in the example code above. In 4.32 it wasn't possible to connect a dll to a Flexsim Global Variable, although it is possible now in 4.5 with a little extra connecting code. This isn't documented, so get back to me if you need to connect to Flexsim's Global Variables. |
The Following User Says Thank You to Anthony Johnson For This Useful Post: | ||
Lolke Koopmans (02-04-2009) |
#5
|
||||
|
||||
It seems that there are missing some replies in the forum.
Lars-Olof posted a very usefull piece of example code in this thread... |
#6
|
|||
|
|||
Everytime I try to post the code again I get an error.
I attach the code in a file until the problem is solved. L-O |
The Following 2 Users Say Thank You to Lars-Olof Leven For This Useful Post: | ||
Lolke Koopmans (02-04-2009) |
#7
|
||||
|
||||
Anthony,
I tried searching the forum but I couldn't find anything. Could you explain a bit more how to use Global Variabels from Flexsim in the DLL? I have looked at the file userfuncs.h and there it states how to define them but I expect that userfuncs has to be called somewhere. Is that in the DLLmain.cpp on the same location where also the Flexsimfuncs.h is called? We tried this but weren't succesfull. Steven Last edited by Steven Hamoen; 02-08-2010 at 09:02 AM. |
Thread | Thread Starter | Forum | Replies | Last Post |
how to open another GUI | qin tian | Q&A | 13 | 01-04-2010 06:52 AM |
Flowitem Bin and Media Files | Martijn van Oostenbrugge | Q&A | 10 | 09-04-2008 09:13 AM |
State files and global variables | Markus Bans | Q&A | 3 | 07-08-2008 12:22 PM |
Creating fsm-Files | Ralfi | Q&A | 4 | 10-16-2007 06:07 PM |