R E X X I N I
Rexx API's for manipulation of Text Based INI Files (used by WINOS2)
Written: Steven Elliott - CompuServe 100032,1454
Useful for manipulating and fixing text ini files used by DOS and windows programs
FREEWARE
Functions Supported
IniLoadFuncs Load this library
IniDropFuncs Unload this library
IniLoad(section, file)
will load the entire section into a stem variable of the section
name, with the shoots being the field = value pairs
IniEnum(stem, where)
returns array of fields. stem.0 = num entries
str = IniGet(field, where)
returns string value of field
bool = IniBool(field, where)
returns '0' for False and '1' for True
supports field being 0/1 or True/False or Yes/No
IniDel(field, where)
deletes the specified field from the section
IniSet(field, value, where)
sets filed to the value value
IniEnumSections(stem, file)
returns array of section names in stem. stem.0 = number of entries
handle = IniOpen(section, file)
returns a handle to use for other functions (in place of 'where')
handle <= 0 is error
IniClose(handle)
close the specified inifile section
IniSave(handle)
save any changes made to the inifile section
IniCopy(handle, section, file)
copy all fields in the 'handle' section to the specified 'section'
in the specified 'file'
where is either 'handle' or 'section, file'
When multiple entries are changed in the same section it is
preferable and faster to use the handle version
eg:
WIN.INI
[Desktop]
Pattern=(None)
Wallpaper=(None)
GridGranularity=0
IconSpacing=100
call rxfuncadd 'IniLoadFuncs', 'REXXINI', 'IniLoadFuncs'
call IniLoadFuncs
wfile = 'C:\OS2\MDOS\WINOS2\WIN.INI'
say "The current Windows Wallpaper is" IniGet('Wallpaper', 'Desktop', wFile)
say "The [Desktop] section contains the following fields"
handle = IniOpen('Desktop', wFile)
call IniEnum 'Desktop', handle
do i = 1 to Desktop.0
say Desktop.i '=' IniGet(Desktop.i, handle)
end
say "Changing Granularity and Spacing"
call IniSet 'GridGranularity', 10, handle
call IniSet 'IconSpacing', 50, handle
call IniSave handle
call IniClose handle
say ""
say "The [Desktop] section now contains the following:"
call IniLoad 'Desktop', wFile
say "Pattern = " Desktop.Pattern
say "Wallpaper = " Desktop.Wallpaper
say "GridGranularity =" Desktop.GridGranularity
say "IconSpacing =" Desktop.IconSpacing
call IniDropFuncs
say "That's all folks!"
/*REXX*/
call rxfuncadd 'IniLoadFuncs', 'REXXINI', 'IniLoadFuncs'
call IniLoadFuncs
wfile = 'C:\OS2\MDOS\WINOS2\WIN.INI'
say "The current Windows Wallpaper is" IniGet('Wallpaper', 'Desktop', wFile)
say "The [Desktop] section contains the following fields"
handle = IniOpen('Desktop', wFile)
call IniEnum 'Desktop', handle
do i = 1 to Desktop.0
say Desktop.i '=' IniGet(Desktop.i, handle)
end
say "Changing Granularity and Spacing"
handle = IniOpen('Desktop', wFile)
call IniSet 'GridGranularity', 10, handle
call IniSet 'IconSpacing', 50, handle
call IniSave handle
call IniClose handle
say ""
say "The [Desktop] section now contains the following:"
call IniLoad 'Desktop', wFile
say "Pattern = " Desktop.Pattern
say "Wallpaper = " Desktop.Wallpaper
say "GridGranularity =" Desktop.GridGranularity
say "IconSpacing =" Desktop.IconSpacing
call IniDropFuncs
say "That's all folks!"
Aggiungi un commento