write to INI file
Blitz3D Forums/Blitz3D Programming/write to INI file
| ||
I am trying to wirte a value to settings.ini I have kernel32.dll and a kernel32.decls in my userlibs folder. my code looks like this Include "imports/INI_functions.bb" ini_write("Display","test","1","settings.ini") INI_functions.bb: ; writes a value to an INI file Function ini_write(Section$,Key$,Value$,File$) IniWrite(Section$, Key$, Value$, File$) Print"write value" End Function settings.ini: [Display] test=3 kernel32.decls: .lib "kernel32.dll" IniRead%(AppName$, KeyName$, Default$, String*, size%, FileName$):"GetPrivateProfileStringA" IniEnumValues%(AppName$, KeyNull%, Default$, String*, size%, FileName$):"GetPrivateProfileStringA" IniEnumSections%(KeyNull1%, KeyNull2%, Default$, String*, size%, FileName$):"GetPrivateProfileStringA" IniWrite%(AppName$, KeyName$, Value$, FileName$):"WritePrivateProfileStringA" ------------------------------------------ I am not getting any kind of error just the value in my ini dont seem to change. Anyone have any idea what i am doing wrong?? |
| ||
Look here: http://www.blitzbasic.com/codearcs/codearcs.php?code=776 That is what I used to get myself started... Rook |
| ||
Include the full path to the INI file, see if that works.INIpath$ = CurrentDir() + "settings.ini" ini_write("Display","test","1",INIPath$) |
| ||
Thanks Snarkbait thats exactly what it was. You would not beleave how much hair I've lost trying to figure out whats wrong :P |
| ||
np, sender. I also remade the ini_read function, and called it 'StringFromINI' Function StringFromINI$(section$,key$,INIpath$,defSize = 100) thisbank = CreateBank(defSize) success = IniRead(section$,key$,"",thisbank,defSize,INIPath$) If success For a = 1 To success this$ = this$ + Chr$(PeekByte(thisbank,a-1)) Next Else RuntimeError "INI file error" EndIf Return this$ End Function |