Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
*-- A class that allows easy read/write access to INI files.
*
DEFINE CLASS cinifile AS csystemsetting
Width = 152
Height = 19
Name = "cinifile"
*-- The name of the INI file to read/write to. Initialized in Init(), but can be overridden in Set() or Get().
PROTECTED cinifile
PROCEDURE set
LPARAMETERS tcSection, tcEntryName, tuValue, tcINIFile
LOCAL lcINIFile, ;
lcValue
*-- Make sure we passed in a value to store
IF PCOUNT() < 3
RETURN .F.
ENDIF
*-- Convert value to character if necessary
IF TYPE("tuValue") <> "C"
*-- Try to convert the value to character
lcValue = STR(tuValue)
ELSE
lcValue = tuValue
ENDIF
*-- Use tcINIFile if passed
IF PCOUNT() < 4 OR TYPE("tcINIFile") <> "C"
lcINIFile = this.cINIFile
ELSE
lcINIFile = tcINIFile
ENDIF
IF UPPER(lcINIFile) = "WIN.INI"
lnResult = WriteProfileString(tcSection, tcEntryName, lcValue)
ELSE
lnResult = WritePrivateProfileString(tcSection, tcEntryName, lcValue, lcINIFile)
ENDIF
RETURN (lnResult = TRUE)
ENDPROC
PROCEDURE get
LPARAMETERS tcSection, tcEntryName, tuDefault, tcINIFile
LOCAL lcINIFile, ;
lcValue, ;
lcBuffer, ;
luEntryValue, ;
lnNumBytes
*-- Setup default value
IF PCOUNT() >= 3
luEntryValue = tuDefault
ELSE
luEntryValue = ""
ENDIF
*-- Use tcINIFile if passed
IF PCOUNT() < 4 OR TYPE("tcINIFile") <> "C"
lcINIFile = this.cINIFile
ELSE
lcINIFile = tcINIFile
ENDIF
lcBuffer = SPACE(255) + CHR(0)
IF UPPER(lcINIFile) = "WIN.INI"
lnNumBytes = GetProfileString(tcSection, tcEntryName, "", ;
@lcBuffer, LEN(lcBuffer))
ELSE
lnNumBytes = GetPrivateProfileString(tcSection, tcEntryName, "", ;
@lcBuffer, LEN(lcBuffer), lcINIFile)
ENDIF
IF lnNumBytes = 0
RETURN luEntryValue
ELSE
RETURN LEFT(lcBuffer, lnNumBytes)
ENDIF
ENDPROC
PROCEDURE Init
LPARAMETERS tcINIFile
*-- DECLARE DLL statements for reading/writing to private INI files
DECLARE INTEGER GetPrivateProfileString IN Win32API ;
String cSection, String cKey, String cDefault, String @cBuffer, ;
Integer nBufferSize, String cINIFile
DECLARE INTEGER WritePrivateProfileString IN Win32API ;
String cSection, String cKey, String cValue, String cINIFile
*-- DECLARE DLL statements for reading/writing to WIN.INI file
DECLARE INTEGER GetProfileString IN Win32API ;
String cSection, String cKey, String cDefault, ;
String @cBuffer, Integer nBufferSize
DECLARE INTEGER WriteProfileString IN Win32API ;
String cSection, String cKey, String cValue
IF PCOUNT() >= 1
this.cINIFile = tcINIFile
ELSE
this.cINIFile = "WIN.INI"
ENDIF
ENDPROC
ENDDEFINE