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

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Monosnap 4.12.0 - Versatile screenshot u...
Monosnap lets you capture screenshots, share files, and record video and .gifs. Features Capture: Capture full screen, just part of the screen, or a selected window Make your crop area pixel... Read more
Visual Studio Code 1.57.0 - Cross-platfo...
Visual Studio Code provides developers with a new choice of developer tool that combines the simplicity and streamlined experience of a code editor with the best of what developers need for their... Read more
Bartender 4.1.0 - Organize your menu-bar...
Bartender lets you organize your menu-bar apps by hiding them, rearranging them, or moving them to Bartender's Bar. You can display the full menu bar, set options to have menu-bar items show in the... Read more
GraphicConverter 11.5 - $39.95
GraphicConverter is an all-purpose image-editing program that can import 200 different graphic-based formats, edit the image, and export it to any of 80 available file formats. The high-end editing... Read more
VLC Media Player 3.0.15 - Popular multim...
VLC Media Player is a highly portable multimedia player for various audio and video formats (MPEG-1, MPEG-2, MPEG-4, DivX, MP3, OGG, ...) as well as DVDs, VCDs, and various streaming protocols. It... Read more
NeoOffice 2017.28 - Mac-tailored, OpenOf...
NeoOffice is a complete office suite for OS X. With NeoOffice, users can view, edit, and save OpenOffice documents, PDF files, and most Microsoft Word, Excel, and PowerPoint documents. NeoOffice 3.x... Read more
Capto 1.2.28 - Capture, annotate, organi...
Capto (was Voila) is an easy-to-use app that takes capturing, recording, video and image editing to the next level. With an intelligent file manager and quick sharing options, Capto is perfect for... Read more
iMazing 2.13.9 - Complete iOS device man...
iMazing is the world’s favourite iOS device manager for Mac and PC. Millions of users every year leverage its powerful capabilities to make the most of their personal or business iPhone and iPad.... Read more
VueScan 9.7.56 - Scanner software with a...
VueScan is a scanning program that works with most high-quality flatbed and film scanners to produce scans that have excellent color fidelity and color balance. VueScan is easy to use, and has... Read more
LibreOffice 7.1.4.2 - Free, open-source...
LibreOffice is an office suite (word processor, spreadsheet, presentations, drawing tool) compatible with other major office suites. The Document Foundation is coordinating development and... Read more

Latest Forum Discussions

See All

