| Stonefield Query SDK |
| SetINIValue |
Syntax
SetINIValue(INIFile as String, Section as String, Entry as String, Value as String) as Boolean
Parameters
INIFile
The fully-qualified path to the INI file.
Section
The section in the INI file where the value is stored (if the section doesn't exist, it's added).
Entry
The name of the entry for the value (if the entry doesn't exist, it's added).
Value
The value to store.
Return Value
True if the value was stored or False 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 | GetINIValue | SetRegistryValue
| Last Updated: 02/05/2008 |