| Stonefield Query SDK |
| Application.AfterSetup |
Note: the Application.AfterSetup script is not called if a report is run from the Windows command line or another application and you specify the EXIT option (see the Running From Other Applications topic in the Stonefield Query help file, SFQUERY.CHM, for details). That's because the report is run before that script executes and then Stonefield Query terminates because of the EXIT option. If you need setup tasks performed even under these conditions, use Application.BeforeSetup instead.
Parameters
A reference to the Stonefield Query Application object.
Return Value
True if the application should continue, False if it should terminate.
Example
This example retrieves a tax rate from a single-record "constants" table using the ExecuteSQLStatement method and stores it in a new property of the Application object so it can be used in other scripts, such as those called from calculated fields. Those scripts simply refer to SQApplication.TaxRate to retrieve that value. The benefit of doing this in Application.AfterSetup is that it only executes once; doing this in a calculated field script causes the constants table to be accessed to retrieve the same value many times.
Visual FoxPro
lparameters toApplication as SQApplication
local loDatabase as Database, lcSelect, llReturn
loDatabase = toApplication.DataEngine.Databases.GetMainDatabase()
lcSelect = 'select TAXRATE from CONSTANTS'
llReturn = not empty(loDatabase.ExecuteSQLStatement(lcSelect, ;
'', 'CONSTANTS'))
if llReturn
toApplication.AddProperty('TaxRate', CONSTANTS.TAXRATE)
endif
return llReturn VBScript
function Main(Application)
dim Database, XMLDOM
set Database = Application.DataEngine.Databases.GetMainDatabase()
SelectStmt = "select TAXRATE from CONSTANTS"
Results = Database.ExecuteSQLStatement(SelectStmt)
set XMLDOM = createobject("MSXML.DOMDocument")
XMLDOM.ASync = False
XMLDOM.LoadXML(Results)
TaxRate = XMLDOM.selectSingleNode("/DataSet/_resultset/taxrate").Text
Application.AddProperty("TaxRate", TaxRate)
Main = True
end function JavaScript
function Main(Application) {
var Database, SelectStmt, Results, XMLDOM, TaxRate ;
Database = Application.DataEngine.Databases.GetMainDatabase() ;
SelectStmt = 'select TAXRATE from CONSTANTS' ;
Results = Database.ExecuteSQLStatement(SelectStmt) ;
XMLDOM = new ActiveXObject('MSXML.DOMDocument') ;
XMLDOM.ASync = false ;
XMLDOM.LoadXML(Results) ;
TaxRate = XMLDOM.selectSingleNode('/DataSet/_resultset/taxrate').Text ;
Application.AddProperty('TaxRate', TaxRate) ;
return true ;
}See Also
Application.BeforeSetup | Application.Shutdown | Scripts
| Last Updated: 02/11/2008 |