I have read an article which is written by Stephen Settimi in Foxpro Advisor
Aug 2000. In the article, Stephen mentioned making use of a text file,
DEF[inition] file, to hold the variables used by the application. The
application will read the DEF file to extract the variable whenever the
application is launched.

Does any body has some code to parse the variable from a text file ?

The structure of the file is very simple such as like the following,

CONSTANT1 = definition1
CONSTANT2 = definition2
.................

for example, I will call the parser function getdefinition("CONSTANT1") to
get the definition of CONSTANT1.

Matthew

Re: DEF[inition] file parser by swdev2

swdev2
Mon Apr 19 08:18:33 CDT 2004

Hullo Matthew -
the code was available online - you should be able to get to it ?
regards [Bill]
--
William Sanders / Electronic Filing Group Remove the DOT BOB to reply via
email.
Mondo Cool TeleCom -> http://www.efgroup.net/efgcog.html
Mondo Cool WebHosting -> http://www.efgroup.net/efglunar.html
Mondo Cool Satellites -> http://www.efgroup.net/sat
mySql / VFP / MS-SQL

"HGC NET-YAN" <tokaho_nospam@nospam.bcluster.on-nets.com> wrote in message
news:c60c27$201j$1@news.hgc.com.hk...
> I have read an article which is written by Stephen Settimi in Foxpro
Advisor
> Aug 2000. In the article, Stephen mentioned making use of a text file,
> DEF[inition] file, to hold the variables used by the application. The
> application will read the DEF file to extract the variable whenever the
> application is launched.
>




Re: DEF[inition] file parser by Rick

Rick
Mon Apr 19 08:42:10 CDT 2004

There are some methods in the REGISTRY.PRG (and the FFC Registry class - =
they are essentially the same) that allow you to read and write to .INI =
files - besides the registry. This functionality is really just a =
wrapper around the API functions - GetPrivateProfileString(), =
WritePrivateProfileString() and GetPrivateProfileInt().

Rick

"HGC NET-YAN" <tokaho_nospam@nospam.bcluster.on-nets.com> wrote in =
message news:c60c27$201j$1@news.hgc.com.hk...
> I have read an article which is written by Stephen Settimi in Foxpro =
Advisor
> Aug 2000. In the article, Stephen mentioned making use of a text file,
> DEF[inition] file, to hold the variables used by the application. The
> application will read the DEF file to extract the variable whenever =
the
> application is launched.
>=20
> Does any body has some code to parse the variable from a text file ?
>=20
> The structure of the file is very simple such as like the following,
>=20
> CONSTANT1 =3D definition1
> CONSTANT2 =3D definition2
> .................
>=20
> for example, I will call the parser function =
getdefinition("CONSTANT1") to
> get the definition of CONSTANT1.
>=20
> Matthew
>=20
>=20
>

Re: DEF[inition] file parser by Rick

Rick
Mon Apr 19 09:13:05 CDT 2004

I also dug up this old Low-Level IO routine that works similarly. I =
wrote it for a FP DOS App many years ago, so it could have the same =
functionality of a Windows app. e.g.

?PARSEINI("constants.ini", "", "Constant1", .F.)

Where I used your example data in a "Constants.INI" file.

Note: Mine allows duplicate named data as long as a SECTION is named - =
just like the old Win 3.x .INI files.

Rick

* FUNCTION PARSEINI.PRG Parse .INI File options
PARAMETERS zcININame, zcSection, zcOption, zlRetUpper
* Returns value found

IF PARAMETERS() < 4 OR TYPE('zlRetUpper') <> 'L'
zlRetUpper =3D .T.
ENDIF
IF PARAMETERS() < 3 OR TYPE('zcININame') <> 'C' OR !GOTFILE(zcININame);
OR TYPE('zcOption') <> 'C'
RETURN ''
ENDIF
PRIVATE lfhandle, lcrecord, llfound, lcret_val, lctempstr

lfhandle =3D FOPEN(zcININame, 0) && read-only buffered
IF lfhandle <=3D 0 && Can't open
RETURN ''
ENDIF

