GoDB Developer Network
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.


 
Monday, November 28, 2005
  Lessong 8: Advanced Topics -External Communication API.

GoDB has support for communicating using sockets, Serial Ports etc. You can use the
DevopenDevRead DevWrite and DevClose functions for this.

Socket Communication.

For Sockets
'DEVOPEN(0,IP,PORT)

st1$="Hello There\r\n"
ret=DEVOPEN(0,"127.0.0.1","8080")
ret = DEVWRITE(0,st1$,"")
ret = DEVREAD(0,st1$,"")
print st1$
DevClose(0,"")


DevRead and DevWrite use Binary Escaped Strings ie Nulls are escaped as /00 and / as /2f (Refer to Chapter on Binary Files).
For Serial Ports and Serial Printers.'DEVOPEN(1,PortID,[Speed,FlowControl])

st1$="Hello There\r\n"ret=DEVOPEN(1,"COM1:","9600,0")
ret = DEVWRITE(1,st1$,"")
ret = DEVREAD(1,st1$,"")
print st1$
DevClose(1,"")



Drawing and Painting

GoDB supports drawing and painting routines like DrawLine, FillRect etc. GoDB Repaints the screen when something major changes happen on the screen.
An example is a Calc Box or LUT Showing up. As the screen gets repainted, all previous drawing commands can get overwritten. To avoid this put all your drawing functions in Form_Paint routine

All drawing routines in Form_Paint routine are called automatically when ever the screen gets repainted.


Sub Form_Paint
' Add Handler Code Here fillrect(10,10,100,100,63488)
fillrect(20,20,100,100,2016) fillrect(30,30,100,100,31)
fillrect(40,40,100,100,2047)
End Sub

GoDB has built in Double Buffering where all drawing and painting routines are drawn on to a local offscreen buffer and then transferred to the OnScreen Buffer.This avoid flickering.

You can selectively paint a field in GoDB.This feature is useful in certain scenarios like for example if you want to paint a control inside a tight loop in GBasic.

If you run the following code you will see only the last number shown in the Field.

Sub Button1_Click
for i=1 to 100
#text1=i sleep(10)
next
End Sub


If you run the following code you can see the numbers changing in the edit control.

Sub Button1_Click
for i=1 to 100
#text1=i
#text1.paint(1)
sleep(10)
next End Sub

From GBasic you can paint the screen using the Paint method or refresh and repaint all the controls using the Update method.


Signature Fields (GoDb Enterprise Edition)

GoDB has a built in signature capture field. The signature capture fields uses the Value attribute of thefield to create two bitmap files, the signature and the thumbnail of signature.When the form is rendered the thumbnail is displayed on the form and when the user clicks onthe signature capture field, the bitmap is displayed in the popup. If the disabled attribute is set to 1 then the popup is not displayed so the user cannot modify the signature.

In a database application the Value attribute should be set to a unique key of the captured record.

Ex: #Sign1$="S_"+PrimKey$ This will create unique sig files that can be associated with a
record.Sig2BMP component can be used convert the .SIG file to a BMP File.



Timers

GoDB has a built in timer for handing background tasks. The timer can be set with a time interval and an Event handler function.

settimer(50,"TimerFunc")
end

Sub TimerFunc
#text1$=format$("time",Time())
#text1.paint(1)
End Sub


Calling External Processes

You can launch an external process / EXE using the OS_EXEC command. You can Launch Print Applications, IR Transfer applications (IRSquirt in Pocket PC), File viewers Like ACROBAT reader, Internet explorer etc
Ex:

ret = os_exec("F:/WINNT/NOTEPAD.EXE C:/temp/test.txt")


External API Dlls

GoDB supports loading of DLLS and Loadable modules (.so files in Linux) for calling native platform functions. The DLLs can be loaded using the LoadLib Function.

h=LoadLib("Test.dll")
When the DLL is loaded The Init function on the DLL is called with the HWND Handle.


//****************************************************
__declspec(dllexport) long Init(HWND hWnd)
{
MessageBox(NULL,"Init","Hi",MB_OK);
return 1;
}


You can call the functions in the Dll using the CallLib Function. GoDB passes all the Parameters as character Pointers to the DLL.


st1$="Hello There Param 1"
st2$="Hello There Param 2"
calllibfunc(h,"TestFunc0")
calllibfunc(h,"TestFunc1",st1$)
print st1$

//****************************************************

__declspec( dllexport ) long TestFunc0()
{
MessageBox(NULL,"Func0","Hi",MB_OK);
return 1;
}


__declspec( dllexport ) long TestFunc1(char *p1)
{
MessageBox(NULL,p1,"Hi",MB_OK);
strcpy(p1,"Changed in DLL");
return 1;
}

To Unload the dll call the UnloadLib Function.


h = loadlib("gDllTest.dll")
ret = unloadlib(h)


When the DLL is unloaded the Deinit Function is called.


//*******************************************************************
// DeInit function in the DLL
//*******************************************************************

__declspec(dllexport)
long DeInit()
{
MessageBox(NULL,"DeInit","Hi",MB_OK);
return 1;
}



Using ActiveX/COM Components in GoDB

GoDB Allows you to instantiate and use ActiveX/COM Components in Win32 and WinCE Platforms.To use a Component you need to add the GDO Control to your form First.This can be done at the design time by
adding the control to a Form.


Or or at runtime by using the Print Command.

print "<gdo Name='GDO1' ProgID= 'WMPlayer.OCX.7' X='100' Y= '100' W='100'
H= '100' >"

In GBasic you can call the methods on the objects as if they were standard Field Objects.

Sub Button1_Click #GDO1.URL$ = "c:\\temp\\1.mpg"
End Sub

The thing to note here is that All String Properties of the object should have a $ at the end.When distributing the Applications that have ActiveX components you need to distribute GDOBridge.dll in the GoDB Installation folder.



GDO Dlls

Only Win32 and WinCE support Com components natively. To create Native Dlls/SOs for other platforms thatCan support Introspection by the GoDB VM to expose the DLL as an object to GBasic you need to create the DLL that exposes the Standard GDO Introspection functions. For an example of a GDO DLL see GDODLL Template in the Dll Samples.

The VM Loads the DLL and calls these exported functions to identify the properties , methods, functions, Types and parameters supported by the DLL and exposes these to GBasic. GDO dlls can be Instantiated by using the GDO Control in the form. This can be done at the design time by adding the control and Setting the ProgID to the File Name of the Component Or or at runtime by using the Print Command.




Message Hook Dlls

GoDB supports devices that have external Barcode Readers/ RFID Readers etc. To support these devices GoDB has the option of loading Message Hook dlls. Message Hook Dlls are standard dlls that have a predefined set of exported Functions.

Message Hook DLLs should have the following exported functions.
HookGetEventRange(void* hWnd,long *EvStart,long *EvEnd, void** ppData)
HookOnEvent(MSG *msg)
HookFree(void* pData)

When GoDB Starts it looks for gHook.dll in the current directory. If Present GoDB loads the DLL and calls HookGetEventRange. The DLL should return the event range that GoDB should pump to the dll.

When an event is received in the Message Queue that matches this range GoDB Calls
the HookOnEvent(MSG *msg) with the Message Structure.

The DLL can then decode the message and post appropriate translated Message. A typical Example is a Symbol Device that has a Barcode Scanner.

THe GHook.dll Initialises the barcode scanner when it loads and registers with GoDB with the message ID range that is generated when the Scan Button is pressed.

When the user presses the scan button the Message ID since is in the requested range is passed to the gHook.dll. gHook.dll then Uses the BarCode Reader API to read the barcode and posts WM_CHAR message to the HWnd sent by godb in the HookGetEventRange function.

GoDB also has Encryption and Connection Manager Dlls. Refer to the External Processes & DLLs section for more information.



Server Push Functions Using Sockets

GoDB has Functions that can Listen for messages from the server or from other GoDB Applications. To Use the Push Functionality you need to start the Message listener using the MSGLISTNER function.

Currently GoDB supports socket listener. To start the Socket Listener,

MSGLISTENER("START_SOCK:9898")

Where START_SOCK is the command to start the socket listener in the future support for Bluetooth etc will be added, and 9898 is the Port Address where the socket will be listening. When a message is received the FORM_NOTIFY handler is called.

To send a message to the Socket Listener use SendMessage Function.

SendMessage("Sock/127.0.0.1:9898","Hello There")


Send message also takes the parameters of the format [Type]/[Commands]

For Sockets it isSock/[IP address]:[Port]

The second parameter is the message to be sent.

Here we are sending a message to the same machine (127.0.0.1).

To Get Notification you have to write a Form_Notify handler. Form_Notify handler receives all types of notifications from GoDB.The Function GetNotifySrc() should be used to determine the source of the Notification. GetNotifySrc() returns 1 for server messages.

When the notification is received you can use GetMessage Function to retrieve the message from the message queue.

GetMessage Takes 4 parameters, The First parameter returns the numeric Message ID that uniquely identifies the message.

The Second Parameter is the message type which is a string variable that specifies the type and identification of the sender. For socket message this contains the sender IP address.

The third parameter contains the message that was received.

The fourth parameter contains the options for retrieving the message.

Sample Code:


