home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1993 #2
/
Image.iso
/
clipper
/
oini.zip
/
INIFILE.DOC
< prev
next >
Wrap
Text File
|
1993-05-30
|
13KB
|
341 lines
┌─────────────────────────────────────────────────┐
│ TIniFile Class for CA-Clipper │█
│ (c) Antonio Linares, 1993 │█
└─────────────────────────────────────────────────┘█
Printout of `TIniFile Class for CA-Clipper'
Printed by the Norton Guides Printer v2.0 (NGP.EXE).
- Page 1 -
Norton Guide: `TIniFile Class for CA-Clipper'
Menu List: TIniFile Class, Sintax
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:
- Page 2 -
Norton Guide: `TIniFile Class for CA-Clipper'
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
- Page 3 -
Norton Guide: `TIniFile Class for CA-Clipper'
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ 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!
───────────────────────────────────────────────────────────────────────────────
- Page 4 -
Norton Guide: `TIniFile Class for CA-Clipper'
Object Creation
TIniFile() --> IniFile Object not inicialized
TIniFile():Use( cIniFileName ) --> IniFile Object Inicialized,
ready to be used
───────────────────────────────────────────────────────────────────────────────
Exported Instance Variables
aLines Text lines of the INI File ASSIG
cSection [cSection] from last Set or Get
cEntry, cValue cEntry = cValue " " " "
nFoundAt cEntry is located at nFoundAt line
nSections Number of sections in a INI File
───────────────────────────────────────────────────────────────────────────────
Exported Methods
Use( cIniFileName ) Uses a INI File CONSTRUCTOR
Set( cSection, cEntry, cValue ) Set a INI value
cGet( cSection, cEntry [, cDefault ] ) Get a INI value
Save() Save the INI file to disk
Use() End using the INI file
- Page 5 -
Norton Guide: `TIniFile Class for CA-Clipper'
Menu Choice: TIniFile Class, About
(c) 1.993 RUNsoft
Written by Antonio Linares
Specially thanks to Mr. Octopus -Francisco Pulpón-
Soon, more Classes coming...
TGraph() Object Oriented Bussines graphics for Clipper
TText() Full featured Word processing with color sintax
highlighting, functions review 'a la Visual Objects',
no limit size, and more...
No external OOPS libraries, just pure OOPS/C/Clipper code!
inifile.obj has been coded using Borland C++ 3.1
__Ini.obj has been coded using CA-Clipper 5.1
┌─ Registration form ─────────────────────────────────────────────────────┐
│ │
│ Mail To: RUNsoft │
│ Málaga 40, 3º │
│ 29600 Marbella │
│ SPAIN │
│ │
│ Yes, I agree. What we really need is really usefull classes. We have │
│ enough OOPS theory, but we do not have Classes to use! │
│ │
│ I am using TIniFile quite enough now so I would like to register to │
│ support your research. Please keep me informed of new Classes you │
│ develop in the future. │
│ │
│ Also, I would like to receive ALL THE SOURCE CODE of this Class and │
│ explanations to understand and learn how to code my own new Classes, │
│ without having to use any external OOPS libraries. Just C and Clipper │
│ Code -or only Clipper code-. You will explain me in deep how Clipper │
│ builds and manage Classes and Objects. │
│ │
│ The price for all the above is just 30 US$ plus 3 US$ mail expenses │
│ if requested from outside Spain. │
│ │
│ User: Name and address. │
└─────────────────────────────────────────────────────────────────────────┘
For the moment we only accept US$ notes for payment. The expenses for
cashing a bank check are very high. Thanks very much for your support.
TIniFile has been designed and coded as the same manner as Clipper
standard Classes.
Electronic adresses:
- Page 6 -
Norton Guide: `TIniFile Class for CA-Clipper'
Antonio Linares, 2:345/201.20@fidonet.org
Juan Miguel Sosso, 2:345/201.8@fidonet.org
and CIS 100114,1776
- Page 7 -
Norton Guide: `TIniFile Class for CA-Clipper'
I N D E X
---------
TIniFile Class
Sintax ....................................................... 2
About ........................................................ 6
- Page 8 -