IF TYPE('zcSection') <> 'C' OR EMPTY(zcSection)
zcSection =3D ''
ELSE
zcSection =3D UPPER(ALLTRIM(zcSection))
IF LEFT(zcSection, 1) <> '[' && Add leading '[' if missing
zcSection =3D '['+zcSection
ENDIF
IF RIGHT(zcSection, 1) <> ']' && Add trailing ']' if missing
zcSection =3D zcSection+']'
ENDIF
ENDIF
llfound =3D .T.
IF !EMPTY(zcSection)
llfound =3D .F.
DO WHILE !FEOF(lfhandle)
lcrecord =3D FGETS(lfhandle)
IF UPPER(ALLTRIM(lcrecord)) =3D=3D zcSection && Found Section
llfound =3D .T.
EXIT
ENDIF
ENDDO
ENDIF
lcret_val =3D ''
zcOption =3D UPPER(ALLTRIM(zcOption))
IF llfound && Now look for the Option
DO WHILE !FEOF(lfhandle)
lcrecord =3D FGETS(lfhandle)
IF UPPER(LTRIM(lcrecord)) =3D zcOption && Found Option ?
lctempstr =3D LTRIM(SUBSTR(LTRIM(lcrecord),LEN(zcoption)+1))
IF lctempstr =3D "=3D" && got it !
lcret_val =3D ALLTRIM(SUBSTR(lctempstr,2))
IF zlRetUpper
lcret_val =3D UPPER(lcret_val)
ENDIF
EXIT
ENDIF
ENDIF
ENDDO
ENDIF
=3DFCLOSE(lfhandle)

RETURN lcret_val

FUNCTION gotfile
PARAMETERS zcfilename
PRIVATE zcfilename
IF TYPE("zcfilename") <> "C"
RETURN .F.
ENDIF
DIMENSION laJunk[1] && so it's local=20
RETURN (ADIR(laJunk, zcfilename, "ARS") > 0)

* Note: Conscious decision to not include Hidden files made, so it =
matched results
* of previous GOTFILE() AND FILE().


"Rick Bean" <rgbean@unrealmelange-inc.com> wrote in message =
news:%23yKSeQhJEHA.1340@TK2MSFTNGP12.phx.gbl...
There are some methods in the REGISTRY.PRG (and the FFC Registry class - =
they are essentially the same) that allow you to read and write to .INI =
files - besides the registry. This functionality is really just a =
wrapper around the API functions - GetPrivateProfileString(), =
WritePrivateProfileString() and GetPrivateProfileInt().

Rick

"HGC NET-YAN" <tokaho_nospam@nospam.bcluster.on-nets.com> wrote in =
message news:c60c27$201j$1@news.hgc.com.hk...
> I have read an article which is written by Stephen Settimi in Foxpro =
Advisor
> Aug 2000. In the article, Stephen mentioned making use of a text file,
> DEF[inition] file, to hold the variables used by the application. The
> application will read the DEF file to extract the variable whenever =
the
> application is launched.
>=20
> Does any body has some code to parse the variable from a text file ?
>=20
> The structure of the file is very simple such as like the following,
>=20
> CONSTANT1 =3D definition1
> CONSTANT2 =3D definition2
> .................
>=20
> for example, I will call the parser function =
getdefinition("CONSTANT1") to
> get the definition of CONSTANT1.
>=20
> Matthew
>=20
>=20
>

Re: DEF[inition] file parser by HGC

HGC
Mon Apr 19 19:49:50 CDT 2004

Hello William,

I am not the subscriber of the Advisor and I cannot find any download at the
Advisor website. I also searched internet through altavista but no luck.
Anyway, Rick has given me some suggestion and code, I will try it out.

Thank you very much.

Matthew

"swdev2" <wsanders.bob@bob.efgroup.com> ¦b¶l¥ó
news:%23aXxtHhJEHA.2660@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g...
> Hullo Matthew -
> the code was available online - you should be able to get to it ?
> regards [Bill]
> --
> William Sanders / Electronic Filing Group Remove the DOT BOB to reply via
> email.
> Mondo Cool TeleCom -> http://www.efgroup.net/efgcog.html
> Mondo Cool WebHosting -> http://www.efgroup.net/efglunar.html
> Mondo Cool Satellites -> http://www.efgroup.net/sat
> mySql / VFP / MS-SQL
>
> "HGC NET-YAN" <tokaho_nospam@nospam.bcluster.on-nets.com> wrote in message
> news:c60c27$201j$1@news.hgc.com.hk...
> > I have read an article which is written by Stephen Settimi in Foxpro
> Advisor
> > Aug 2000. In the article, Stephen mentioned making use of a text file,
> > DEF[inition] file, to hold the variables used by the application. The
> > application will read the DEF file to extract the variable whenever the
> > application is launched.
> >
>
>
>



Re: DEF[inition] file parser by HGC

HGC
Mon Apr 19 19:52:53 CDT 2004

Hello Rick,

