TryFetchField (return comma delimited INI file value)

Top  Previous  Next

 

TryFetchField( section, entry, field )

TryFetchField

Returns a comma delimited value from the INI file.

section

A string constant, variable, EQUATE, or expression containing the INI file section name.

entry

A string constant, variable, EQUATE, or expression containing the INI file entry name.

field

An integer constant, variable, EQUATE, or expression identifying the comma delimited value to return.

The TryFetchField method returns one of several comma delimited values from the INI file. If the specified section and entry do not exist, TryFetchField returns an empty string. This allows you to check the return value and take appropriate action when the INI file entry is missing.

TryFetchField assumes the entry value is a comma delimited string of the form V1,V2,...,Vn. A field value of one (1) returns the value prior to the first comma in the string; a value of two (2) returns the value between the first and second commas; a three (3) returns the value between the second and third commas, etc.

Return Data Type:

STRING

Example:

Sound   STRING(3)

Volume  BYTE

 

 CODE

Sound=INIMgr.TryFetchField('Preferences','Sound&Volume',1)

!get Sound value

IF NOT Sound               !if not present

 Sound='ON'                !default to on

END

Volume=INIMgr.TryFetchField('Preferences','Sound&Volume',2)

!get Volume value

IF NOT Volume              !if not present

 Volume=3                  !default to 3

END

!program code

INIMgr.Update('Preferences','Sound&Volume', |  !create INI entry like

       CLIP(Sound)&','&Volume)                 !Sound&Volume=ON,3

 

See Also: GETINI