Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 15.5 ('Touch Bar')
Instant purchase and download via GumRoad!

COLUMN

Making Code Pretty

Using IDE Scripting for Custom Code Formatting

Issue: 15.5 (September/October 2017)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 15,290
Starting Page Number: 66
Article Number: 15507
Resource File(s):

Download Icon project15507.zip Updated: 2017-09-05 00:14:46

Related Web Link(s):

http://developer.xojo.com/custom-code-reformatting

Excerpt of article text...

We all have coding standards and try to be consistent in the way we write our programs, but it can be hard. I've long considered writing a program to change code to match my style, but have never gotten around to doing it. Now with Xojo 2017r2, Xojo has inspired me with a new feature: custom code reformatting.

As you may know, Xojo has long had a preference setting for automatically reformatting your code to match a certain style. The problem was, if you didn't like that style, there was nothing you could do about it. Now you can write a script that runs to style your code just the way you want it!

Well, that's the theory, anyway. In practice, I've found this new feature to be painful to implement.

Creating ReformatCode.xojo_script

In principle, using this new feature is easy. Just create a new XojoScript called "ReformatCode.xojo_script" and stick it in the Scripts folder inside Xojo's folder. Then when you select some code in Xojo and bring up the contextual menu (see Figure 1), you can choose the "Standardize Format" to run the script.

(A XojoScript is a plain text file, so you can create this with any text editor. You can also create it with Xojo's "New IDE Script" menu command which you'll find on the File menu under "IDE Scripting." This will provide you with an editor that will apply color syntaxing and other features to make scripting easier.)

...End of Excerpt. Please purchase the magazine to read the full article.