[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 Class TIniFile
 It provides IniFile Objects to automatically manage INI Files
--------------------------------------------------------------------------------

 Description

 INI Files are becoming the standard files for storing random and
 configuration information. Microsoft is making an extended use of them
 in all their products.

 An INI file is an ASCII file that uses INI as the extension filename.
 The general structure of a INI File is:

 [SECTION1]
 ENTRY1=VALUE
 ENTRY2=VALUE
 ...

 [SECTION2]
 ENTRY1=VALUE
 ENTRY2=VALUE
 ...

 As a example let's have a look at Microsoft Windows WIN.INI File:

 [windows]
 spooler=yes
 load=
 run=
 Beep=Yes
 NullPort=None
 BorderWidth=3
 CursorBlinkRate=350
 DoubleClickSpeed=508
 Programs=com exe bat pif
 Documents=doc txt wri xls xlc sam jw jwt tg1
 ...


 They are very easy to use as you can modify them using any text editor,
 so you do not need any specialized tool. But from inside your programs
 the situation is quite different. Microsoft Windows API provides some
 functions to automatically manage them, but accesing them from Clipper
 can be quite complicated, until now!

 TIniFile Objects lets you easily manage INI files. You just have to
 USE them, and you can Set or Get any of its entries values. When you
 finish using them, you can save them to disk storing your modifications.

 To create a IniFile Object you assign:

      local oIniFile := TIniFile()

 but that Object it is not ready to use as it has not been inicialized.
 To inicialize it, you send it a message requesting the action of a Method
 Constructor:

      oIniFile:Use( "MyApp.ini" )

      or you can do both at the same time:

      local oIniFile := TIniFile():Use( "MyApp.ini" )

 As :Use( cIniFileName ) is a method constructor, it will return a reference
 to Self.

 Now you can perform any operation on the INI File. You can :Set() or :Get
 any of its values. Remember that a INI file only stores strings. So if you
 stores any number remember to STR()ingify it after :cGET()ting it.

 You can review the IniFile Object using the debugger as you normally do
 with Clipper standard Classes. From inside the debugger press Alt-M to
 review memory variables. Then select L for locals. Using TAB select the
 variables window. Then place the highligh bar over the name of your
 Object variable and press Enter. The Debugger Object Inspector will show
 you all the information stored at the Object exported instance variables.

   File   Locate   View   Run   Point   Monitor   Options   Window   Help
################################ Monitor: Local ################################
#0) OINI <Local, O>: { ... }                                                   #
#1) N <Local, U>: NIL                                                          #
#############+----------------------------------------------------+#############
+------------|                       OINI                         |------------+
|20:      CLS|                                                    |            |
|21:         | Object                                             |            |
|22:    +--------------------------------------------------------------+;      |
|23:    |                            OINI                              |       |
|24:    |                                                              |       |
|25:    | ALINES    { ... }                                            |() + 1 |
|26:    | CENTRY    "message"                                          |       |
|27:    | CFILENAME "MyApp.ini"                                        |       |
|28:    | CSECTION  "colors"                                           |       |
|29:    | CVALUE    "GR+/BG"                                           |       |
|30:    | NFOUNDAT  11                                                 |       |
|31:    | NSECTIONS 5                                                  |       |
|32:    +--------------------------------------------------------------+       |
+------------------------------------------------------------------------------+

 The IniFile Object contains an array with all the text lines of the INI
 file. You should perform on it any operation you want. But the easiest
 way is to use Set() and Get() methods.

 When you :cGet() a value, you should specify a default value, so if
 that entry is not found it will be created with the default value.

   File   Locate   View   Run   Point   Monitor   Options   Window   Help
################################ Monitor: Local ################################
#0) OINI <Local, O>: { ... }                                                   #
#1) N <+---------------------------------------------------------------+       #
#######|                         ALINES[1..18]                         |########
+------|                                                               |-------+
|20:   | ALINES[1]  "[main]"                                           |       |
|21:   | ALINES[2]  "title=The title of my program"                    |       |
|22:   | ALINES[3]  "colors=W+/B, W+/R,,,N/BG"                         |;      |
|23:   | ALINES[4]  "message=Main message of my program"               |       |
|24:   | ALINES[5]  ""                                                 |       |
|25:   | ALINES[6]  "[users]"                                          |() + 1 |
|26:   | ALINES[7]  "supervisor=PASSWORD"                              |       |
|27:   | ALINES[8]  ""                                                 |       |
|28:   | ALINES[9]  "[colors]"                                         |       |
|29:   | ALINES[10] "title=GR+/RB"                                     |       |
|30:   | ALINES[11] "message=GR+/BG"                                   |       |
|31:   | ALINES[12] ""                                                 |       |
|32:   | ALINES[13] "[MainMenu]"                                       |       |
+------| ALINES[14] "Item1=My Clients"                                 |-------+
+------| ALINES[15] "Item2=My Accounts"                                |-------+
|      | ALINES[16] ""                                                 |       |
|      | ALINES[17] "[Clients]"                                        |       |
|>     | ALINES[18] "Dbf=Clients.dbf"                                  |       |
+------+---------------------------------------------------------------+-------+

 To Save the INI File to disk you send the message :Save(). And if you
 have finish using the INI file you send the message :Use() with no
 arguments so the internal memory of the Object gets freed.

 Enjoy!

 ------------------------------------------------------------------------------


 This Class has been completely design and written using C language and
 Clipper internal functions. That means that you have very little size,
 no overhead and fastest execution.

 License

 We give this Class as try before buy. This is _not_ a demo. It works with
 no limits. If you want to get the sources to learn how to code your own
 Classes using C -and/or Clipper- and obtain support, send 30 US$ (plus
 $3 if outside of Spain) to:

                                RUNsoft
                             M.laga 40, 3.
                          29600 Marbella (MA)
                                 Spain

 We will explain you some very interesting tricks to design Classes and
 how to handle Objects from within C. Your code will run incredibly fast!

This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson