I am trying to make a function were you can save a key to an INI file.
But it only works if the [section] doesn't exist.
Here is the code and I hope you can help me on this one!
FUNCTION saveINIkey$ (file$, section$, key$, value$)
what$ = "[" + section$ + "]"
OPEN file$ FOR APPEND AS #1
CLOSE #1
what = LEN(section$) + 2
OPEN file$ FOR INPUT AS #1
C = 1
DIM M$(1 TO 1000)
DO WHILE NOT EOF(1) AND C <= 1000
INPUT #1, M$(C)
IF LEFT$(M$(C), what) = what$ THEN lne = C
C = C + 1
LOOP
CLOSE #1
IF lne = 0 THEN
OPEN file$ FOR APPEND AS #1
PRINT #1, what$
PRINT #1, key$ + "=" + value$
CLOSE #1
EXIT FUNCTION
END IF
END FUNCTION
But it only works if the [section] doesn't exist.
Here is the code and I hope you can help me on this one!
FUNCTION saveINIkey$ (file$, section$, key$, value$)
what$ = "[" + section$ + "]"
OPEN file$ FOR APPEND AS #1
CLOSE #1
what = LEN(section$) + 2
OPEN file$ FOR INPUT AS #1
C = 1
DIM M$(1 TO 1000)
DO WHILE NOT EOF(1) AND C <= 1000
INPUT #1, M$(C)
IF LEFT$(M$(C), what) = what$ THEN lne = C
C = C + 1
LOOP
CLOSE #1
IF lne = 0 THEN
OPEN file$ FOR APPEND AS #1
PRINT #1, what$
PRINT #1, key$ + "=" + value$
CLOSE #1
EXIT FUNCTION
END IF
END FUNCTION