'******************************************************
' Form_Notify Is Called when a Notification Event is Received.
'*******************************************************
sub Form_Notify
if GetNotifySrc()=1 then
print "Server Notification Received"
dimi a
dims b$,c$
for i=1 to 10
if getmessage(a,b$,c$,"")=1 then
print a;b$;c$
else
exitfor
endif
next
update
endif
endsub


Note: For performance reasons a message can contain up to 255 characters.




Server Push Using SMS (Short Message Service) in smartphones.

On Smartphones the MSGLISTNER function can be used to setup a listener for SMS Incoming Messages.

MSGLISTENER("START_SMS") Starts the SMS Listener so when a SMS is received by the phone Form_Notify is called withGetNotifySrc Returning 4. The Form_Notify Event for SMS is


'*************************************************
' Form_Notify Is Called when a Notification
' Event is Received.
'*************************************************
sub Form_Notify
if GetNotifySrc()=11 then
print "SMS Notification Received"
dimi a
dims b$,c$
for i=1 to 10
if getmessage(a,b$,c$,"")=1 then
print a;b$;c$
else
exitfor
endif
next
update
endif
endsub

To Stop the SMS Listener .
MSGLISTENER("STOP_SMS")

To Send an SMS you can use the Send Message Function.
SendMessage("sms/+14250010001","Hello There")

Note: If some other built in program like Inbox is already listening for SMS, you cannot start the SMS.You need to shut it down first and then start the SMS
Listener.

 
  Lesson 7: Syncronization API & XML Parsing


GoDB was designed to support occasionally connected and always connected applications.

Occasionally connected applications are standard rich client applications which can synchronize data and applications to the GoDB Sync server.

You can also create online applications using GoDB. There are two ways to create online applications in GoDB.

Using Forms and using net API.

Using Forms

NOTE: To Execute this sample you need a webserver.

Open the form builder and add a few text boxes. Also add a Submit Button.

Set the URL property of the Submit.box to /gtest/hello.asp.





Open the config page and set the GatewayIP to the IP address of the webserver.

You can do this at compile time by editing Config.ini or at run time by pulling up the config screen (F9 after login in) and changing the GateWay IP and saving. If you select the runtime approach when you rebuild the project you need to set the Gateway IP again.

In the Webserver machine create a directory called gtest and create a page called Hello.asp
in it and copy the following content.

<%

Response.Write Request.ServerVariables("QUERY_STRING") & vbcrlf
Response.Write "Text1 = " & Request("text1") & vbcrlf
Response.Write "Text1 = " & Request("text2") & vbcrlf
Response.Write "Text1 = " & Request("text3") & vbcrlf
Response.Write "<link Name='Link1' value='Go Home' URL='!home.frm'>" & vbcrlf
Response.Write "<link Name='Link2' value='Get More Info' URL='/gtest/Moreinfo.asp'>" & vbcrlf
%>

Compile and Run the Project.



Click on the Submit Button.




You should see the results from the server.

If URL property of the submit button does not start with a / then the BasePath
from the config file is used as the target url.

For example if BasePath is GoDBSS and the URL Property of the Submit Box is gtest.asp then target URL would be http://Server/GoDBSS/gtest.asp

You can also use the Link Control to link to internet pages.

Add a link control to the Form and set the URL to /gtest/hello.asp. When you click on the link you will be taken to the page in the webserver.










NET API

In the previous section we saw how we can connect to a webserver to post values and link to internet pages.

In this section we will see how we can do this from GBasic using net API. The remote site can be a standard website or a webservice.

You can use the HTTPDNLD Api for downloading data from internet site to a local file.

Result = HTTPDNLD(URL,POSTQUERY,FILENAME,ISEXTERNALFILE)

Examples of usage.

'Standard Download
ret=HTTPDNLD("/gtest/hello.asp","text1=v1&text2=v2","test.txt",0)

UnLike the Submit button and the Link Control HttpDNLD can be used to download data from Fully Qualified URLs.

ret=HTTPDNLD("http://www.consigntech.com/gTest/Hello.asp","Text1=v1&Text2=v2",

"test.txt",0)

Downloading Rows to a Table

Result = HTTPDNLDTABLE(URL,POSTQUERY,TABLENAME)

You can use the HTTPDNLDTable api to download a tab delimited file from a webserver and insert it into a local table. The table should exist on the client and the Column count in the downloaded file and the local table should be compatible.

ret=HTTPDNLDTABLE("/gab/default.asp","search=A&viewby=0","TestTable");

print ret
print DB_ERROR$()

Note On Proxies.

In some cases you might have a proxy server in your network.If this is the case you need to get the Port of the proxy server and enter it in the "Port" box. Also enter the Proxy IP in the "ProxyIP" box and finally check "UseProxy".






XML Parser

