GoDB Developer Network
Tuesday, November 07, 2006
  Chart control in GoDB
One of the cool features added in version 3.9 is the chart control.

Let me provide you the gist before going into the details:

Best part:

Best bet if there is a large and emcompassing requirement to build feature rich charts.


Type of Charts available:

The below links provide samples / syntax on how to create / use line, pie and bar charts

Chart Tutorial

Line Chart

Chart With X Legend Texts

Charts With Multiple Data Streams

Bar Charts With Multiple Data Streams

Horizonal Bar Charts

Horizonal Bar Charts With Multiple Data Streams

Chart with Chart Labels, Chart Legend and Chart Event handling

Different Chart Types for Different Data Streams

Chart with Colors Specified for Points

Pie Charts

Database Driven Charts

Database Driven Charts With Multiple Data Streams

 
Monday, December 12, 2005
  Using Web Services with GBasic (GoDB)
This article shall peep into invoking a webservice from the internet through GoDB. Iam using HTTPDNLD file and XML commands of GoDB.

The application takes the input of a host name and queries a WHOIS server through webservices and gets the detailed information.

For this, I am using http://www.webservicex.net . You can use other WHOIS server though.

Configuring the proxy:

for those having a proxy, you need to configure first before using the application. To go to Configuration screen (inbuilt with GoDB) press Function key 9 (F9). Fillin only the 'ProxyIP' field with your Proxy server. Leave other fields. Click 'save' and 'Go Home'



















Querying the web:


the httpdnld command sends a http request with a host name as the parameter to a webservice. The webservice inturn queries a whois server and sends the result back. The result is saved in a file called test.xml



path$=http://www.webservicex.net/whois.asmx/GetWhoIS?HostName=+trim$(#txtName$)
RET=HTTPDNLD(path$,"","TEST.XML",1)
if RET=-3 then
msgbox "unable to get file"
endif

Parsing the XML:

Now, having created a XML file, we need to parse and display the content in the application for view. Since, the parse is inbuilt in GoDB, my work is much reduced- precisely four lines.

h=XMLParseFile("TEST.XML",1)

if ret>0 then
ret= XMLGoToFirst(h)
while XMLFetch(h,"")=1
str$=str$+ xvalue$(h)
pprint xpath$(h) ; xvalue$(h)

wend
endif

ret=XMLClose(h)
#txtRes$=str$



Overall, if you see, I put up a simple form to enter the host name, a button to query the web and a text area to print the queried results. I stored the data in XML format, parsed it and and displayed in the text area. A variance can be, instead of saving it in XML format, we can also save the same in .txt format and display.



HTTPDOWNLOAD.ZIP
 
Tuesday, December 06, 2005
  Plotting charts with GoDB
With GoDB you can construct graphs and charts- both static and dynamic quite easily and pep up your data presentation. This article will touch the shallow waters of charting with static data. End of the article there is a link to download the source code for this charting application.

First some definitions:

''*****************************************************************
''''SOME VARIABLES THAT CAN BE INCLUDED IN THE QUERY STRING ARE

'XMargin = 20 MARGIN WIDTH BETWEEN COORDINATES IN X LEGEND
'XOrigin = 5 STARTING X1 POSITION OF RECTANGLE
'XRange = 190 X2-530, XRANGE IS DIFF OF X1 AND X2
'XDiv = 5 NO. OF DIVISIONS IN X AXIS

'YMargin = 20 MARGIN WIDTH BETWEEN COORDINATES IN Y LEGEND
'YOrigin = 210 STARTING Y1 POSITION OF RECTANGLE
'YRange = 200 YRANGE IS DIFF OF Y1 AND Y2
'YDiv = 5 NO. OF DIVISIONS IN Y AXIS


'ShowData = 1 TO DISPLAY DATA, WHILE PLOTTING POINTS

'Type = 1 LINE CHART
'Type = 2 BAR CHART
''*****************************************************************


'XAXIS$ = LIST OF X COORDINATES
'YAXIS$ = LIST OF Y COORDINATES

'SAMPLE COORDINATES
'XAxis$ = "1999,2000,2001,2002,2003,2004,2005,2006,2007,2008, 2009"
'YAxis$ = "50.340,83,737,90.50,400,300,200,200,400, 200, 300"



Bar Chart: Drawing the rectangle bar

to draw the rectangle bar, use drawrect function

ex: drawrect(XOrigin-10,YOrigin,XRange+30,-YRange,2,0,46815,46815)

For Color coding the bar use Fillrect function

ex: fillrect(XOrigin,YOrigin,XRange,-YRange,46815)




Line charts:

Line charts invovle two basic components. Plotting the data and drawing line.

PLOTTING DATA

If ubound(Str$) > 0 Then
For Count = 0 to ubound(Str$)
If Count=0 Then
m1=split(arrY$,Str$(Count),",")
ElseIf Count = 1 Then
m1=split(arrY$,Str$(Count),",")
End If

for i = 0 to NoOfPoints - 1
DataX = atol(arrX$(i))
NewX = TransX(DataX, XMax, XMin)
DataY = atol(arrY$(i))
NewY = TransY(DataY, YMax, YMin)
If Request$("Type") = "1" Then
iff i>0 then drawline(NewX,NewY,OldX,OldY,1,1)
iff ShowData>0 then textout(NewX,NewY,arrY$(i),0,63504, 5)
drawrect(NewX,NewY,2,2,2,1,63488,0)
ElseIf Request$("Type") = "2" Then
iff showData>0 then textout(NewX-5,NewY-20,arrY$(i),0,63504, 5)
drawrect(NewX-5,NewY,10,YOrigin-NewY,2,1,1,255)
End If
OldX = NewX
OldY = NewY
next
Next
Else
for i = 0 to NoOfPoints - 1
DataX = atol(arrX$(i))
NewX = TransX(DataX, XMax, XMin)
DataY = atol(arrY$(i))
NewY = TransY(DataY, YMax, YMin)
If Request$("Type") = "1" Then
iff i>0 then drawline(NewX,NewY,OldX,OldY,1,1)
iff ShowData>0 then textout(NewX,NewY,arrY$(i),0,63504, 5)
drawrect(NewX,NewY,2,2,2,1,63488,0)
ElseIf Request$("Type") = "2" Then
iff showData>0 then textout(NewX-5,NewY-20,arrY$(i),0,63504, 5)
drawrect(NewX-5,NewY,10,YOrigin-NewY,2,1,1,255)
End If
OldX = NewX
OldY = NewY
next
End If

Plotting charts from dynamic data or from database shall be dealt in future articles. So expect a sequel.




charts.zip

 
Monday, December 05, 2005
  Printing: support for USB printers

GoDB has support for printing from serial printers. But for Win32 platform, there may be a need print to common printers attached to PC.

Direct Printing is supported through serial ports. In case other printers are required, GoDB usually launch the printing application provided by the printer manufacturer with the temporary file contains the contents to be printed.

For ex: You can use HP's print application for Pocket PC to print a file using the OS_EXEC command.

Syntax: OS_EXEC("hpprint.exe data.txt")

Here data.txt is the data to be printed, created within GoDB as an external file

 
Friday, December 02, 2005
  Sample code for Activating trial applications.

This sample application provides input on how to create Trial Versions of applications and their distribution & activation mechanism for the developer community. The Sample application attached herewith gives an idea on how to Create Application ID, generate activation key and activation of the same by the user. It includes an Activation form where 'No. of Tries left' is shown along with a button (How To Activate), on click of which shows an 'Application ID'.

P.S. By default "no. of times left" shows 1000. This means the user can login upto 1000 times in the application. This no. can be defined by the Developer also. (Syntax: MaxAllowed=1000)

Steps to be Followed:

=====================

1) How to Activate - On click of this button by the user a message box pops up with the application id. The user would need to send the application ID to your predefined Email address (Eg.info@xxxx.com)

2) Use your custom logic to Generate an activation key and send the same to the user.( Refer sample code in samplekey.asp )

3) The user enters the activation key and clicks on activate button.







ActivationKey.zip

 
Wednesday, November 30, 2005
  Obtain IMEI number of your symbian phone from Your Go-DB application

by Ted Daniel -- Source: www.newlc.com

Go-DB supports loading external DLLs via simple GBasic APIs. Although most of the widgets neccessary for business application development are avaiable in Go-DB, you may in certain cases want to extend a particular platform for reasons best suited for your requirement be it for your application related needs or simply having fun. Find out how to use Go-DB to obtain IMEI number(International Mobile Equipment Identity) from your Go-DB application. In a later article, i will explain how to send SMS from your Go-DB application from a Sony Ericsson p910i phone.

Any cross platform application development at a particular point may need to extend a particular platform. Like any good cross platform development tool, Go-DB offers features which enable developers to fully extend a platform’s full capability. This article focuses on certain APIs in GBasic and how to use them to hook your DLL built using Symbian SDK.

Step 1

You will need GStudio 3.4 (now a newer version 3.6 is available for download) final realease. Get a trial copy from http://www.go-db.com. You will also need Symbian module , which can be downloaded from the same location. (comes pre-installed with version 3.6. So no need to do this step)

Step 2

Download and install a Symbian SDK. For this particular example any SDK for Symbian OS version 6.0 and above is needed. I have used UIQ 2.1 SDK wincw version, downloadable from Sony Ericsson developer site(http://developer.sonyericsson.com)


NOTE: You dont need to have Codewarrior to get this example working.

Step 3

Download the sources for this tutorial, downloadable with this article. Download and unzip to your Symbian install drive.Open a command prompt window and issue these commands.


bldmake bldfiles

abld build armi urel

This will buid the DLL. Pre-built SIS files are located in Group directory. SIS file installation will copy IMEIDLL.DLL to /system/libs directory on your device. Change the pkg file located in Group directory to suit your requirement.


Step 4

Build the Go-DB project in release mode. Create a SIS file for your device and install it. Click on "Fetch IMEI" button and a message box will pop-up displaying your device’s IMEI number.

The Source code is as Follows


Listing 1. Symbian cpp source code

Our DLL exports one function whose definition is EXPORT_C long GetIMEICode(char *str); and the implementation is as follows

EXPORT_C long GetIMEICode(char *str)

{

int i= 0;

TBuf<256> Path;

TPlpVariantMachineId imei;

PlpVariant::GetMachineIdL(imei);

Path.Copy(imei);

for(i=0;i < Path.Length();i++)

{

str[i] = Path[i];

}

str[i] = '\0';

return 1;

}


Note that Go-DB understands "char *" only as parameters to functions.Converting to and from Symbian Descriptors is neccessary.After freezing the dll and building the project, note that a .DEF file will be created which will list the functions exported and theordinal associated with it.Our .DEF bundled with source shows the following.

EXPORTS

E32Dll__F10TDllReason @ 1 NONAME R3UNUSED ; E32Dll(TDllReason)

GetIMEICode__FPc @ 2 NONAME R3UNUSED ; GetIMEICode(char *)

We are not interested in E32Dll , just GetIMEICode. The ordinal as given to us is 2. This ordinal will be needed by our GBasic Code.

Note: To freeze a dll after exports have been identified and defined properly, issue this command

abld freeze armi

Listing 2. Go-DB source code

Sub IMEICTRL_Click

st1$="Initial String"

h = loadlib("\\system\\libs\\IMEIDLL.dll")

if h <> -1 then

ret = calllibfunc(h,"2",st1$)

msgbox("IMEI Code is " + st1$)

unloadlib(h)

else

msgbox("Failed loading IMEIDLL.DLL")

end if

End Sub

We load the IMEIDLL first using loadlib function, if the function gets loaded properly, then the handle it returns will not be -1. Once we obtain the handle , use the handle in calllibfunc to execute the exported function. As explained in Listing 1, use "2" as Function Name. After the function call, st1$ will hold the IMEI number.




GoDB-IMEI.zip
7.6 kb

 
Tuesday, November 29, 2005
  Ged Reference


Ged is the tool used to import and export data between html pages and databases and
GoDB's file system.

Note: This is used by GStudio Internally.

Ged can be used for the following :

1) Import Html, Image , Database, Text, config and forms.

2) Export database and config files.




Notes :

GoDB filesystems SHOULD be named as "bdb" and should be in the current working directory (of ged and simulator). All the following operations are executed on this file.


Usage : GED [options] InFile [ext]

Options



-a Add Any File without translation. Used to add raw binary files.

Usage: Ged -a xyz.txt



-h Add Html files with tag translation. Used to load html pages and forms.

Usage: Adding a Page -- Ged -h test.html .txt

Adding a form-- Ged -h test.html


Note: Refer to -p option to set font height while translation.



-p Sets the font height for translation. This should be combined with -h option.

Usage: ged -p 12 -h test.htm

Note: If this option is not provided then ged assumes a font height of 8.



-g Translates image into GoDB Image file.

Usage: ged -g [FileName] [Rle] [ColorDepth]


Rle - Determines the Compression

0 - Uncompressed.
1 - Compressed.


ColorDepth -

0 - Monochrome

1 - Pallete based 256 color

2 - 64k Colors (RGB565 format).



-i Will index the a database table

Usage: ged -i [Tablename] [IndexFileName] [KeyField] [KeyLength_in_chars]


Ex: ged -i Comp Comp.idx CompID 12


 
  GStudio Reference

GStudio

GStudio is the and Integrated development Environment to edit debug and simulate GoDB applications.

Menu Options.

File Menu

File Operations.

Edit Menu

Editor Operations.

Build Menu

Compile : Compiles the current file.

Build : Builds the project by compiling all the Modified Files.

Build All : Builds all the Files in the project.

Clean: Deletes all the intermediate files in the build folder including the database files.

Start Debug : Launches the simulator and connotes to it for source level debugging.

Run : Launches the simulator in Run Mode.

Remove All Breakpoints: Removes all the breakpoints in the open bas files.

Configurations: Add or remove Platforms to the Forms Builder.

Publish: Publishes the current project to GoDB Sync Server for Application Deployment.

Exclude Setup: Launches a dialog that lets you exclude files for different platforms.Ex: In some cases you might have ifferent images for different platforms and youexclude the images from getting to all the platforms. Home_PPC.bin should get compiled only to PPC platforms, Home_PALM.bin should get compiled only to Palm platforms etc.

Tools Menu

AddPlatform To Project : This option adds a new platform to the project. Platforms option allows the developer to have different form layouts for different Resolutions.This is similar to Build ->Configurations.

Unicode To UTF: This option helps the developer to get UTF-8 Encoded strings from Unicode strings. elect the Language option from the Language tool bar in the OS and
type it on the Uincode Edit box , the UTF text will appear in the UTF Text
box.This can be copied and pasted into the property


window.

Other Options in this menu let you Publish the app and VM to devices create setups etc.

View Menu

Clear Build Window: Clears the Build Output Window. PPrint outputs to thiswindow during debug Sessions.

Clear Trace Marks : Clears the Cyan marks in the left margin when you run your project in debug mode.



Options -> Project

Project

GVS: When using the GoDB Sync server, GVS is the GODB Versioning system formulti user
projects. Refer to Sync server manual for GVS configuration.



Options -> Source & Design:


Insert Comments Options determines if the comments are automatically insertedwhen you press enter after entering a sub statement.

Enable Auto Completion Options determines if the Auto Completion Popup
ShowsUp.

Auto Intend Options determines if Code intends automatically in the editor.

Use UTF8 This option if Unchecked will render characters above ASCII 127 as Extended ASCII Characters. This is required for projects that use scandinavian ASCII characters .



Options -> Build



Verbrose option determines if the external tools output, like the compiler output etc are displayed in the build output window.

Publish Compiled Scripts option publishes the compiled files to GoDB Sync server
automaticallyafter compilation.

BDB Custom Size option lets you sepcify the Maximum size of the BDB. Default is 90 MB.

Command Line option let you specify the Additional Command line parameters while Executing.

Ex: -a=100 -b=200 etc these will be available in GBasic as GetOsVar$("*CMDLINE")




Option -> Workspace


Gridspacing Determines the guide grid in the form builder.

Render Images Determines if the images are rendered in the form builder.

Auto Hide DesignTools Determines if the Tool Box is automatically hidden when you switch to code view from the form builder.

Selection: Determines if the selection rectangle selects Complete or partial Selections.

When the "Select items that are completely..."
option is selected only the first control is selected.When
the "Include Partial Items..." option is selected both the controls are
selected.



Layout MenuForm Layout Operations.

Set Tab Order Let you set the focus order of the controls in the form.Select this option and click on the controls in the order you want the controlsand select Layout->Set Taborder Option to go back to normal editing.


Before After

Example:

Script Wizard Menu

Creates Scripts for the current form and fields.

Window Menu

Manages open windows in the IDE.

Help Menu

Help, Activation , Updates etc.

 
  How GoDB Works ?

GoDB works by having runtimes (VM) for various platforms that isolate hardware specific issues from the application developer.

For example GoDB provides a consistent way of rendering forms with edit boxes and buttons, display images on forms, store data in RDBMS as records etc on all platforms. GoDB VM takes care of determining the type of file system used (Ex Flash,FAT etc) and implements appropriate the read and write routines. Similarly GoDB VM takes care of determining the display solution and color depth and renders forms in color or monochrome accordingly.

GoDB has the following components.


  1. Microbrowser to render Forms and Pages.

  2. RDBMS engine with ANSI SQL support.

  3. GBasic programming environment.

  4. File System Manager.

  5. Display manager.

  6. Pointer/Keyboard Manager

  7. Connectivity Manager.

  8. Smart Sync Manager.

  9. Memory Manager (Heap/Stack)


All these components were written in pure ANSI "C" so that it could be compiled on multiple platforms. These components form the GoDB runtime environment (VM).
This enables the applications developed for GoDB on one platform say Win32 to run on the another platform say Palm without any change.


The following components are hosted in Windows.


  1. GStudio - GoDB IDE with Integrated Source level Debugger.

  2. GoDB Compiler

  3. GoDB platform simulators.


Platforms supported



GoDB VM

GoDB VM is the runtime engine that renders the forms and executes the applications on the various platforms. GoDB VM reads the Forms, gBasic and image files from the GoDB file system that is generated by the GoDB IDE after successful compilation of the project. This file system contains all the files required by an application and is called the BDB. To deploy an application to other platforms this file is just copied to that platform.

GoDB Build Process




GoDB Architecture



 
  Custom Keyboards (GoDb Enterprise Edition)

When dealing with multi lingual fonts or devices that do not have keyboards, GoDB provides an
extensible Multilingual Keyboard and GBasic API for managing the Keyboard.

To create a Custom Keyboard you need to create an Image with the KeyMap.



You need to create XML Keyboard Map files that specify the Location of the keys and the ASCII code that has to be generated corresponding to the font you are using. The XML file should have the same name as that of the image file, say you have T_Main.GIF the XML file should be called T_Main.xml.

The XML is defined as

<gkeymap keycount='10'>

<key x='17' y='0' w='17' h='15' c='1' >

<key x='28' y='31' w='17' h='15' c='a' >

<key x='212' y='47' w='26' h='15' a='13' >

<key x='0' y='47' w='34' h='17' i='T_shift_main'>

</gkeymap>

Where keycount Specifies the Number of keys in the keyboard.
x,y Specifies the Coordinates of the Key.
w,h Specifies the Dimensions of the Key.
Character Codes that need to be generated can be specified as c - Character that needs to be
generated for the key.

a - ASCII / Unicode Code for the character that needs to be generated.
Multiple Keyboards can also be liked with the i attribute
i - This attribute can be used to load another keyboard when the user clicks on the specified
region. In the example clicking on the Shift key will load the T_shift_main.bin and T_shift_main.xml.



To Load the Keyboard you have to use the LoadKeyBoard Method.
To Show the Keyboard you have to use the ShowKeyBoard Method.
To Hide the Keyboard you have to use the HideKeyBoard Method.

Compile and run the project



In the simulator you can Display the keyboard using the F5 key.



You can click on the Shift Key for the Alternate Keyboard.




 
  Importing Fonts


Goto Tools -> Font Importer.


Select the Font By Clicking the Select Font Button.



This should open up the Font selection dialog select the font and Hit OK. Next Select the The Font File Name to Export the font to (Say Font7.fnt)

Next Select the Char Set. Select Basic Latin and Click on the Add (">") Button.



Click on the Export Button.

This should create the Font file. Add the font file (F7.fnt) to the project. Add a text box to your form and change the Font attribute for the text box to 7 and save compile and run the project.

GoDB supports Unicode fonts too. See Tutorial on using Unicode for Multilingual apps and font apps.

Note: Font files are copyrighted and you should acquire necessary Licences to export and
use them in your applications.

 
  Styles Fonts and Icons

GoDB's Microbrowser supports customization of all the widgets and color schemes using Style Files.

Style files are standard text files with CSS extension that have the name of the colors to change and the new color value.

Ex:

TXTFLD_FG_COL=31 'Foreground color

TXTFLD_BG_COL= 65520'Background color

TXTFLD_BORDER_COL=63519'Border color
TXTFLD_SELTXT_COL= 63488 'Selected text color
TXTFLD_SEL_COL= 65504 'Selected background color
TXTFLD_SELBRDR_COL= 2016 'Selected border color


The above example shows how color scheme of a text box can be changed.

The file name of the CSS file determines which form the style is applied to. For example if you name the CSS file as home.css then the styles apply only to Home.Frm.

If the CSS file is named Global.CSS then the style applies to all the forms but can be overridden by specific CSS files (say home.css).

Starting with GoDB 3.6 you can use HTML 24 it Color formats #FE00FF

Example:

Right click in the project explorer and select Add File. Enter Home.CSS in the open dialog. Open Home.css and enter the example css data.



Compile and Run the application.



You can add global.css and copy the style contents and see that all the forms show the same style. Refer to styles section in the help for a complete list of style names.

You can also load custom fonts into godb. These fonts can be English or regional fonts. You need to use GoDB Font Converter tool to convert any standard ttf file to a file that can be used in GoDB. GoDB supports up to 20 concurrent fonts. These are numbered from 0-19 , Fonts 3, 4 and 5 are preloaded into the GoDB VM. These can be overridden to change the standard fonts in godb. GoDB also supports right to left Arabic and Hebrew Fonts.


 
Welcome to the unofficial GoDB Developer Network. This blog is completely dedicated to GoDB platform -- a multi platform Mobile RAD tool for developing handheld and wireless applications for Windows Mobile (Pocket PC,Win CE, Smartphones), Palm, Symbian, Embedded Linux, Linux, Win 32, etc. Fellow GoDB developers can find sample codes, contribute to the blog and Mobility related news for the benefit of the mobile development community as a whole.

ARCHIVES
2005-11-20 / 2005-11-27 / 2005-12-04 / 2005-12-11 / 2006-11-05 /


Powered by Blogger