OS2World OLD-STATIC-BACKUP Forum

OS/2 - SIGs => Rexx => Topic started by: jep on 2008.04.10, 13:03:21

Title: Use EA to store information and settings
Post by: jep on 2008.04.10, 13:03:21
Marked as: Normal
Hello,

At times you may want to store information between each run. It can improve performance so you don't have to use code that serach for files and information that is already known from earlier and it can serve as a storage of data that you want to hide form the user, at least a bit.

Remember that you can't use this method to set data on executables that run as they're "locked", but you can use a dummy ini-file and store info in the EA of that one intead.

/* Read/Save info from/to Extended Attributes */

parse source . . prog

if SysGetEA( prog, '.settings_plugin', 'plugin' ) = 0 then
  if length( plugin ) = 0 then do
    plugin = value( 'ETC',, 'ENVIRONMENT' )'\settings.plg' /* if not found, search or define where it should be placed */
    say "Plugin will be placed in "plugin
  end
  else say "Information read from EA ("plugin")"

if SysPutEA( prog, '.settings_plugin', plugin ) = 0 then
   say "Information has been saved to EA of "prog
else
   say "It wasn't possible to write the information to "prog