home *** CD-ROM | disk | FTP | other *** search
/ Freelog 115 / FreelogNo115-MaiJuin2013.iso / Internet / Firefox / FirefoxPortable_20.0_French.paf.exe / Other / Source / ReadINIStrWithDefault.nsh < prev    next >
Text File  |  2010-06-22  |  1KB  |  55 lines

  1. ∩╗┐; ReadINIStrWithDefault 1.1 (2009-05-12)
  2. ;
  3. ; Substitutes a default value if the INI is undefined
  4. ; Copyright 2008-2009 John T. Haller of PortableApps.com
  5. ; Released under the BSD
  6. ;
  7. ; Usage: ${ReadINIStrWithDefault} OUTPUT_VALUE INI_FILENAME SECTION_NAME ENTRY_NAME DEFAULT_VALUE
  8. ;
  9. ; History:
  10. ; 1.1 (2009-05-12): Fixed error with $0 and $2 being swapped
  11.  
  12. Function ReadINIStrWithDefault
  13.     ;Start with a clean slate
  14.     ClearErrors
  15.     
  16.     ;Get our parameters
  17.     Exch $0 ;DEFAULT_VALUE
  18.     Exch
  19.     Exch $1 ;ENTRY_NAME
  20.     Exch 2
  21.     Exch $2 ;SECTION_NAME
  22.     Exch  3
  23.     Exch $3 ;INI_FILENAME
  24.     Push $4 ;OUTPUT_VALUE
  25.     
  26.     ;Read from the INI
  27.     ReadINIStr $4 $3 $2 $1
  28.     IfErrors 0 +3
  29.         StrCpy $4 $0
  30.         ClearErrors
  31.  
  32.     ;Keep the variable for last
  33.     StrCpy $0 $4
  34.     
  35.     ;Clear the stack
  36.     Pop $4
  37.     Pop $3
  38.     Exch 2
  39.     Pop $2
  40.     Pop $1
  41.     
  42.     ;Reset the last variable and leave our result on the stack
  43.     Exch $0
  44. FunctionEnd
  45.  
  46. !macro ReadINIStrWithDefault OUTPUT_VALUE INI_FILENAME SECTION_NAME ENTRY_NAME DEFAULT_VALUE
  47.   Push `${INI_FILENAME}`
  48.   Push `${SECTION_NAME}`
  49.   Push `${ENTRY_NAME}`
  50.   Push `${DEFAULT_VALUE}`
  51.   Call ReadINIStrWithDefault
  52.   Pop `${OUTPUT_VALUE}`
  53. !macroend
  54.  
  55. !define ReadINIStrWithDefault '!insertmacro "ReadINIStrWithDefault"'