I remember seeing on these forums, a post about exporting a project's code to a text file somehow, but I have searched the forums and can't seem to find it.
Could someone please advise me if this is still possible, and if so how.
Thank you all, in advance.
If you're running Windows, one way to export a project's code to a text file is to use File --> Print, having first installed a "Generic / Text Only" printer to your computer.
It's not really a physical printer. It simply allows a Windows user the freedom to "print" to a disk FILE. The "file" it prints is plain text ("text only"), which means that it's not anything fancy like PDF, but in this situation PDF (in my opinion) is over-kiil (and over-long) when all you ordnarily want is plain text.
I suspect there is something similar to "Generic / Text Only" that can be done on Linux or a Mac, but I do not (yet) have any real experience with those two platforms.
One option that can be used on any platform, however, is (as someone has already mentioned) to save the project as an XML file. That is a very powerful approach, but it has two significant complications if all you want is export a project's source code to a text file: (1) it intermingles the source code with other information related to the project (but probably unrelated to your posted purpose), and (2) and it contains no information on indentation of the source code.
Both limitations, however, can be easily overcome, but let me explain them a bit first. First, you may not have thought about it, but RB programs really have two parts. On one of its menus, RB calls the two parts "Edit Source Code" and "Edit Window." Even though we often think only of the source code, what is not source code is equally important to the project. You couldn't have the project without it.
If you want to extract the source code from the XML file, it's not difficult to do. You can easily write a short program of half a dozen lines to do that. All the program has to do is to discard entirely the lines that do not begin with "<Source Line> and then from the remaining lines discard "<Source Line>" at the beginning and "</Source Line>" at the end.
What's left is the source code. One problem: you do not have the indenting that you ordinarily expect. You have to do the indenting yourself OR you can use a program someone else has written to extract the source code AND to add the appropriate indenting.
Such a program (free with free source code) is my CodeHelper, which you can get at http://traver.org/ch/ch115.rbp
. In addition to extracting and formatting source code and allowing you to save it as a text file on disk, it does a lot more, since it doesn't look only at (source) code, but takes advantage of other information in the XML file, i.e., "Window" information in addition to "Source Code" information.
If you are ONLY interested in exporting a project's code to a text file, you don't need something like CodeHelper. It's a lot easier to just use File --> Print to a "Generic / Text Only" Printer (or its equivalent) to "print" a text file on disk. But with CodeHelper you can analyze or modify that part of your program which is NOT in the source code, and which is equally important to the source code.
For more on CodeHeper, go to http://traver.org/ch/ch105.htm
Further questions? Please feel free to contact me through email or phone (details in last file). I'll do my best to answer them. (Or, of course, you can post your question here.)