HttpDnld can be used to download data from normal sites and webservice sites.

When the file is downloaded from a webservice site the resultant file is usually a XML File. You can use the XML api in GoDB to parse the file and extract the information you require.

Example: To reterive market quotes from

http://www.webservicex.net/RealTimeMarketData.asmx/Quote?Symbol=IBM

Create a new form and add a few text box controls and name them Symbol, DateTime,Price,Shares.





Add a button and add the following code in the handler.

Sub Button1_Click

' Add Handler Code Here

url$="http://www.webservicex.net/RealTimeMarketData.asmx/Quote?Symbol="+#symbol$
ret=httpdnld(Url$,"","quote.xml",0)
h=XMLParseFile("quote.XML",0)
ifh<>-1 then
> ret=XMLGoToFirst(h)
while XMLFetch(h,"")=1
print xpath$(h) ; xvalue$(h)
iff xpath$(h)="\\QuoteList\\QuoteLists\\Quote\\Price" then #Price$=xvalue$(h)
iff xpath$(h)="\\QuoteList\\QuoteLists\\Quote\\MatchedShares" then #Shares$=xvalue$(h)
iff xpath$(h)="\\QuoteList\\QuoteLists\\Quote\\DateTime" then #DateTime$=xvalue$(h)
wend
endif
ret=XMLClose(h)

End Sub

Compile and Run the application and Click on the button.








Sync API (GoDB Enterprise Edition)

GoDB has a built in synchronization component to identify modified files, records and seamlessly synchronize them with the GoDB server. The developer doesn't have to write even a single line of code to synchronize files and tables. The developer just needs to map the
files and tables through in the GoDB Sync server admin panel and they automatically get downloaded and updated when the user synchronizes.

There are two ways the client can initiate synchronization. By Opening up the Menu and clicking on Sync.





Or by using the SYNC Api.

Sync([FULLSYNC],[Sync Status Display Level])

if FULLSYNC =0 then Incremental Sync is performed

if FULLSYNC =1 then All the files tables are downloaded from the server and synced locally OVERWRITING all the data on the client.

rem Delta Sync

SYNC(0,3)

rem FULL Sync

SYNC(1,3)

Refer to GoDB Sync Server Manual for an overview of GoDB Synchronization.



HTTP File Uploading.

Just as the HTTPDNLD enables you to download files , you can use the HttpUPLD and HTTPUpldTable apis to upload client files to the server.

Result = HTTPUPLD(URL,POSTQUERY,FILENAME,SERVERFILE,

RETURN_VARIABLE,IsExternalFile)
Ex:

'Internal File

dim a$(10000)

print httpupld("http://default.asp","a=U","SMS.jpg","SMS.jpg",a$,0)

print a$

NOTE: The file is uploaded as a HTTP Upload (HTML <input type=file>) and you need appropriate component on the server to receive and store the file.

You can upload a local table or results of a query to the server similarly using the HttpUpldTable Command.

Result = HTTPUPLDTABLE (URL,POSTQUERY,SQL,SERVERFILE,

COLUMNSEPERATOR,RETURN_VARIABLE)

dim a$(10000)

print httpupldtable("http://Server/default.asp","a=U","select * from customer","table.txt","\t",a$)

print a$

The return Variable holds the contents sent back from the server after upload.

You can implement a complete Sync system using the HTTP Uploading/Downloading api, You can use FATTR function to identify modified files on the client, FCOPY, FDelete and OS_exec to do post sync installation and cleanup tasks.

 
  Lesson 6: Images, Custom Menus, Reading & writing Files and Authentication

Images

GoDB has an in-built Microbrowser which can render forms enabling you to develop rich UI applications with images.

Here are some of the UIs that are possible.



GoDB supports GIF,JPEG and BMP Images.




Select the Images Tab In Project Explorer.

Right Click on internal images and select Add File.

In the Open dialog select the images.



Open Home.Frm, Switch to the Images Tab in the project explorer and drag drop the images into the form.



Reposition the Image fields.



Compile and Run the application.



If you want to see the images rendered in the form builder after you drag and drop them, then click on Menu -> View-> Options. Select Workspace Tab and Check Render Images.



You should be able to see the rendered images in the form builder now.



When the project is compiled the images are converted to a BIN File (GoDB Bitmap Image format) and compiled into the BDB file.

External Images: (Not Recommended for handheld platforms)You also have the option of having the images in an external images folder (Sub-directory
below the BDB directory).

If the platform supports rendering of PNG/JPG/GIF files they can also be placed in
this folder.




Custom Menus


GoDB Has a standard Built in menu. This menu can be brought up by pressing the F1 key or or by clicking at the bottom right corner.



This menu can be changed by loading a custom menu using the strong>LoadMenu Command.

