Create a file and save algorithm-data into it!

Hi,

A short and trivial question:

I have assigned a button to save algorithm data when pressed. I tried the code below which didn’t work (the txt-file was not created - it actually made my Vst-plugin break):

if(button==saveButton) { File *p_tmp= new File("C:\\AlgoData.txt"); int x=0; }

Can anyone please explain what I’ve done wrong?

Cheers

A File object represents a filename, so creating one doesn’t actually create the file. You need to learn about the File class a bit more, where you’ll see plenty of methods for creating and writing to the file.

And the breakpoint would be caused by the assertion that tells you not to use a non-absolute file name - because where on earth did you expect it to put this “algodata.txt” file? If you had debugged it, the debugger would have caught the assertion, and would have taken you straight to a nice comment explaining this.

[quote=“jules”]A File object represents a filename, so creating one doesn’t actually create the file. You need to learn about the File class a bit more, where you’ll see plenty of methods for creating and writing to the file.

And the breakpoint would be caused by the assertion that tells you not to use a non-absolute file name - because where on earth did you expect it to put this “algodata.txt” file? If you had debugged it, the debugger would have caught the assertion, and would have taken you straight to a nice comment explaining this.[/quote]

Hi Jules,

Thanks for your quick reply. It makes great sense what you write. Also, immediatly after I posted the thread I found some good hints in haydxn’s Juce tutorial!

Thanks again