TweetFollow Us on Twitter

Oct 99 Factory Floor

Volume Number: 15 (1999)
Issue Number: 10
Column Tag: From the Factory Floor

A Palm Update, Part 2

by Eric Cloninger and Dave Mark

Web apps with Lasso and FileMaker Pro

Last month's Factory Floor got us back in sync with the Palm development universe. We checked out some of the new features in the upcoming Palm OS SDK and CodeWarrior for Palm OS releases. This month, Eric Cloninger will take us through the process of developing an internationalized Palm OS application.

Eric Cloninger is the product manager and technical lead for CodeWarrior for Palm OS. When he isn't working on CodeWarrior, he spends way too much time on his research project - how to rid the world of the affliction known as the 'designated hitter rule'. He can be reached at ericc@metrowerks.com.

Dave: Tell me about the application you'll be taking us through.

Eric: This month, I'm going to go through an application I wrote using CodeWarrior for Palm OS Release 6 (available in October 1999). The application, called Base X, takes advantage of several new features that Palm has added to the OS, the SDK and the tools.

Since our goal is to make an international Palm OS application, I chose an example that is simple to describe but is also useful in a real-world sense. This example, called Base X, provides four edit fields that display the same 4 byte value as decimal, hexadecimal, octal, and binary. In addition to the user interface elements on the main form, Base X has a menu bar, an alert and an info string, all of which have been localized from English to German, French, and Japanese.

I started by creating a new project from the "Palm OS C App" stationery project. CodeWarrior for Palm OS provides stationery projects for Palm OS 3.1 (for the original Pilot, PalmPilot, Palm III, and Palm V), Palm OS 3.2 (for the wireless Palm VII), as well as Japanese examples.

I renamed the resource file to BaseX_english.rsrc and opened it with Constructor for Palm OS. Constructor for Palm OS is very similar to Constructor for PowerPlant - you can create menus, menu bars, pictures, icons, etc. In fact, all of these elements use standard MacOS resource types, so you can edit them with ResEdit or Resourcerer. The thing that is unique about Constructor for Palm OS is that it lets you create the Palm-specific resource types that define how forms look. Figure 1 is from Constructor for Palm OS - it shows the main form for Base X as it appears in the English resource file.


Figure 1. Constructor for Palm OS editing a Palm OS form.

After I created the user interface, I moved the resources that are language neutral into a separate resource file called BaseX_Common.rsrc. Then, I moved the English resource file into a directory named "English" and duplicated it for German, French, and Japanese and renamed the files appropriately.

In my CodeWarrior project, I created four targets, one each for English, German, French, and Japanese. Next, I added the common resources to all four targets and the language-specific resources to each of the language targets. At this point, for each target I have a source file, a common resource file, and a language-specific resource file. I have not yet written any code to operate my user interface, but the starter application has enough code in it to display my form.

Next came the localization part. First, I browsed to babelfish.altavista.com and tried their web interface. The engine that provides the translation on the web page is available as a commercial product called SYSTRAN. I used the web interface to convert my strings, but I found that the translations weren't quite right and it doesn't translate to Japanese. Since Metrowerks has offices in many parts of the world, I asked employees to do the translations instead. These employees aren't in our Austin office and they didn't have immediate access to the Palm tools, so I had to find a way to get the strings to them easily.

Using the CodeWarrior IDE, I created an empty target in my project called "DeRez". Then I added the English resource file to that target and changed the settings for the target to use the 68K linker (to activate preference panels - no linking occurred in this target). Next, I changed the "File Mappings" panel so that files of type "PLob" (Palm OS Constructor files) are compiled with the "Rez" compiler. Finally, I entered a file called PalmTypes.r for the Prefix file in the "Rez" panel. I saved these settings and returned to the "Files" view of the project window.

From the files view, I clicked on BaseX_english.rsrc and held the mouse button for a second until the pop-up menu appeared with an item called "Disassemble". The Rez compiler will disassemble resource files into .r files if it has type definitions for the resources, which is what PalmTypes.r provides. The result of the disassembly is a new text file that I sent to my colleagues. PalmTypes.r is available from Palms' developer web site, by the way.

I knew it would be several thousand Swatch beats before I got my replies back, so I decided to jump into the programming task.

Base X has four edit fields into which the user can enter text for decimal, hexadecimal, octal and binary numbers. When the user enters a character, Base X sees if the character is valid for the field with the edit focus and converts all the fields if it is. The code for all of BaseX is too long to include in this article, so I've put it on Metrowerks web site at the address shown at the end of this article. The code segment below is the part that converts strings from one base to another and is where I had to use the Palm OS internationalization manager.

