Write many values to INI file for reading

From NSIS Wiki
Jump to navigationJump to search
Author: Afrow UK (talk, contrib)


Description

This is a simple script to write multiple values to an INI file. It writes values like so...

[Values]
Value1=Blah|LaLaLa
Value2=JaJaJa
Value3=Muhahahahahaah

...and so on.

Usage

Push "$R0|$R1" ;input string to write
Push "$TEMP\settings.lst" ;file to write into
Call WriteToINI

The Function

Function WriteToINI
Exch $0 ;file
Exch
Exch $1 ;string
Push $2
Push $3
 StrCpy $2 0
loop:
  ReadINIStr $3 $0 Values Value$2
  StrCmp $3 "" done_loop
 IntOp $2 $2 + 1
Goto loop
done_loop:
  WriteINIStr $0 Values Value$2 $1
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd

-Stu