Menu

resloving strings for window settings

Help
fpefpe
2016-05-14
2016-07-06
  • fpefpe

    fpefpe - 2016-05-14

    Hello -- from time to time when fetching string from rhe registery, values might come back in the form
    %value%

    which in windows means to use the value currently stored in the enviroment -- is there a rexx / function / package that would evaluate this value (as-is)?

     
    • frank

      frank - 2016-07-06

      DIY could begin like this:

      EXPAND:  procedure                  /* resolving REG_SZ_EXPAND */
         parse arg SRC
         DST = ''                         ;  P = pos( '%', SRC )
         do while P > 0
            DST = DST || left( SRC, P - 1 )
            SRC = substr( SRC, P + 1 )    ;  P = pos( '%', SRC )
            if P = 0 then  do
               DST = DST || '%'           ;  leave
            end
            DST = DST || value( left( SRC, P - 1 ),, 'ENVIRONMENT' )
            SRC = substr( SRC, P + 1 )    ;  P = pos( '%', SRC )
         end
         return DST || SRC
      

      If what you expect is an absolute path to a file there be dragons (%SystemRoot%, %SystemDrive%, Unicode/ACP/OemCP, the works).
      `

       

Log in to post a comment.