Ok, so I did understand it. Let me explain the limitations. You will almost have to rewrite the whole forum code to achieve what you want (which is why I won't be writing the code for you).
The part of the message that is in the code tags is simply not separated from the rest of the message. So there will be no easy way to write just the code into a text file. Not that it would be easy even if the code were separated from the rest.
It'd be much easier to write a mod to simply have a "highlight and copy" button for the code. I will eventually write code like that for this site.
There is another set of possible options.
Javascript can't actually save files (for obvious security reasons).
But I wrote a couple of scripts that could help.
Save to .txt file
That script takes a text and dynamically creates a .txt file and prompts the user to save it.
Now this will still be tricky, you will still need the text to escape all the characters like quotation marks that would break the javascript.
You will also need to make extensive modification to the forum software. But at least this should give you one idea of how you can do this without writing temporary text files to the server (which I'd not advise for this).
Write information to a new window
I wrote that script while thinking about this challenge but it's nopt as good as the last one.
In any case, like I have said. The modification you want will require extensive rewriting of the forum code.