Iniwrite append instead of modify value Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Giacomo
Posts: 2
Joined: 18 Oct 2017, 01:57

Iniwrite append instead of modify value

18 Oct 2017, 03:19

[Moderator's note: Topic moved from Bug Reports.]

Hi guys,

iniwrite append at the end insted of modify Fullscreen = 0 in the first section [main]
but the other sections are modified

I attached the files in question


I try to copy the content of gpuDX11.ini to another .ini and the script works

Where I'm wrong?


iniwrite gpuDX11.ahk

Code: Select all

sp := " " ; salva il carattere spazio nella variabile sp
IniWrite, %sp%1, gpuDX11.ini, main, UseFullscreen
IniWrite, %sp%%A_ScreenWidth%, gpuDX11.ini, resolution, Width
IniWrite, %sp%%A_ScreenHeight%, gpuDX11.ini, resolution, Height
MsgBox, INI UPDATED


gpuDX11.ini

Code: Select all

[main]
Vsync = 0
AutoSort = 0
NetworkSort = 0
OModifier = 0
TModifier = 0
JoinTrans = 0
UseFullscreen = 0
rotate = 0
aspect = 1
scaling = 1
MaxLayers = 32
NotAutoRotate = 0
slowpoke = true
blitperf = 70000000
tlthread = true
tlcache = false
bilinearfb = true
atifix = false


[resolution]
Width = 1920
Height = 1080


[shaders]
usePass1 = 0
usePass2 = 0
shaderPass1 = 
shaderPass2 =
Attachments
iniwrite gpuDX11.ahk
(435 Bytes) Downloaded 22 times
gpuDX11.ini
(417 Bytes) Downloaded 20 times
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Iniwrite append instead of modify value  Topic is solved

18 Oct 2017, 07:23

It's because your text file has a UTF-8 BOM. Ini files can only handle ANSI or UTF-16.

However, if the text is all ASCII, which it appears to be, a simple workaround would be to add a comment at the top of the file:

Code: Select all

;my comment
[main]
Alternative solutions would be to save the file as 'ANSI' (if it contains no Unicode characters) or 'Unicode' in Notepad.

Or to have a 'UTF-8 ini file', you would need to do some strings conversions after reading and before writing, using StrGet/StrPut.

[EDIT:] I posted some workaround functions for anyone who does actually want to use 'UTF-8 ini files'.
UTF-8 ini files - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=38511
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Giacomo
Posts: 2
Joined: 18 Oct 2017, 01:57

Re: Iniwrite append instead of modify value

19 Oct 2017, 08:20

Thank you jeeswg for the fast reply, I use the comment workaround and it worked!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee and 314 guests