// This struct describes how to convert strings 
// into different bases. It’s OK for this to be 
// single-byte chars because it’s never shown.
struct {      
 char *digits;
 char multiplier;
} cvtTable[4] = {
 {“0123456789”, 10},
 {“0123456789abcdef”, 16},
 {“01234567”, 8},
 {“01”, 2}
};

// Convert a string to a number using base ‘x’
ULong ToLong(WChar *str, short table_index) {
 unsigned long accum = 0;
 WChar ch = 0;
 short str_index = 0;
 short accum_index = 0;
 
 // Go through the input string, pull each 
 // character off and find the index of that
 // character in the table. That index is 
 // the amount to add to the accumulator.
 while (str_index < EDIT_SIZE) {
  str_index += TxtGlueGetNextChar(
     (Char *) str, str_index, &ch);
  if (ch)
  {
   accum_index = 0;
   while ((accum_index <
     StrLen(cvtTable[table_index].digits)) &&
     (WChar)
     cvtTable[table_index].digits[accum_index]
     != ch)
    accum_index++;

   accum *= cvtTable[table_index].multiplier;
   accum += accum_index;
  }
 }
 
 return accum;
}

// Creates a string of base ‘x’ from a long value
void ToString(ULong value, WChar *str, short table_index)
{
 short masked_value;
 char temp_str[EDIT_SIZE];
 char *p = temp_str;
 short str_index = 0;
 
 while (value > 0) {
  masked_value = value % 
      cvtTable[table_index].multiplier;
  *p++ = cvtTable[table_index].digits[masked_value];
  value /= cvtTable[table_index].multiplier;
 }

 // At this point, temp_str is in reverse order.
 // Create output by walking temp_str in reverse.
 str_index = 0;
 while ( — p >= temp_str) 
  str_index += TxtGlueSetNextChar(
    (Char *) str, str_index, (WChar) *p);
}

The functions prefixed by 'TxtGlue' are notable because they are implemented through a library called PalmOSGlue.lib instead of the A-trap mechanism used by most of the OS calls. These functions are safe to use on devices running version 2.0 or later of the Palm OS, regardless of whether it is a single-byte or multi-byte OS.

By the time I had the code working for English, my translations were done. Thanks to Andreas Hommel, Christophe Escobar, and Shoji Ueda for providing this service. Next came the task of getting the converted resources into the project without re-entering the text myself.

Developers who work with localized applications are faced with the same situation I found myself in - whether to keep localized resources in a text file where the text can be modified easily, or to keep them as resource files where their properties can be modified with a visual editor. Either method is fine and CodeWarrior allows me to use resource files or Rez files, so I chose to set up my project so that I could use either method.

I created a new target called 'Rez French' cloned from the 'French' target. I modified the settings so that the output file created by the MacOS linker is different from the output file generated by the resource file target. I also modified the 'Rez' panel to include the 'PalmTypes.r' file as the prefix file. Into this target, I added the translated BaseX_french.r file. Then, I built the project.

The output from the linker and post linker was the translated Palm OS application. An artifact of the build process is a file that also contains all my application's resources before they were modified by the post linker. I opened this intermediate file, called BaseXRsrc.tmp, with ResEdit and copied all the resources except 'CODE' and 'DATA' into my French resource file named BaseX_french.rsrc. At this point, I can create a French Palm OS application using either the .r file that is compiled by the Rez compiler or I can build the same application using resources included from the Constructor file. Next, I duplicated this work for the English, German, and Japanese targets.

After building my applications, I want to run them and see how they work. I could download them individually to my Palm OS device over the serial connection or I can use an extremely useful application called the Palm OS Emulator, or POSE for short. POSE is an application that contains a 68K emulator and it runs the Palm OS image that is in ROM. You must own a Palm device to get the ROM image, which is downloaded from your Palm device using an application called ROM Transfer.

Figure 2 shows the Palm OS Emulator running the Japanese version of BaseX. Any Palm device is capable of displaying English, French, and German applications. Japanese applications require a Japanese-enabled ROM to display the text correctly.


Figure 2. Palm OS Emulator and CodeWarrior debugger.

Let's suppose that I decide I don't like the way one of the Japanese screens looks - perhaps I want to change the text of the info string shown in the about box. Instead of sending the text file to Tokyo where it's early in the morning, I use Constructor for Palm OS to modify the strings myself. Palm has modified Constructor to work with the Japanese Language Kit. With the JLK installed on my Mac, I need only change the selection for the "Palm OS Target" in Constructor to "Palm OS for Japan" and then I can begin editing in Japanese.

Now, I open the editor for the string that I want to modify. I select Japanese mode input by clicking on the blue triangle on the menu bar in the upper right corner. As I type, the MacOS pops up a text entry window that converts the 'sounds' I am typing into the correct characters, as shown in Figure 3.