Exos Heroes is celebrating the impending...
The Season Four update for Line Games' Exos Heroes is arriving soon, and the developers have decided to throw a party to celebrate. They are calling it the Season 4 Eve Party, and it will provide players with a plethora of rewards. [Read more] | Read more »
Componut is a 2D physics based puzzler a...
Componut is an upcoming 2D physics-based puzzle game that's heading for iOS and Android sometime this June. The name, as you may have already guessed, blends the words component and donut. Why? Because you will get tasked with returning one of... | Read more »
Angry Birds Slingshot Stories returning...
Rovio has announced it will be launching a second season of Angry Birds Slingshot Stories on 19th June. [Read more] | Read more »
Everything you need to know about Space...
The excellent Space Marshals 3 just released a new chapter of 12 missions, just about doubling the original release's size. In them, Burton continues his wild adventures through space taking down bounty hunters, illegal intergalactic still... | Read more »
Guild of Dungeoneering is a DnD-style de...
During the Guerilla Collective digital games festival on Saturday, Gambrinous announced it will be launching a major remaster for its tabletop-inspired RPG Guild of Dungeoneering. The remaster is supposed to be coming to both PC and mobile devices... | Read more »
Gumslinger welcomes bosses, characters a...
Today, Itatake has released the first major update for their colourful action game, Gumslinger. It introduces a bunch of new content and features to the title, including duels against bosses. These fierce opponents include Lobster Bob, Boss Orc... | Read more »
A Scrub's Guide to League of Legend...
League of Legends: Wild Rift is the friendliest and most accessible MOBA on mobile, but it still maintains a high skill ceiling and demands your full attention while playing. You can't just hop into games casually and assume you'll be a great... | Read more »
PUBG Mobile's latest collaboration...
PUBG Mobile has announced yet another collaboration today, this time with Mclaren. The popular battle royale frequently teams up with a host of other brands, but this marks the first occasion they have partnered with an automotive company. [Read... | Read more »
Divinity - Original Sin 2 - Gameplay Jou...
| Read more »
Memory Stamps is a new memory puzzler ou...
Indie game developer Tepes Ovidiu has released a new puzzle title called Memory Stamps for iOS and Android devices. [Read more] | Read more »

Price Scanner via MacPrices.net

Apple’s 24″ M1 iMacs on sale for $50 off MSRP
Amazon has Apple’s new 24″ M1 iMacs on sale this weekend for $50 off MSRP with prices starting at $1249 shipped. At the moment, the $50 discount is restricted to certain colors & configurations,... Read more
Sale! Apple AirPods Max for $499, save $50
Amazon has Silver and Blue AirPods Max on sale for $499 shipped. Their price is $50 off Apple’s MSRP, and it’s the lowest price we’ve seen so far for AirPods Max. For the latest prices & sales,... Read more
New Apple Canada promotion: Free $75 Apple Gi...
Apple Canada is offering a free $75 Apple Gift Card with the purchase of an iPhone 12 or iPhone 12 mini through June 28, 2021. Additional savings are available with the trade-in of an eligible device... Read more
Apple has last year’s iPhone 11 available tod...
Apple has a range of Certified Refurbished iPhone 11 models available today starting at only $549. Apple includes a standard one-year warranty, new outer shell, and shipping is free. According to... Read more
These Apple resellers are offering $100 disco...
Looking for a discount on one of Apple’s popular new Mac minis with Apple M1 Silicon CPUs? These Apple Authorized Resellers are offering $100 discounts on standard mini configurations today: (2):... Read more
New promo at Xfinity Mobile: Buy on Apple iPh...
Buy on 64GB iPhone SE at Xfinity Mobile through June 25, 2021, and get a second one for free. 24 month contract required, and cost for the free phone will be credited to your account over a 24 month... Read more
Apple restocks 3″ M1 MacBook Airs for as litt...
Apple has restocked a full line of 2020 13″ M1 MacBook Airs, Certified Refurbished, starting at only $849 and up to $190 off original MSRP. These are the cheapest M1 MacBook Airs for sale today at... Read more
Apple Watch Series 6 GPS + Cellular on sale f...
Amazon has Apple Watch Series 6 GPS + Cellular models on sale for $70 off Apple’s MSRP. These are the same Watches sold by Apple in their retail and online stores. Be sure to order from Amazon,... Read more
Get a new M1 13″ MacBook Air for up to $63 of...
Apple reseller Expercom has 2020 13″ M1 MacBook Airs on sale for up to $63 off Apple’s MSRP with prices starting at $948. In addition to their MacBook Air sale prices, take $44 off AppleCare+ when... Read more
B&H launches 16″ MacBook Pro sale with mo...
B&H has Apple’s 16″ MacBook Pros on sale for $200-$300 off Apple’s MSRP with prices starting at $2199. Expedited shipping is free to many addresses in the US. Their prices are among the lowest... Read more

Jobs Board

*Apple* Health Drug Utilization Review Speci...
Description ** Apple Health Drug Utilization Review Specialist (MAPS 3/CQCT)** **71029045** This position is relied upon for timely review and analysis of drug Read more
*Apple* End User Support Specialist - North...
…of Key Responsibility: 1. Responsible for support of all College owned Apple computers, mobile ios devices and peripherals such as monitors, keyboards, printers, Read more
*Apple* /Mac Support Technician - Insight Net...
Apple /Mac Support Technician Ft Lauderdale, FL, US St Petersburg, FL, US Requisition Number: 82002 Position Overview As our Desktop Support Specialist, you will work Read more
Teller at *Apple* Valley (40 hours) - Wells...
…+ Ability to work weekends and holidays as needed or scheduled **Street Address** **MN- Apple Valley:** 14325 Cedar Ave - Apple Valley, MN **Disclaimer** All Read more
*Apple* Mac Infrastructure Design & Deli...
…Overview** CTI End User Services Desktop OS Engineering team is seeking an Apple Mac Infrastructure Design & Delivery Engineer to provide engineering services for Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.