Reputation: 881
I have created a setup button with the following code
to setup
file-open "tcout.txt"
file-print "Hello World" ;; File is in writing mode
end
and pressed it once. The file is created but it's empty:
Can anyone please help?
Upvotes: 3
Views: 413
Reputation: 9620
As in other languages, what happens when you write to a file (here, issue a file-print
command) depends on your operating system. If you want to ensure that what you are writing shows up immediately on disk, you need to flush or close the file. Details are in the documentation:
https://ccl.northwestern.edu/netlogo/docs/dictionary.html#file-flush
Upvotes: 2
Reputation: 1199
In NetLogo, after writing output to a file you also have to close the file in the end:
either via file-close
- closes the previously openend file
or via file-close-all
- closes all previously opened files
Upvotes: 2