You can use Hierarchal Menus in GoDB.

To Specify a menu you need to form strings that represent each menu item as
MenuID,ParentID,MenuText.

For example a standard Menu would be.

St$=""
St$=St$+"10,0,Test1,"
St$=St$+"11,0,Test2,"
St$=St$+"12,0,Test3,"
St$=St$+"13,0,Test4,"
St$=St$+"14,0,Test5"
LoadMenu(St$)
END

The above code fragment creates the following single level menu



To Display the menu all Show Menu

Sub HelloBtn_Click
ShowMenu()
print GetMenuID()
End
Sub


Two Level Menu.

St$=""

St$=St$+"10,0,Test1,"

St$=St$+"11,0,Test2\x1E,"

St$=St$+"12,0,Test3,"

St$=St$+"13,0,Test4,"

St$=St$+"14,0,Test5,"

St$=St$+"15,11,Test21,"

St$=St$+"16,11,Test22,"

St$=St$+"17,11,Test23,"

St$=St$+"18,11,Test24,"

St$=St$+"19,11,Test25"

LoadMenu(St$)

END

The above code fragment creates a two level menu the first levels have MenuIDs 10-14 and second level menu have MenuIDs 15-19 and you can notice that the second level menu's parent id is 11. This is the Parent MenuID. The \x1E is the character icon for right arrow.



When the user selects the second item, the menu will move the current item to the top and show the second level menu.



Three Level Menu.

St$=""
St$=St$+"10,0,Test1,"
St$=St$+"11,0,Test2\x1E,"
St$=St$+"12,0,Test3,"
St$=St$+"13,0,Test4,"
St$=St$+"14,0,Test5,"
St$=St$+"15,11,Test21,"
St$=St$+"16,11,Test22,"
St$=St$+"17,11,Test23\x1E,"
St$=St$+"18,11,Test24,"
St$=St$+"19,11,Test25,"
St$=St$+"20,17,Test231,"
St$=St$+"21,17,Test232,"
St$=St$+"22,17,Test233,"
St$=St$+"23,17,Test234,"
St$=St$+"24,17,Test235"
LoadMenu(St$)
END








You can press Left or Backspace to go up one level. The Menu Colors can be changed using style files Refer to Lesson 9 for more details.

For applications that need to display the menu programmatically you can use ShowMenu function.

Sub HelloBtn_Click

ShowMenu
print GetMenuID()
End Sub

Showmenu command's first parameter determines if the selected item in the menu is restored or if the menu starts from the first level.

Sub HelloBtn_Click
ShowMenu(1) ' Remember Menu Settings
print GetMenuID()
End Sub

Showmenu command's second and third parameter determines position of the menu.

Sub HelloBtn_Click
ShowMenu(0,10,10) ' Show the menu in the top left corner.
print GetMenuID()
End
Sub

The Important thing to note is that, When a custom menu is loaded the
Standard hotkeys like F1,F7,F9 are disabled.

You can show the menuwhen F1 Key is pressed by handling the OnKeyPressed event.

sub Form_keypress

' If F1 Key is pressed set keyhandled to 2
if getkey()=1 then
showmenu()
endif
EndSub

Reading and Writing Files

GoDB VM was also designed to support devices that do no have file systems. GoDB has its own internal filesystem to store and reterive Forms, Script and Image files. This filesystem is part of the BDB file which shows up as a single file in the native OS.

The File API in GoDB can write to both internal files (into the BDB file - the GoDB File system) or external files (Native OS files).

Files can be opened with the FOpen(Filename,Location,Type) API where the location parameter determines if the file is internal or external.

The Type parameter determines if the file is opened for Reading(1), Writing(2) or Appending(3)




Reading From Files

'/*********************************************/

'/* Read The strings in the file and print */

'/*********************************************/

h1=fopen("test1.txt",0,1)
print "File Handle ",h1
print "Size ",fsize(h1)
while feof(h1)=0
print FREAD$(h1)
wend
ret=fclose(h1)


You can Read from the file using FREAD$ function. This function reads the upto 1024 chars each time.


'/*********************************************/

'/* Read The strings in the file and print */

'/*********************************************/

h1=fopen("test1.txt",0,1)
print "File Handle ",h1
print "Size ",fsize(h1)
while feof(h1)=0
print FREADLN$(h1)
wend
ret=fclose(h1)


To Read Lines you can use the FREADLN$ function.

Writing to Files


h1=fopen("test1.txt",0,2)
b=FWRITE(h1,"test1")
ret=fclose(h1)


You can write to the file using FWrite. This Function writes the contents of a string to a file.


'/*****************************************/

'/* Open and append some text to the file */

'/*****************************************/

