Wednesday, November 22, 2006

New release

I have uploaded UW345.dot.
You can download it from my downloads page at http://www.chrisgreaves.com/Downloads/

Friday, November 17, 2006

New release

I have uploaded UW345.dot.
You can download it from my downloads page at http://www.chrisgreaves.com/Downloads/

Thursday, November 02, 2006

Sectioning an INI file

Nothing complex about it. (But see also Using An INI File).

We want to store data that reflects our run-time in a file quite separate from the program. INI files have been around for a long time. They are text files, and a reasonably competent user can edit them. A reasonably competent designer (like you!) can build a GUI form for a user interface.

Our application has two distinct phases the CORE and the RIM, and we would like to park INI keys and values in separate sections, one section to be called [CORE] and the other section to be called [RIM].

In the sample code below I have used literal character strings; you will, of course, prefer to use string constants.

References

Set a reference to the utility library UW.DOT from within your project.

Constants

In your constants module, declare two public constants:
Public Const strcApplication As String = "MyTest"

Program code

In a module write a very simple test macro:

Sub test()
Dim strEnv As String
strEnv = UW.strEnvironmentFactual(strcApplication)
MsgBox UW.strprofilein(strEnv, "CORE", "1stKey", "1stValue")
MsgBox UW.strprofilein(strEnv, "RIM", "1stKey", "2ndValue")
End Sub


Testing the code

Run the little test macro.

You will observe pop-up message boxes bearing the strings "1stValue" and "2ndValue".
The INI file
In your Documents and settings folder locate the file Utils.INI.

Its contents should look like this:
[CORE]
1stKey=1stValue
[RIM]
1stKey=2ndValue