home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / clipper / oini.zip / INIFILE.DOC < prev    next >
Text File  |  1993-05-30  |  13KB  |  341 lines

  1.  
  2.  
  3.              ┌─────────────────────────────────────────────────┐
  4.              │          TIniFile Class for CA-Clipper          │█
  5.              │            (c) Antonio Linares, 1993            │█
  6.              └─────────────────────────────────────────────────┘█
  7.  
  8.  
  9.  
  10. Printout of `TIniFile Class for CA-Clipper'
  11. Printed by the Norton Guides Printer v2.0 (NGP.EXE).
  12.  
  13.  
  14.                                  - Page 1 -
  15. Norton Guide: `TIniFile Class for CA-Clipper'
  16.  
  17.  
  18. Menu List: TIniFile Class, Sintax
  19.  
  20.  
  21.  
  22.  Class TIniFile
  23.  It provides IniFile Objects to automatically manage INI Files
  24. ────────────────────────────────────────────────────────────────────────────────
  25.  
  26.  Description
  27.  
  28.  INI Files are becoming the standard files for storing random and
  29.  configuration information. Microsoft is making an extended use of them
  30.  in all their products.
  31.  
  32.  An INI file is an ASCII file that uses INI as the extension filename.
  33.  The general structure of a INI File is:
  34.  
  35.  [SECTION1]
  36.  ENTRY1=VALUE
  37.  ENTRY2=VALUE
  38.  ...
  39.  
  40.  [SECTION2]
  41.  ENTRY1=VALUE
  42.  ENTRY2=VALUE
  43.  ...
  44.  
  45.  As a example let's have a look at Microsoft Windows WIN.INI File:
  46.  
  47.  [windows]
  48.  spooler=yes
  49.  load=
  50.  run=
  51.  Beep=Yes
  52.  NullPort=None
  53.  BorderWidth=3
  54.  CursorBlinkRate=350
  55.  DoubleClickSpeed=508
  56.  Programs=com exe bat pif
  57.  Documents=doc txt wri xls xlc sam jw jwt tg1
  58.  ...
  59.  
  60.  
  61.  They are very easy to use as you can modify them using any text editor,
  62.  so you do not need any specialized tool. But from inside your programs
  63.  the situation is quite different. Microsoft Windows API provides some
  64.  functions to automatically manage them, but accesing them from Clipper
  65.  can be quite complicated, until now!
  66.  
  67.  TIniFile Objects lets you easily manage INI files. You just have to
  68.  USE them, and you can Set or Get any of its entries values. When you
  69.  finish using them, you can save them to disk storing your modifications.
  70.  
  71.  To create a IniFile Object you assign:
  72.  
  73.  
  74.                                  - Page 2 -
  75. Norton Guide: `TIniFile Class for CA-Clipper'
  76.  
  77.  
  78.       local oIniFile := TIniFile()
  79.  
  80.  but that Object it is not ready to use as it has not been inicialized.
  81.  To inicialize it, you send it a message requesting the action of a Method
  82.  Constructor:
  83.  
  84.       oIniFile:Use( "MyApp.ini" )
  85.  
  86.       or you can do both at the same time:
  87.  
  88.       local oIniFile := TIniFile():Use( "MyApp.ini" )
  89.  
  90.  As :Use( cIniFileName ) is a method constructor, it will return a reference
  91.  to Self.
  92.  
  93.  Now you can perform any operation on the INI File. You can :Set() or :Get
  94.  any of its values. Remember that a INI file only stores strings. So if you
  95.  stores any number remember to STR()ingify it after :cGET()ting it.
  96.  
  97.  You can review the IniFile Object using the debugger as you normally do
  98.  with Clipper standard Classes. From inside the debugger press Alt-M to
  99.  review memory variables. Then select L for locals. Using TAB select the
  100.  variables window. Then place the highligh bar over the name of your
  101.  Object variable and press Enter. The Debugger Object Inspector will show
  102.  you all the information stored at the Object exported instance variables.
  103.  
  104.    File   Locate   View   Run   Point   Monitor   Options   Window   Help
  105. █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ Monitor: Local ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
  106. █0) OINI <Local, O>: { ... }                                                   █
  107. █1) N <Local, U>: NIL                                                          █
  108. █▄▄▄▄▄▄▄▄▄▄▄▄┌────────────────────────────────────────────────────┐▄▄▄▄▄▄▄▄▄▄▄▄█
  109. ┌────────────│                       OINI                         │────────────┐
  110. │20:      CLS│                                                    │            │
  111. │21:         │ Object                                             │            │
  112. │22:    ┌──────────────────────────────────────────────────────────────┐;      │
  113. │23:    │                            OINI                              │       │
  114. │24:    │                                                              │       │
  115. │25:    │ ALINES    { ... }                                            │() + 1 │
  116. │26:    │ CENTRY    "message"                                          │       │
  117. │27:    │ CFILENAME "MyApp.ini"                                        │       │
  118. │28:    │ CSECTION  "colors"                                           │       │
  119. │29:    │ CVALUE    "GR+/BG"                                           │       │
  120. │30:    │ NFOUNDAT  11                                                 │       │
  121. │31:    │ NSECTIONS 5                                                  │       │
  122. │32:    └──────────────────────────────────────────────────────────────┘       │
  123. └──────────────────────────────────────────────────────────────────────────────┘
  124.  
  125.  The IniFile Object contains an array with all the text lines of the INI
  126.  file. You should perform on it any operation you want. But the easiest
  127.  way is to use Set() and Get() methods.
  128.  
  129.  When you :cGet() a value, you should specify a default value, so if
  130.  that entry is not found it will be created with the default value.
  131.  
  132.    File   Locate   View   Run   Point   Monitor   Options   Window   Help
  133.  
  134.                                  - Page 3 -
  135. Norton Guide: `TIniFile Class for CA-Clipper'
  136.  
  137.  
  138. █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ Monitor: Local ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
  139. █0) OINI <Local, O>: { ... }                                                   █
  140. █1) N <┌───────────────────────────────────────────────────────────────┐       █
  141. █▄▄▄▄▄▄│                         ALINES[1..18]                         │▄▄▄▄▄▄▄█
  142. ┌──────│                                                               │───────┐
  143. │20:   │ ALINES[1]  "[main]"                                           │       │
  144. │21:   │ ALINES[2]  "title=The title of my program"                    │       │
  145. │22:   │ ALINES[3]  "colors=W+/B, W+/R,,,N/BG"                         │;      │
  146. │23:   │ ALINES[4]  "message=Main message of my program"               │       │
  147. │24:   │ ALINES[5]  ""                                                 │       │
  148. │25:   │ ALINES[6]  "[users]"                                          │() + 1 │
  149. │26:   │ ALINES[7]  "supervisor=PASSWORD"                              │       │
  150. │27:   │ ALINES[8]  ""                                                 │       │
  151. │28:   │ ALINES[9]  "[colors]"                                         │       │
  152. │29:   │ ALINES[10] "title=GR+/RB"                                     │       │
  153. │30:   │ ALINES[11] "message=GR+/BG"                                   │       │
  154. │31:   │ ALINES[12] ""                                                 │       │
  155. │32:   │ ALINES[13] "[MainMenu]"                                       │       │
  156. └──────│ ALINES[14] "Item1=My Clients"                                 │───────┘
  157. ┌──────│ ALINES[15] "Item2=My Accounts"                                │───────┐
  158. │      │ ALINES[16] ""                                                 │       │
  159. │      │ ALINES[17] "[Clients]"                                        │       │
  160. │>     │ ALINES[18] "Dbf=Clients.dbf"                                  │       │
  161. └──────└───────────────────────────────────────────────────────────────┘───────┘
  162.  
  163.  To Save the INI File to disk you send the message :Save(). And if you
  164.  have finish using the INI file you send the message :Use() with no
  165.  arguments so the internal memory of the Object gets freed.
  166.  
  167.  Enjoy!
  168.  
  169.  ------------------------------------------------------------------------------
  170.  
  171.  
  172.  This Class has been completely design and written using C language and
  173.  Clipper internal functions. That means that you have very little size,
  174.  no overhead and fastest execution.
  175.  
  176.  License
  177.  
  178.  We give this Class as try before buy. This is _not_ a demo. It works with
  179.  no limits. If you want to get the sources to learn how to code your own
  180.  Classes using C -and/or Clipper- and obtain support, send 30 US$ (plus
  181.  $3 if outside of Spain) to:
  182.  
  183.                                 RUNsoft
  184.                              Málaga 40, 3º
  185.                           29600 Marbella (MA)
  186.                                  Spain
  187.  
  188.  We will explain you some very interesting tricks to design Classes and
  189.  how to handle Objects from within C. Your code will run incredibly fast!
  190.  
  191. ───────────────────────────────────────────────────────────────────────────────
  192.  
  193.  
  194.                                  - Page 4 -
  195. Norton Guide: `TIniFile Class for CA-Clipper'
  196.  
  197.  
  198.  Object Creation
  199.  
  200.  
  201.  
  202.  
  203.  
  204.    TIniFile()  --> IniFile Object not inicialized
  205.  
  206.    TIniFile():Use( cIniFileName )  --> IniFile Object Inicialized,
  207.                                        ready to be used
  208.  
  209. ───────────────────────────────────────────────────────────────────────────────
  210.  
  211.  Exported Instance Variables
  212.  
  213.  
  214.  
  215.  aLines                           Text lines of the INI File            ASSIG
  216.  
  217.  cSection                         [cSection]      from last Set or Get
  218.  
  219.  cEntry, cValue                   cEntry = cValue   "   "    "      "
  220.  
  221.  nFoundAt                         cEntry is located at nFoundAt line
  222.  
  223.  nSections                        Number of sections in a INI File
  224.  
  225. ───────────────────────────────────────────────────────────────────────────────
  226.  
  227.  Exported Methods
  228.  
  229.  
  230.  
  231.  Use( cIniFileName )                     Uses a INI File          CONSTRUCTOR
  232.  
  233.  Set( cSection, cEntry, cValue )         Set  a INI value
  234.  
  235.  cGet( cSection, cEntry [, cDefault ] )  Get  a INI value
  236.  
  237.  Save()                                  Save the INI file to disk
  238.  
  239.  Use()                                   End using the INI file
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.                                  - Page 5 -
  254. Norton Guide: `TIniFile Class for CA-Clipper'
  255.  
  256.  
  257. Menu Choice: TIniFile Class, About
  258.  
  259.  
  260.  
  261.    (c) 1.993 RUNsoft
  262.    Written by Antonio Linares
  263.  
  264.    Specially thanks to Mr. Octopus -Francisco Pulpón-
  265.  
  266.    Soon, more Classes coming...
  267.  
  268.          TGraph()   Object Oriented Bussines graphics for Clipper
  269.          TText()    Full featured Word processing with color sintax
  270.                     highlighting, functions review 'a la Visual Objects',
  271.                     no limit size, and more...
  272.  
  273.  
  274.    No external OOPS libraries, just pure OOPS/C/Clipper code!
  275.  
  276.    inifile.obj has been coded using Borland C++ 3.1
  277.    __Ini.obj   has been coded using CA-Clipper 5.1
  278.  
  279.   ┌─ Registration form ─────────────────────────────────────────────────────┐
  280.   │                                                                         │
  281.   │  Mail To: RUNsoft                                                       │
  282.   │           Málaga 40, 3º                                                 │
  283.   │           29600 Marbella                                                │
  284.   │           SPAIN                                                         │
  285.   │                                                                         │
  286.   │  Yes, I agree. What we really need is really usefull classes. We have   │
  287.   │  enough OOPS theory, but we do not have Classes to use!                 │
  288.   │                                                                         │
  289.   │  I am using TIniFile quite enough now so I would like to register to    │
  290.   │  support your research. Please keep me informed of new Classes you      │
  291.   │  develop in the future.                                                 │
  292.   │                                                                         │
  293.   │  Also, I would like to receive ALL THE SOURCE CODE of this Class and    │
  294.   │  explanations to understand and learn how to code my own new Classes,   │
  295.   │  without having to use any external OOPS libraries. Just C and Clipper  │
  296.   │  Code -or only Clipper code-. You will explain me in deep how Clipper   │
  297.   │  builds and manage Classes and Objects.                                 │
  298.   │                                                                         │
  299.   │  The price for all the above is just 30 US$ plus 3 US$ mail expenses    │
  300.   │  if requested from outside Spain.                                       │
  301.   │                                                                         │
  302.   │  User: Name and address.                                                │
  303.   └─────────────────────────────────────────────────────────────────────────┘
  304.  
  305.    For the moment we only accept US$ notes for payment. The expenses for
  306.    cashing a bank check are very high. Thanks very much for your support.
  307.  
  308.    TIniFile has been designed and coded as the same manner as Clipper
  309.    standard Classes.
  310.  
  311.    Electronic adresses:
  312.  
  313.                                  - Page 6 -
  314. Norton Guide: `TIniFile Class for CA-Clipper'
  315.  
  316.  
  317.  
  318.    Antonio Linares, 2:345/201.20@fidonet.org
  319.    Juan Miguel Sosso, 2:345/201.8@fidonet.org
  320.  
  321.    and CIS 100114,1776
  322.  
  323.  
  324.                                  - Page 7 -
  325. Norton Guide: `TIniFile Class for CA-Clipper'
  326.  
  327.  
  328.  
  329.                                 I N D E X
  330.                                 ---------
  331.  
  332.  
  333.  
  334. TIniFile Class
  335.     Sintax  .......................................................    2
  336.     About  ........................................................    6
  337.  
  338.  
  339.                                  - Page 8 -
  340.  
  341.