h1=fopen("test1.txt",0,3)
a=100
a$="Test"
FPRINT h1,"test1",a,a$
ret=fclose(h1)


You can write to the file using FPrint. This commands writes a line to the file.
This command is similar to print and write to the file instead of to the screen.

Binary Files.

GoDB supports reading from and writing to binary files using the FREADBIN$ and FWRITEBIN functions.

Binary files can have Null chars that GoDB strings can infer as termination characters.

To Avoid this the FreadBin$ escapes the NULL characters in the File with a /00 and a / is escaped as /2f.


'/*********************************************/

'/* Read The strings in the file and print */

'/*********************************************/

h1=fopen("test1.txt",0,1)

while feof(h1)=0
print FREADBIN$(h1)
wend
ret=fclose(h1)



While writing the same rules of escaping applies.

h1=fopen("test1.txt",0,3)
b=FWRITEBIN(h1,"test/00Hello/2Fthere")
ret=fclose(h1)


In some cases where native multimedia apis expect pure binary data, you can use
LoadBlobFile and SaveBlobFile functions.


ret = LoadBlobFile("abc.wav",0,a$)
LoadRet = LoadBlobFile("abc.wav",0,a$)
saveRet = SaveBlobFile("abc.wav",0,a$,LoadRet)


These functions return the number of bytes that was read and should be stored because the String Len Function cannot be used with the strings
returned by these functions

Copying Files

GoDB supports copying of files into and out of the BDB using the FCOPY function


FCOPY(SrcFile,SrcLoc,DestFile,DestLoc).

To copy a file within the bdb use

FCOPY("test1.txt",0,"test2.txt",0)

To copy a file from within the bdb to the external file system use

FCOPY("test1.txt",0,"test2.txt",1)

To copy a file from the external file system to the bdb use

FCOPY("test2.txt",1,"test3.txt",0)

You can also copy files in the external file system using

FCOPY("test2.txt",1,"test3.txt",1)




Authentication - Config.ini and Config.frm

GoDB was designed primarily for business applications that communicate with GoDB Sync server to source data for local tables, download the Frm,Bas and Bin files etc.

For authentication purpose user has to log into the client application and use these credentials during sync process with GoDB Sync server. Information like the UserID,Password, Sync server IP address are held in CONFIG.INI configuration file.

To set the configuration the Config.frm is used. To load the config form you can press F9 in the simulator platforms. On the device the configuration form can be
loaded using the
"?A" URL.<link Name="Link1" Url="?A" Value="Config">

OR From GBasic

LoadURL("?A")




When this form is saved GoDB automatically stores the values in the form to the config.ini.

The Config.ini has the following format.


?A?UID=g&PWD=&USRID=0&IP=127.0.0.1&Port=80&
BP=GoDBSS&UP=&

PI=192.168.0.123&HN=&LOG=

When GoDB starts Logon.frm is loaded from the BDB if present. If not then the default logon page is displayed. The UserID and the Password entered by the user in the logon screen are compared with the ones in the Config.ini. If they match then the user is authenticated and automatically taken to Home.FRM.

The Gateway IP is the ip address of the GoDB Sync server.



Skipping the Logon Page

In some cases you might want to skip the logon page this can be done by AUTHSUCCESS command.

In logon.bas You can add


AUTHSUCCESS
LOADURL("!home.frm")
END

Or you can add custom authentication / Startup screen in the Logon.FRM. When the user clicks on the button you can take the user to the home.frm.

Sub Button1_Click

if CustomAuth()=1 then
AUTHSUCCESS
LOADURL("!home.frm")
Endif
EndSub

Function CustomAuth
CustomAuth=1
End Function

 
  Lesson 5: Advanced Forms Programming

Enumerating the Field Names

To reterive the column names and Column count in a recordset, you can use B_RSFLDCOUNT, DB_RSFLDNAME and DB_RSFLDVAL Functions.

DB_RSFETCH(A,"select * from test",1)
n=DB_RSFLDCOUNT(A)
print " Fld Count ",n
for i=0 to n-1
print " Fld Names ";i;DB_RSFLDNAME$(A,i)
next

while DB_RSISEOF(A)=0

for i=0 to n-1
print DB_RSFLDVAL$(A,i);
next
DB_RSMOVENEXT(A)
wend
DB_RSCLOSE(A)



Advanced Forms Programming.

Form Fields

To ease programming, the fields in a page that have GBasic Script show up as Field Objects. Hence changing the value of the fields in a page can directly the field value. For example if a page contains a text field named USERID then in your gbasic script you can directly set the field value like this.

#USERID$ =
"test"

Notethat form fields are proceeded by a '#'. A $ should be preceded to assign string variables to Form Fields

Example:

#USERID$ =
"Hello"

To assign Numeric variables the $ sign should be omitted

Example:

#USERID=100


NOTE: For all field variables use a # in front of the field name. To update the contents of the text field.



Dynamic Form Controls

GoDB Forms are rendered by the Microbrowser at runtime by parsing the XML Form tags. All controls that are dropped in to a GoDB Form exist as simple XML tags. For Example a text control has the following XML Tag.

<TEXT NAME='UID' VALUE='g' />

As the forms are rendered at run time, you can create controls at run time by just printing the XML Form tags using the print statement.

Sub Button1_Click
print "<text name='test1' value='g'>"
print "<text name='test2' value='g'>"
print "<text name='test3' value='g'>"End Sub
From GoDB 3.6 you can also use CreateObject Command to create objects.
CreateObject(ObjectType,ObjectName,Attrs)

Ex:CreateObject("Text","text1"," Value= 'g' ")




Form Field Arrays

Fields with same names can be accessed as Field Arrays using the '[' Operator.

Ex.:

Print #RAD1[0].checked
Print #RAD1[1].checked
Print #RAD1[2].checked


Events in Field Arrays

When Events are fired in the handler use Curfld$() to get the Field name that generated the Event.
EX: CurFld$ will return the Name of the Control with the index.
For the first control it will be Button1
For the second control it will be Button1[1]
For the third control it will be Button1[2]



Dereferencing Fields Objects