Figure 3. Constructors' string editor with Japanese text input.

At this point, BaseX is completed. I hope that I've been able to show that CodeWarrior for Palm OS and the Palm OS SDK provide a rich toolkit for developers who want to or need to write international applications. CodeWarrior Professional users who want to try out the Palm OS tools can do so after October by visiting the Metrowerks web site and downloading the tools.

Users who want to play with the BaseX project file or the application can download the archive from the Metrowerks Palm OS web site listed at the end of the article.

Resources

 
AAPL
$106.79
Apple Inc.
-0.55
MSFT
$45.98
Microsoft Corpora
-0.65
GOOG
$544.32
Google Inc.
-5.01

MacTech Search:
Community Search:

Software Updates via MacUpdate

VMware Fusion 7.0.1 - Run Windows apps a...
VMware Fusion allows you to create a Virtual Machine on your Mac and run Windows (including Windows 8.1) and Windows software on your Mac. Run your favorite Windows applications alongside Mac... Read more
OneNote 15.3.2 - Free digital notebook f...
OneNote is your very own digital notebook. With OneNote, you can capture that flash of genius, that moment of inspiration, or that list of errands that's too important to forget. Whether you're at... Read more
Audio Hijack Pro 2.11.4 - Record and enh...
Audio Hijack Pro drastically changes the way you use audio on your computer, giving you the freedom to listen to audio when you want and how you want. Record and enhance any audio with Audio Hijack... Read more
Iridient Developer 3.0.0 beta 3 - Powerf...
Iridient Developer (was RAW Developer) is a powerful image conversion application designed specifically for OS X. Iridient Developer gives advanced photographers total control over every aspect of... Read more
TextWrangler 4.5.11 - Free general purpo...
TextWrangler is the powerful general purpose text editor, and Unix and server administrator's tool. Oh, and also, like the best things in life, it's free. TextWrangler is the "little brother" to... Read more
NeoFinder 6.6 - Catalog your external me...
NeoFinder (formerly CDFinder) rapidly organizes your data, either on external or internal disks, or any other volumes. It catalogs all your data, so you stay in control of your data archive or disk... Read more
Chromium 38.0.2125.111 - Fast and stable...
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all Internet users to experience the web. FreeSMUG-Free OpenSource Mac User Group build is... Read more
Default Folder X 4.6.11 - Enhances Open...
Default Folder X attaches a toolbar to the right side of the Open and Save dialogs in any OS X-native application. The toolbar gives you fast access to various folders and commands. You just click... Read more
Mariner Write 3.9.3 - Light-weight and s...
Mariner Write is your Mac OS go-to word processing tool! Professional writer, educator or student, Write has all the functionality you need for that important letter, technical paper or research... Read more
DesktopLyrics 2.6.5 - Displays current i...
DesktopLyrics is an application that displays the lyrics of the song currently playing in "iTunes" right on your desktop. The lyrics for the song have to be set in iTunes; DesktopLyrics does nothing... Read more

Latest Forum Discussions

See All

French Developer Pated Unveils Seashine
French Developer Pated Unveils Seashine Posted by Ellis Spice on October 30th, 2014 [ permalink ] French one-man studio Pated has unveiled Seashine, “a poetic journey into the abyss.” Players take on the role of a jellyfish strugglin | Read more »
Agents of Storm: Tips, Tricks, and Strat...
Calling all agents: Would you like to see what we thought of this rather pretty base builder? Check out our Agents of Storm review! Have you downloaded Agents of Storm, been bowled over by the graphics, and aren’t quite sure what to do next? Never... | Read more »
Any.DO 2.0 Hopes to Help Manage Producti...
Any.DO 2.0 Hopes to Help Manage Productivity Posted by Ellis Spice on October 30th, 2014 [ permalink ] iPhone App - Designed for the iPhone, compatible with the iPad | Read more »
Base Busters Review
Base Busters Review By Jennifer Allen on October 30th, 2014 Our Rating: :: FUN BUT RESTRICTED MIXUniversal App - Designed for iPhone and iPad Mixing up two forms of tower defense gaming and collectible cards, Base Busters is a fun... | Read more »
Sumptus - Personal Expense Tracker in Yo...
Sumptus - Personal Expense Tracker in Your Pocket 1.0 Device: iOS iPhone Category: Finance Price: $3.99, Version: 1.0 (iTunes) Description: Sumptus - a personal finance assistant in your pocket. It’s an ultimate expense tracker... | Read more »
Meat Factory (Games)
Meat Factory 0.1 Device: iOS Universal Category: Games Price: $.99, Version: 0.1 (iTunes) Description: Meat factory harks back to the old days of the game and watch. Easy to pick up and play, but hard to score big. With cute visuals... | Read more »
Medford Asylum: Paranormal Case - Hidden...
Medford Asylum: Paranormal Case - Hidden Object Adventure (Full) 1.0 Device: iOS Universal Category: Games Price: $4.99, Version: 1.0 (iTunes) Description: Uncover the mystery of Medford City asylum! | Read more »
Secret Files Sam Peters (Games)
Secret Files Sam Peters 1.0.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0.0 (iTunes) Description: [ After the successful iOS release of Secret Files Tunguska, the acclaimed point and click adventure Secret Files... | Read more »
Woah Dave! (Games)
Woah Dave! 1.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0 (iTunes) Description: ***SPECIAL LAUNCH PRICE! IT DOESN'T COST A LOT OF MONEY!*** Optimized for iPhone 6+! A huge hit at E3, PAX, PAX East, IndieCade... | Read more »
Drift'n'Drive (Games)
Drift'n'Drive 1.0.0 Device: iOS Universal Category: Games Price: $1.99, Version: 1.0.0 (iTunes) Description: Follow your destiny to become the ultimate racing driver! | Read more »

Price Scanner via MacPrices.net

New 2.8GHz Mac mini on sale for $949, save $5...
Abt Electronics has the new 2.8GHz Mac mini in stock and on sale for $949.05 including free shipping. Their price is $50 off MSRP, and it’s the lowest price available for this model from any reseller... Read more
Sale! 3.7GHz Quad Core Mac Pro available for...
 B&H Photo has the 3.7GHz Quad Core Mac Pro on sale for $2649 including free shipping plus NY sales tax only. Their price is $350 off MSRP, and it’s the lowest price for this model from any... Read more
Mujjo Steps Up The Game With Refined Touchscr...
Netherlands based Mujjo have just launched their Refined Touchscreen Gloves, stepping up their game. The gloves feature a updated elegant design that takes these knitted gloves to the next level. A... Read more
Sale! Preorder the new 27-inch 5K iMac for $2...
 Abt Electronics has the new 27″ 3.5GHz 5K iMac on sale and available for preorder for $2374.05 including free shipping. Their price is $125 off MSRP, and it’s the lowest price available for this... Read more
Simplex Solutions Inc. Brings Secure Web Surf...
New York based Simplex Solutions Inc. has announced the release and immediate availability of Private Browser 1.0, its revolutionary new secure web browser developed for iPhone, iPad and iPod touch... Read more
Save up to $180 off MSRP with an Apple refurb...
The Apple Store has Apple Certified Refurbished 2014 MacBook Airs available for up to $180 off the cost of new models. An Apple one-year warranty is included with each MacBook, and shipping is free.... Read more
Apple refurbished 2013 MacBook Pros available...
The Apple Store has Apple Certified Refurbished 13″ and 15″ MacBook Pros available starting at $929. Apple’s one-year warranty is standard, and shipping is free: - 13″ 2.5GHz MacBook Pros (4GB RAM/... Read more
What Post PC Era? – The Mac Bounces Back, Big...
Apple’s fiscal Q4 2014 was an all-time record quarter for Mac sales, with 5.5 million units shipped, representing nearly one million more sales (+21 percent, + 25 percent sequentially) than Apple... Read more
Unpacking The Big Changes At Microsoft – iPad...
The days of product keys and email attachments are nearing an end and Microsoft, though late to the game, is making big strides to keep up, says tech expert Karl Volkman of SRV Network, Inc. Under... Read more
Apple refurbished iPad Airs and minis availab...
Apple dropped prices recently on Apple Certified Refurbished iPad Airs and iPad mini 2s, with models now available starting at $209. Apple’s one-year warranty is included with each model, and... Read more

Jobs Board

*Apple* Solutions Consultant (ASC) - Apple I...
…important role that the ASC serves is that of providing an excellent Apple Customer Experience. Responsibilities include: * Promoting Apple products and solutions Read more
*Apple* Solutions Consultant (ASC) - Apple I...
…important role that the ASC serves is that of providing an excellent Apple Customer Experience. Responsibilities include: * Promoting Apple products and solutions Read more
*Apple* Solutions Consultant (ASC) - Apple I...
…important role that the ASC serves is that of providing an excellent Apple Customer Experience. Responsibilities include: * Promoting Apple products and solutions Read more
*Apple* Solutions Consultant - Apple Inc. (U...
…important role that the ASC serves is that of providing an excellent Apple Customer Experience. Responsibilities include: * Promoting Apple products and solutions Read more
*Apple* Solutions Consultant - Apple Inc. (U...
…important role that the ASC serves is that of providing an excellent Apple Customer Experience. Responsibilities include: * Promoting Apple products and solutions Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.