SFToHB

 

This project shows how to convert your Satellite Forms application to HB++.

 

This app has all Satellite Forms datatypes, except for TimeStamp.  For simplicity, I did not include code to convert the InkView, but I may add this at a later date.

 

There are two SF forms, List and Item

 

 

 

There are two tables, Items and Globals.

 

 

 

There is one script, in the Item AfterRecordCreate event:

 

Tables().Fields("ID") = Tables("Globals").Fields("ID_ITEM")

Tables("Globals").Fields("ID_ITEM")= Tables("Globals").Fields("ID_ITEM") + 1

 

Tables().Fields("CHAR") = ""

Tables().Fields("DATE") = SysDateToDate(GetSysDate)

Tables().Fields("TIME") = SysTimeToTime(GetSysTime)

Tables().Fields("TF") = False

Tables().Fields("NUMERIC") = ""

 

The List New button filters on the ID field and the Item Done button removes the filter.

 

The project has a creator id of SMS9.  To load the program on the palm, add the following files:

 

 

Add data to the program.

 

 

 

 

We need to create a HB++ program that does the following:

 

Let’s do that now…

 

Open HB++ -> Minimal Project and call it SFToHB. 

 

Open another instance of HB++ and open \HB++\Samples\SatFormsDbReader.  Examine the application.

 

Add the following files to SFToHB:

 

Add a button and a List to frmMain as noted below:

 

 

Add tblItems as noted below:

 

To the 4 standard fields, add Date, Time, String, TF, and Number. Note that I am letting the system create the UniqueID. 

 

 

 

Add a Module, General, and copy and paste the constants found in the SatFormsDbReader into it:

 

Public const iTypeString as byte = &H43

Public const iTypeBoolean as byte = &H4C

Public const iTypeDate as Byte=&H44

Public const iTypeTime as Byte          =&H54

Public const iTypeNumeric as Byte = &H4E

Public const iTypeInk as Byte = &H47

 

Copy and paste the following code into frmMain.

 

'===============================================================

' SFToHB - frmMain

'===============================================================

 

'===============================================================

' PRIVATE MEMBERS

'===============================================================

 

Private rs as tblItems

 

'===============================================================

' FORM EVENTS

'===============================================================

 

Private Sub Form_Load()

            set rs = new tblItems

            rs.OpenTable hbModeOpenAlways+hbModeReadWrite

End Sub

 

Private Sub Form_Unload()

            rs.Close

End Sub

 

'===============================================================

' BUTTON EVENTS

'===============================================================

Private Sub Button1_Click()

            Dim sfDB as New clsSatFormDB

            'Dim sfRc as New clsSatFormRecord

            'Dim sfField as New clsSatFormField

            Dim i as Integer

            Dim di as new DatabaseInfo

 

            on error goto Err_Import

 

            If di.FindByName("ESMS90100_ITEMS") Then

                        sfDB.Open di.Name,hbModeOpenExisting+hbModeReadOnly

                        For i=0 to sfDB.RecordCount-1

                                    rs.OpenTable hbModeReadWrite+hbModeOpenExisting

                                    rs.AddNew

                                    rs.Date= sfDB.Record(i).HField("DATE").Value

                                    rs.Time= sfDB.Record(i).HField("TIME").Value

                                    rs.String= sfDB.Record(i).HField("CHAR").Value

                                    rs.TF = sfDB.Record(i).HField("TF").Value

                                    rs.Number = sfDB.Record(i).HField("NUMERIC").Value

                                    rs.Update

                                    'If you have related records, you need to obtain the UniqueID and

                                    'then start another loop. New records are added at the end, so

                                    'MoveLast and then obtain  the UniqueID. 

                                    'This behavior may have changed with version 1.05, so test it if you

                                    'use this function.

                                    'rs.MoveLast

                                    'msgbox rsPatients.UniqueID

                        Next i

                        sfDB.Close

                        di.Delete

            End if

 

            If di.FindByName("ESMS90100_GLOBALS") then

                        di.Delete

            End If

            If di.FindByName("ESMS90100#DATATYPE") then

                        di.Delete

            End If

            If di.FindByName("ESMS90100$DATATYPE") then

                        di.Delete

            End If

            If di.FindByName("Datatype") then

                        di.Delete

            End If

 

            'Note:  do not delete the SF runtime unless you are certain there are

            'no other SF applications on the Palm

 

            FillList

 

            exit sub

 

Err_Import:

Msgbox "err=" & err.Description

 

End Sub

 

'===============================================================

' PRIVATE SUBS AND FUNCTIONS

'===============================================================

 

Private Sub FillList()

            lstView.Redraw = False

            lstView.Clear

            If rs.RecordCount>0 Then

                        rs.MoveFirst

                        While Not rs.EOF

                                    lstView.AddItem rs.String, rs.UniqueID

                                    rs.MoveNext

                        Wend

            End If

            lstView.Redraw = True

End Sub

 

Private Sub lstView_PenUp(ByVal x As Integer, ByVal y As Integer)

            dim lUniqueID as Long

 

            lUniqueID = lstView.ItemData(lstView.ListIndex)

            rs.LookupUniqueId(lUniqueID)

            msgBox "DATE = " & rs.Date & "| TIME = " & rs.Time & "| TF = " & rs.TF & "| NUMERIC = " & rs.Number

End Sub

 

 

Load both programs, make sure there is data in the SF program, then click the button on the HB++ app.  Your converted data will appear in the list.  You can click the list item to see other information in the record.

 

 

On the Palm, you can see that your SF app is no longer visible.  If you use FileZ or RscrEdit, you will see that the SF Runtime is still present.  Also note that the date and time have the same format in HB++, ie seconds from 1/1/04, so they will need to be formatted correctly for display.

 

 

If you note any errors in the above article, please let me know.

 

Jon Blackman

jab@easystreet.com

 

Last modified 10/17/04