Cut and Paste
Edit > Copyand email is always quick and easy.
In addition, you can choose "Copy" in a context menu when your
Right-clickfor PCs) on a method name in the project's lists. You code will be surrounded with "Sub" or "Function" declaration lines including parameter types.
Export & Import
Select a class in your project's listing, then choose
File > Export. Your class and all its related code are copied into a disk file. That file can then be imported into another project. On import, the file's content is copied into your project, after which you can trash the file.
You may export a class, a Window, a module, or a menu bar.
You may choose between exporting using REAL Studio's own native format, or in XML format. Both can be imported into another project. You may find it interesting to peruse an export in XML format. In theory, I suppose one could build a tool to generate these XML files thereby creating REAL Studio forms programmatically.
External Project Item
Export-import is certainly more convenient than copy-paste. But if you have some generic code that you use in multiple projects, making changes to that code becomes tedious when you export again and re-import repeatedly into the various other projects. Wouldn't it be nice if REAL Studio could refer to that exported file without actually importing? Well, it can.
Rather than choosing
File > Importin the various projects, instead hold down the Option key (ALT key for PCs) while choosing the
Filemenu. The "Import" menu item changes to "Import as external". This command tells REAL Studio to consider that external file to be a part of the project without actually copying its contents. When you do a compile or build in incorporating project, REAL Studio compiles that source code too. That source code may be sitting in an external file (outside the project file) but is nevertheless part of the project.
Later, when you revise the shared source code, merely replacing the external file effectively updates all the various incorporating projects. No need to import again into each of the projects.
As an alternative to using the File menu, you can incorporate the external file into a project by dragging the file into the project window while holding down
While working in that incorporating project, you can even edit the external file. How convenient. One catch, of course, is that you should not try to edit the same external file from two different projects at the same time -- just as you would not have two word-processors editing the same document simultaneously.
Another catch is that you can only incorporate external files as source code. You cannot include a chunk of compiled REALbasic code into another project. However, you do have the option of encrypting the external source code file. Encryption enables you to sell or give away your software without disclosing the open source code, if you so desire.
Shortcut: The "Make External" menu item is a convenient shortcut for exporting a selected class' source code to a disk file, deleting the original source code in the project, and importing as external that newly created file. So you can instantly prep your existing source code for sharing with other projects and people.