Backslashes and curly brackets

The secrets of Rich Text Format, the lingua franca of the word processing world.

Tim Knott

If you are dealing with documents purely in an electronic state, rather than printing them out, then there are several advantages to using Rich Text Format (rtf) as the file format, rather than the native file format of whatever word processing software you are using.

Although rtf is a standard developed by Microsoft, it has long been the lingua franca of electronic documents. Any word processor should be able to both read and write in rtf format.

Advertisement

Like HTML, and unlike the binary format of Word doc files, rtf is a 7bit format. This means it can be sent in most email systems without further encoding such as UUencode and MIME, which binary files must go through, and is also platform and application independent. Again, like HTML, it can be 'read' by someone with a basic knowledge of the formatting commands in a plain-text editor such as Notepad.

Despite this 7bit limitation, rtf can encompass most of the features found in word processing, including multiple fonts, character and paragraph formatting, columns and tables. It even comes with its own way of encoding graphics into 7bit text. And it's all done with backslashes and curly brackets.

The beginning of the file has various header sections, which can contain document properties, such as the author and time of creation, and lists of resources used in the document, such as colours and fonts. The document body contains the text and formatting commands.

For example, if you want to use a character not in the sub-128 ANSI range, such as an 'e', this gets represented as a backslash, followed by an unhanded apostrophe, followed by the ANSI code in hex. So, the word 'Cafe', for example, would be encoded as Caf/'e9.

Character formatting can also be done with simple codes - /b and /b0, for instance, turn bold on and off. Formatting is more usually grouped, rather like styles, by enclosing the text and commands in curly quotes. For example:

{/b/i/f4 This text will be in bold italic, using font number four in the list}

The versatility and platform-independence of rtf make it a natural choice for the world of publishing, but there's another, equally compelling reason every file I've ever sent to Personal Computer World has been in this format. One thing an rtf document can't do - unlike Word 97 and 2000 - is contain macros.

But this seeming limitation is actually one of rtf's strongest points. With thousands of files flying about, generated both in-house and from freelance contributors, the threat of a macro virus is a constant worry. Since rtfs can't spread macros, there's nothing to worry about. Or, at least, that was the case until recently, when Microsoft discovered a major security hole in this department.

It seems that an rtf file can be used to activate a macro, if that macro is contained in a template referenced by the file. The problem only applies to Word 97 and 2000 on the PC, and 98 and 2001 on the Macintosh. Usually, if a user opens a document containing macros, they are warned, but in the case where a macro is embedded in a template on which the rtf file is based, the latter can trigger the macro without warning.

This, as the Microsoft bulletin warns, "would be able to take any action that the user could take. This could include disabling the user's Word security settings so that subsequently opened Word documents would no longer be checked for macros." Scary stuff indeed. Fortunately, Microsoft has already released patches for the affected versions of Word. You can find out more here.

Loop-da-loop

Which just leaves us room for a quick VBA query that I've promoted from the Question Time section. Reader John Shore referred to a problem that had been "bugging him for years". If he creates a macro by recording keystrokes - in this case to edit a list of email addresses - how can he make it repeat for each line in the file and then stop when it reaches the end of the file?

He has searched the VBA help files, which really demonstrates how badly these are indexed. Searching for 'end' or 'end of file' gets you nowhere, but John was so very close. Look up EOF, which as every programming veteran - and nobody else - knows is geek-speak for 'end-of-file' and all is revealed. Although you can use a While... Wend statement, the help file reckons it is classier to use the following:

Do While Not EOF(1)
'all the things
'you want to do
'go in here
Loop

  • Have your say
  • Send to a friend
  • Print
  • Digg
  • Reddit
  • Share

Tags:

Do you agree?

Further reading

Word processing - Macro magic

A guide to creating simple and easy to use macros in Microsoft Word.

Word processors

Word processors are becoming increasingly sophisticated. Featuressuch as grammar checking, automatic page layout, and 'smart'auto-correction allow you to process your words as perfectly and painlessly as possible. Tim Knott evaluates eight of the latest Windows packages.

Related whitepapers

Related jobs

Most watched

Motorola logo

Motorola demos femtocell hardware

Device combines femtocell, SIP softphone and digital photoframe

HTC Hero

Video: HTC Hero launch

Handset maker unveils its latest Android-based smartphone

IT white papers

Search white papers

Top categories

Poll

Poll: Summer smartphones

Poll: Summer smartphones

Which smartphone will you be taking to the beach this summer?

View poll results

Advertisement

Advertisement

Newsletter signup

Sign up for our range of FREE newsletters:

Existing User

Newsletter user login:

Enter email address to edit your newsletter preferences

Job of the week

Search thousands of IT jobs :

Search thousands of IT jobs:

Advanced search

Hiring now on ComputingCareers:

Related IT jobs

Search thousands of IT jobs :

Search thousands of IT jobs:

Advanced search

Spotlight

Overheating iPhones: Sorry I'll have to call you back, I'm in a heat wave

The heat wave may have broken in the UK, but...

Oracle

Oracle set to cut 1,000 staff in Europe

Firm sheds six per cent of European workforce to improve...

Cooling towers

Recession fuels growth in green IT initiatives

Green IT and cost-effective IT no longer mutually exclusive, says...

NXP showcases the future of silicon

We need to move "from living faster to living better",...

Primary Navigation