11.07.2015 Views

WEB-ENABLE POWERBUILDER APPS WITH SYBASE EASERVER ...

WEB-ENABLE POWERBUILDER APPS WITH SYBASE EASERVER ...

WEB-ENABLE POWERBUILDER APPS WITH SYBASE EASERVER ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

FIGURE 1Same window internationalized in two languagespiler installer (lccwin32.exe) with the manual,but also the documentation installer(lccdoc.exe). It’s a command-line compiler thatcomes with a simple yet very capable IDE (andeven includes a GUI builder).At the very beginning we ran into someissues with the LCC-WIN32 resource compilerfailing to compile strings larger than 255 characters(quite common for some of our Frenchmessages). What happened next made me abeliever in open source. I contacted JacobNavia about the problem around 5 p.m. EST viae-mail. Despite the time difference (Franceversus Canada), he had a fixed version for methe next morning. My congratulations go out toJacob for providing such superb support for histool.Please refer to the sidebar, Installing andSetting Up LCC-WIN32, for a detailed list of thesteps required to install LCC-WIN32 and set upa project in it that you can use to maintainresource strings and compile them into a DLL.Seeing It All in ActionPlease download the LANGUAGE.PBL fromwww.sys-con.com/pbdj/sourcec.cfm. It containsthe class N_CST_LANGUAGE in which allthe required APIs are already set up for you. Italso includes a small test application thatprompts you to enter any of the two DLLs supplied(English.dll and Polish.dll, for example)and displays an internationalized window inwhatever language the selected DLL was compiledin (see Figure 1).Note that the test window doesn’t containFIGURE 2LCC-WIN32 resource editor outputoptionsany hard-coded internationalization logic;instead it’s encapsulated in the ancestor visualobjects (command button, label, multilineedit, etc.). They automatically translate themselvesupon creation using a resource IDembedded in their text label. This simpleapproach allows you to visually enter resourceIDs in the PowerBuilder GUI builder instead ofcoding them by hand, making the wholeprocess faster and more productive.INSTALLING AND SETTING UP LCC-WIN321. Install LCC-WIN32 using the installer EXE. I recommend installing intothe default directory (usually “C:\lcc”) to avoid installing into a directorywith spaces embedded in its name.2 After installing, start up the lcc-win IDE (Wedit) using the shortcut inStart—>Programs—>lcc-win32.3. After Wedit starts up, create a new project using File—>New—> Project….4. Choose a project name.5. Define the project properties (namely, the source directory in whichyou want your files to be compiled). Be sure to select the “Type ofProject” as “Dynamic Link Library (dll)”.6. When prompted whether to create an application skeleton, select“Yes.”7. Wedit displays a summary of the options for your project. Please notethe “Resource file” field at the bottom. It’s the actual resource file we’llbe maintaining and then compiling into a DLL.8. You’re then prompted for the default compiler settings; select “OK” toaccept them.9. Select “OK” to accept the default linker settings.10. Select “Finish” to accept the default debugger settings and completethe wizard. This will create the stub C code necessary to compile aDLL. No other C coding on our part is required; Wedit makes theentire process very simple.11. Create a resource file within the project using the Design—>Open/New… menu option and then type in the required name of theresource file (it can be anything you want, but I keep it the same as theproject name). This opens the Wedit resource editor, which can be usedto create all types of resources, not just strings. This editor is gearedmore toward creating dialogs, menus, etc., but you’ll only be using it tomaintain the string table of all phrases you want to internationalize. Toaccomplish that, change a few of the default resource settings.12. Invoke the Design—>Output menu option, which pops up the outputoptions dialog. Make sure the “RC ASCII resource file (.rc)” option isset up and flagged as “Generate,” as in Figure 2. Select “Validate” tosave the settings.13.Our next step is the actual creation of a string resource. To accomplishthis we need to go to Design—>New—>strings. This opens the StringTable editor where we can finally start entering string phrases with theresource IDs that identify them.14. To start adding strings, select the “Add” action on the right-hand sideof the window, which prompts you for the resource string to enter aswell as its ID (see Figure 3).The “Value” field is the resource ID; the “Content” field is the actualstring phrase. Selecting “OK” saves the value to the resource file.Using this resource editor we can add all the string phrases requiredby our application.15. After you’re finished, select “Save” to save your changes to the file.Obviously, you can reopen the same resource file later from withinWedit and add any new phrases that you might need later.16. To let LCC-WIN32 know that this resource file needs to be compiledwith the DLL, you need to add it to the project. This is a one-timeaction that you need to perform only after creating the file for the firsttime. It can be accomplished via the Project—>Add/Delete Files…menu option, which in turns brings up the dialog box shown in Figure4, where you can add the newly created *.RC file to the project.Simply select the “Add” button and select your *.RC file. Select the“Validate” button when you’re finished.17. At this point we already have a base C project and a base resource filein which we can keep adding new strings. To compile both of theminto a DLL we simply need to invoke the Compiler—>Compile “project_name.c”option. This compiles the DLL and makes it ready for youto use in your PowerBuilder application. The compiled DLL is locatedin the “\lcc” subdirectory of your project’s base directory.16PBDJ volume9 issue4www.SYS-CON.COM/pbdj/

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!