| Stonefield Query SDK |
| GetINIValue |
Syntax
GetINIValue(INIFile as String, Section as String, Entry as String [, DefaultValue as String]) as String
Parameters
INIFile
The fully-qualified path to the INI file.
Section
The section in the INI file where the value can be found.
Entry
The name of the entry to return the value for.
DefaultValue
The value to return if the specified entry isn't found. Optional; if it isn't specified and the entry doesn't exist, an empty string is returned.
Return Value
The value in the INI file if it was found or a blank string (or the value of DefaultValue if it's specified) if not.
Example
Here's an example that retrieves the location for the AR tables from the AR Location entry in the [Custom Settings] section of the SFQUERY.INI file for the project. If the entry is blank (such as when this code is executed for the first time), the user is prompted for the value and it's stored in the INI file. This code goes into the DataEngine.GetCustomMetaData script.
Visual FoxPro
lparameters toApplication as SQApplication
local lcINIFile, lcLocation, lnI, loTable as Table
lcINIFile = toApplication.ProjectDirectory + 'SFQUERY.INI'
lcLocation = toApplication.GetINIValue(lcINIFile, ;
'Custom Settings', 'AR Location')
if empty(lcLocation)
lcLocation = toApplication.PromptUserForValue('Location of AR Tables')
toApplication.SetINIValue(lcINIFile, ;
'Custom Settings', 'AR Location', lcLocation)
endif
if not empty(lcLocation)
for lnI = 1 to toApplication.DataEngine.Tables.Count
loTable = toApplication.DataEngine.Tables.Item(lnI)
do case
case left(loTable.Alias, 2) <> 'AR'
case lcValue = 'Y'
loTable.Location = lcLocation
otherwise
loTable.Reportable = .F.
endcase
next
endif VBScript
function Main(Application)
dim Table
INIFile = Application.ProjectDirectory + "SFQUERY.INI"
Location = Application.GetINIValue(INIFile, "Custom Settings", _
"AR Location")
if Location = "" then
Location = Application.PromptUserForValue("Location of AR Tables")
Application.SetINIValue INIFile, _
"Custom Settings", "AR Location", Location
end if
if Location <> "" then
for I = 1 to Application.DataEngine.Tables.Count
set Table = Application.DataEngine.Tables.Item(I)
if left(Table.Alias, 2) = "AR" then
if Value = "Y" then
Table.Location = Location
else
Table.Reportable = False
end if
end if
next
end if
end function JavaScript
function Main(Application) {
var INIFile, Location, I, Table ;
INIFile = Application.ProjectDirectory + 'SFQUERY.INI' ;
Location = Application.GetINIValue(INIFile, 'Custom Settings',
'AR Location') ;
if (Location = '') {
Location = Application.PromptUserForValue('Location of AR Tables') ;
Application.SetINIValue(INIFile,
'Custom Settings', 'AR Location', Location) ;
}
if (Location <> '') {
for (I = 1; I <= Application.DataEngine.Tables.Count; I++) {
Table = Application.DataEngine.Tables.Item(I) ;
if (left(Table.Alias, 2) = 'AR') {
if (Value = 'Y') {
Table.Location = Location ;
}
else {
Table.Reportable = false ;
}
}
}
}
}See Also
Application Object | GetRegistryValue | SetINIValue
| Last Updated: 02/05/2008 |