Thank you very much. I will try it out.

Matthew

"Rick Bean" <rgbean@unrealmelange-inc.com> ???
news:OiY8vhhJEHA.2412@TK2MSFTNGP12.phx.gbl ???...
I also dug up this old Low-Level IO routine that works similarly. I wrote it
for a FP DOS App many years ago, so it could have the same functionality of
a Windows app. e.g.

?PARSEINI("constants.ini", "", "Constant1", .F.)

Where I used your example data in a "Constants.INI" file.

Note: Mine allows duplicate named data as long as a SECTION is named - just
like the old Win 3.x .INI files.

Rick

* FUNCTION PARSEINI.PRG Parse .INI File options
PARAMETERS zcININame, zcSection, zcOption, zlRetUpper
* Returns value found

IF PARAMETERS() < 4 OR TYPE('zlRetUpper') <> 'L'
zlRetUpper = .T.
ENDIF
IF PARAMETERS() < 3 OR TYPE('zcININame') <> 'C' OR !GOTFILE(zcININame);
OR TYPE('zcOption') <> 'C'
RETURN ''
ENDIF
PRIVATE lfhandle, lcrecord, llfound, lcret_val, lctempstr

lfhandle = FOPEN(zcININame, 0) && read-only buffered
IF lfhandle <= 0 && Can't open
RETURN ''
ENDIF

IF TYPE('zcSection') <> 'C' OR EMPTY(zcSection)
zcSection = ''
ELSE
zcSection = UPPER(ALLTRIM(zcSection))
IF LEFT(zcSection, 1) <> '[' && Add leading '[' if missing
zcSection = '['+zcSection
ENDIF
IF RIGHT(zcSection, 1) <> ']' && Add trailing ']' if missing
zcSection = zcSection+']'
ENDIF
ENDIF
llfound = .T.
IF !EMPTY(zcSection)
llfound = .F.
DO WHILE !FEOF(lfhandle)
lcrecord = FGETS(lfhandle)
IF UPPER(ALLTRIM(lcrecord)) == zcSection && Found Section
llfound = .T.
EXIT
ENDIF
ENDDO
ENDIF
lcret_val = ''
zcOption = UPPER(ALLTRIM(zcOption))
IF llfound && Now look for the Option
DO WHILE !FEOF(lfhandle)
lcrecord = FGETS(lfhandle)
IF UPPER(LTRIM(lcrecord)) = zcOption && Found Option ?
lctempstr = LTRIM(SUBSTR(LTRIM(lcrecord),LEN(zcoption)+1))
IF lctempstr = "=" && got it !
lcret_val = ALLTRIM(SUBSTR(lctempstr,2))
IF zlRetUpper
lcret_val = UPPER(lcret_val)
ENDIF
EXIT
ENDIF
ENDIF
ENDDO
ENDIF
=FCLOSE(lfhandle)

RETURN lcret_val

FUNCTION gotfile
PARAMETERS zcfilename
PRIVATE zcfilename
IF TYPE("zcfilename") <> "C"
RETURN .F.
ENDIF
DIMENSION laJunk[1] && so it's local
RETURN (ADIR(laJunk, zcfilename, "ARS") > 0)

* Note: Conscious decision to not include Hidden files made, so it matched
results
* of previous GOTFILE() AND FILE().


"Rick Bean" <rgbean@unrealmelange-inc.com> wrote in message
news:%23yKSeQhJEHA.1340@TK2MSFTNGP12.phx.gbl...
There are some methods in the REGISTRY.PRG (and the FFC Registry class -
they are essentially the same) that allow you to read and write to .INI
files - besides the registry. This functionality is really just a wrapper
around the API functions - GetPrivateProfileString(),
WritePrivateProfileString() and GetPrivateProfileInt().

Rick

"HGC NET-YAN" <tokaho_nospam@nospam.bcluster.on-nets.com> wrote in message
news:c60c27$201j$1@news.hgc.com.hk...
> I have read an article which is written by Stephen Settimi in Foxpro
Advisor
> Aug 2000. In the article, Stephen mentioned making use of a text file,
> DEF[inition] file, to hold the variables used by the application. The
> application will read the DEF file to extract the variable whenever the
> application is launched.
>
> Does any body has some code to parse the variable from a text file ?
>
> The structure of the file is very simple such as like the following,
>
> CONSTANT1 = definition1
> CONSTANT2 = definition2
> .................
>
> for example, I will call the parser function getdefinition("CONSTANT1") to
> get the definition of CONSTANT1.
>
> Matthew
>
>
>