In some cases you might need to refer to a Field variable whose name is determined at runtime in such cases you can use the Field Variable Dereferencing operator {

Ex:


' Variable Name in a string literal
print #{"NAME"} $
' Variable Name in a string variable
b$="NAME"
'As Numeric
print #{b$}
'As String
print #{b$}$
#{b$}$="Hello"
'Accessing Field Properties
print #{b$}.x'Assigning Field Properties
#{b$}.y=100

'Assigning Array Field
b$="VAR[0]"
#{b$}.y=100

b$="Grid1" 'Calling Object Methods
#{b$}.Addrow("Data1,Data2,Data3,Data4,Data5")
' Getting the value of clicked field
b$=CURFLD$()
print #{b$}$



Passing Parameters between Forms

In Some Cases you might want to pass parameters between forms. You can use global variables to achieve this. If
the number of variables is small the you can pass variables in the page URL.

Ex:

LOADURL("!page1.txt&a=10&b=100")
<linkurl="!page1.txt&a=10&b=100">

In the preceding page the variables can be retereived using the REQUEST$ Function

' page1.basPRINT REQUEST$("a")
PRINT REQUEST$("b")

 
Sunday, November 27, 2005
  Lesson 4 -- Database Programming using GoDB

This is applicable only to GoDB Enterprise Edition.

Importing Data From External Database (MS Access) into your GoDB application Grid and LookupTables(LUTs)

GoDB has an embedded ANSI SQL RDBMS. You can create ,modify and query tables using standard SQL statements.

In this chapter lets see how we can import a MS Access MDB file into a GoDB application.




Select Tools->DataAccess -> Import From MSAccess.

This will prompt for the location of the MDB File.

For the sample we have used an MDB file called gsales.mdb located in GoDB Install Directory\palm\access.

Enter the Full path C:\Program Files\GoDB\palm\access\gsales.mdb.

This will import all the tables in the MDB file into GoDB. In GODB the RDBMS tables are stored in a .BDB.DB file. If you named your project gTest then the forms and basic scripts are stored
in gTest.bdb and the RDBMS tables are stored in gTest.bdb.db file. In Platforms that do not
support external files like palm the gTest.bdb.db file is created inside gTest.pdb file along with gTest.bdb.

To View the tables that were imported you can use the GoDB Query Manager.

Select Tools->DataAccess ->Query Manager.





Here enter a sample query select * from City and select Run.



This should show the query results.

Warning: If you select Build -> Clean in GStudio, the Database tables will also be deleted
(the .bdb.db file is deleted). So you will have to import the tables again.

Now that we have the tables lets see how we can use them.



Embedded Grid

In GStudio open home.frm add a embedded grid control.

Embedded grid can be used to display tabular data. The columns are defined in the ColNames attribute and to addrows you can use the AddRow Method.

In home.bas add the following code.

Ex:

#egrid1.ColNames$="Col1,Col2,Col3,Col4"
#egrid1.addRow("r11,r12,r13,r14")
#egrid1.addRow("r21,r22,r23,r24")
#egrid1.addRow("r31,r32,r33,r34")
END

Compile and run.





Sourcing Data for grid from a query. In Home.bas remove the previous code fragment and add

#egrid1.sql$="select * from city"
end

Compile and Run




You can see that the results of the query are now displayed in the grid. Alternatively you can also enter the query in the SQL Attribute in the Property list window.





Full Screen Grid

Full screen grids are used to display query results and occupy the entire screen.
For this insert a Full Screen Grid Control. Change the Value attribute to Results and the SQL attribute to "Select * from emp"

Compile and Run



Click on the control



You can change the SQL attribute from GBasic for different reports.

#grid1.sql$="select * from city"
Full Screen grids can also be displayed from gBasic using the DB_ShowGridcommand



Sub Button1_Click

DB_ShowGrid("select * from emp","Hello There","50,50,100")

End Sub





Lookup Tables (LUTs)

This is one of the most useful and powerful Data controls in GoDB. LUTs are usually used for selecting items in master tables. LUTs require three primary attributes, the TableName, IDField which will be the field that will uniquely identify a row in the table, ShowField The field that will be displayed to the user for filtering and selection.

Into the Home.frm add a LUT Control. Change the Value Attribute to Select Emp

Change the TableName Attribute to Emp

Change the IDField Attribute to EmpID

Change the ShowField Attribute to EmpName





Compile and Run the Project



Click on the Control




Type A



you can see that only the records starting with A are displayed. This is a very powerful feature when you are searching through few thousand records and you want to narrow down data as you type the first few characters.

To Select the row you can double click on the row or select the row and hit ok.



When you print the value for the LUT control from gbasic you will get the IDField Value.


Sub Button1_Click

print #lut1$

End Sub



Lut Data Binding


Lut Field has the capability to populate other controls with the current record value. For example if we might want to display the EmpID and AutoFld columns in the table.

For this add two Readonly controls to the form. Change the First Readonly control's
LutBind Attribute to Lut1 Change the First Readonly control's LutSrcField Attribute to empID



Change the Second Readonly control's LutBind Attribute to Lut1. Change the Second Readonly control's LutSrcField Attribute to AutoFld



Compile and Run the Project



Select the employee Balaji. This will automatically populate the two Readonly controls.





Lut from GBasic

LUTs can be displayed from GBasic using DB_SHOWLUT

Sub Button1_Click
ret=DB_SHOWLUT("select EmpID,EmpName from emp where EmpName like '?%'")
if ret=1 then
print lutselected$()
print lutselname$()
endif
End Sub

DB_SHOWLUT takes a SQL query as a parameter, this query should return two columns the first the IDField and the Second the ShowField. When the Lut is displayedand the ? is the SQL is replaced with the text the user enters. So if the user enters A the sql that would executed will be select EmpID,EmpName from emp where EmpName like 'A%'

DB_SHOWLUT Function returns 1 if the user selected a valid value.

LutSelected$() returns the Selected IDField.

LutSelName$() returns the Selected ShowField.

Database and Forms Programming.

GoDB Database

GoDB has a built in RDBMS that lets you use standard SQL commands to create tables, query data etc.

GBasic Supports two types of Database commands.



DB_EXEC


This command is used for data manipulation . Please note that this command does not return RecordSets. This command can be used for Creating tables, inserting, deleting and updating records etc.

EX:

db_exec("create table test(id int,name varchar(20))",0)

db_exec("insert into test values (1,'test1')",0)

db_exec("insert into test values (2,'test2')",0)

db_exec("insert into test values (3,'test3')",0)

db_exec("insert into test values (4,'test4')",0)

DB_RowsMod function can be used to determine the number of rows a DB_Exec statement affected.

db_exec "update vtable set qty= 100 where price > 10",0

print db_rowsmod()


DB_RSFETCH

This command is used for Data Querying. This command returns a recordset that can be used to get the value for individual columns. This command is used with the SQL Select query statement.

DB_RSFETCH(A,"select * from test",1)

while DB_RSISEOF(A)=0
print @A.id,@A.name$
DB_RSMOVENEXT(A)
wend

DB_RSCLOSE(A)

You will notice the A as the first parameter in the DB_RSFETCH command. This is will be used as the RecordSet Identifier.

GoDB Supports up to 10 con-currently open RECORDSETs named A - J.

Data in the Recordset can be Retrieved in two ways.

Direct Addressing

DB_RSFETCH(A,"select * from test",1)

while DB_RSISEOF(A)=0
print @A.id,@A.name$
DB_RSMOVENEXT(A)
wend
DB_RSCLOSE(A)

InDirect Addressing.

DB_RSFETCH(A,"select * from test",1)
while DB_RSISEOF(A)=0
print @A("id"),@A$("name")
DB_RSMOVENEXT(A)
wend
DB_RSCLOSE(A)

This format helps you use a string expression for the field name.

F1$="ID"
F2$="Name"
print @A(F1$),@A$(F2$)

 
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