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 14 in printed book and digital formats -- plus a one-year subscription 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 12.4 ('Game Center')
Instant purchase and download via GumRoad!

COLUMN

Eureka!

Tips and Tricks for the Xojo Developer

Issue: 12.4 (July/August 2014)
Author: Markus Winter
Author Bio: Markus is a Molecular Biologist who taught himself REALbasic programming in 2003 to let the computer deal with some exceedingly tedious lab tasks. Some call it lazy, he thinks it smart. He still thinks of himself as an advanced beginner at best.
Article Description: No description available.
Article Length (in bytes): 16,453
Starting Page Number: 71
Article Number: 12414
Related Web Link(s):

http://www.monkeybreadsoftware.de/realbasic/plugin-regex.shtml
http://www.realsoftwareblog.com/2012/11/speeding-up-textarea-modifications.html
http://www.xojo.com/blog/en/2013/07/take-advantage-of-your-multi-core-processor.php
http://www.tempel.org/RB/MultiProcessing
http://www.xdevmag.com/browse/9.3/

Excerpt of article text...

Henry David Thoreau (an American poet and philosopher among other things; see Figure 1) liked to measure the worth of things by the time it took to acquire them. For example: if you had to work for a day to afford the train ticket to a place that you could just as well reach on foot during that time, then it was clearly not worth taking the train. Instead of a pleasant day in the countryside (and doing something for your fitness and well-being to boot), you would have to spend the time working, possibly by being stuck in a stuffy office or breaking your back on the railways—but you are no better off afterwards.

While public transport has become a lot cheaper since Thoreaus's time, it is worth keeping his approach in mind. You only have around 2,365,200,000 seconds to live—so using it wisely and not wasting it pointlessly is important. That is doubly true for your users, as any time savings in your app is multiplied by the number of its users. Every second that Microsoft Office could be quicker would save nearly 32 years of users' time! So, I'm sure Thoreau would approve of any tips that speed up your app.

Tip 1: Speeding up saving and loading RTF files on the Mac

RTF is the standard text document exchange format for many apps. It is, for word processors, what tab delimited files are for spreadsheets. If you are using RTFdata under Windows, then you might not have noticed, but under MacOS it is simply unusable. Getting and setting a TextArea's RTFdata is mostly fine for small amounts of text, but it gets exponentially slower as the length grows, becoming unusable surprisingly quickly: getting RTFdata from a TextArea containing just 8000 characters (not words) takes 25 seconds on a fairly speedy Mac.

Most people will encounter this when reading or saving RTF files (for example those produced by Word). Bob Keeney did some extensive testing and found that the built-in Xojo RegEx class is extremely slow. Something in the neighborhood of 80ms for every search, and some of the test files that people have been giving him have proven that this is THE bottleneck when reading RTF - and the larger the file, the worse it gets.

But this isn't the only problem. In my testing, I deliberately created an RTF file from Word where the original file included items that the TextArea can't display like (among other things) a text box with a picture and some text. Unsurprisingly the text box and its contents did not show up (neither do they in TextEdit or any other app I tried except Word), and it took 11 seconds for the text to appear in the TextArea. What did, however, surprise me was that only a tiny amount of the original text arrived in the TextArea! Now what? You can hardly ask users to clean up their RTF files before trying to open them in your app!

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