File fhutils - function createResultTable

createResultTable

Provides an easier way to work with standard result sets, especially when working with multiple columns

Sample Usage


    fhu = require("fhUtils")
    local tblResults = fhu.createResultTable()
    -- Define Columns
    tblResults.indi  = {title='Record'}
    tblResults.id    = {title='id',type='integer',align='align_right',width=20} 
    tblResults.death = {title='Death'}
    tblResults.name  = {title='Name',type='text'}
    tblResults.birth = {title='Birth',width=40}
    
    pi = fhNewItemPtr() -- declare pointer
    pi:MoveToFirstRecord("INDI") -- and set to the first record.
    while pi:IsNotNull() do
        -- Add Row
        tblResults:newRow()
        -- Set Columns
        tblResults.indi:set(pi:Clone())
        tblResults.name:set(fhGetDisplayText(pi))
        tblResults.birth:set(fhGetItemPtr(pi,'~.BIRT.DATE'))
        tblResults.death:set(fhGetItemPtr(pi,'~.DEAT.DATE'))
        tblResults.id:set(fhGetRecordId(pi)) 
        pi:MoveNext()
    end
    fhOutputResultSetTitles("All Individuals", "All Individuals", "Item List Example Date: %#x")
    tblResults:outputResults()
getParam (sTitle, sTopMessage, fields, tButtons, shortcuts, hParent)
This function allows a dynamic prompt box to be created with 5 different line types with a variety of controls for ranges and prompting.

Defining Columns

Define each column by simply adding a table as the column

For more information on the column values please see the function help for fhOutputResultSetColumn. The table can contain

  • title: The column title
  • type: The type text|number|item
  • width: required column width
  • alignment: align_left - column is left aligned | align_right - Column is right aligned | align_mid - Column is centered
  • sort: sort order
  • sortAscending: true/false
  • sortType: default
  • visibility: show|hide

All values other than the title are optional

Setting a Column

To set the value for the column simply call the set function on the column passing the value required.

tblResults.id:set(fhGetRecordId(pi))

Outputing the Results

First call fhOutputResultSetTitles to set the titles and then call

tblResults:outputResults()

Row Count

The count of rows can be accessed at any point using the function.

tblResults:rowCount()