Page 1 of 1

INIREAD returns ERROR

Posted: 07 Sep 2018, 03:03
by KRG-23
Hello all,

I've made some research but I can't figure out how to solve my problem :

When I select a .INI file and make an IniRead, it always returns an error.

I am sure I am missing something and that's why I'm asking the boards for help ...

Here's the script (UTF-8 without BOM):

Code: Select all

;==================================================
; GUI
;==================================================

Gui, Add, Button, h25 w150 vOpen_LogFile gButt_OpenLog, Open Logfile
Gui, Show, Autosize, INI TEST
return

;==================================================
;LABELS
;==================================================

Butt_OpenLog:
	; SetWorkingDir, logs
	FileSelectFile, temp_FileName,,, Please choose a previous IM log file from the logs folder,
	IniRead, temp_IM_number, %temp_FileName%, Header, IM_number
	MsgBox, temp_FileName = %temp_FileName%`ntemp_IM_number = %temp_IM_number%
Return	

GuiEscape:
GuiClose:
	ExitApp
Return
My INI file (ANSI):

Code: Select all

[Header]
IM_number=IM11223344
I suspect the error is right under my nose but it's too large for me to see anything...

Obviously, there'll be more than a single line in my INI file but I need to get this fixed before going any further.

Thank you !

Re: INIREAD returns ERROR

Posted: 07 Sep 2018, 03:28
by Alguimist
Your ini file is in UTF-8 with BOM.

Re: INIREAD returns ERROR

Posted: 07 Sep 2018, 04:39
by KRG-23
Alguimist wrote:Your ini file is in UTF-8 with BOM.
I've changed myfile.ini encoding to UTF-8 (as with NP++ there's not the choice of UTF-8 with BOM) and it's not working any better :(

I've forced both my script and ini file as ANSI, it's not working neither.

Re: INIREAD returns ERROR

Posted: 07 Sep 2018, 04:51
by Alguimist
Open the ini file in Notepad and save it with the encoding "Unicode" (UTF-16 LE).

Re: INIREAD returns ERROR

Posted: 07 Sep 2018, 06:27
by KRG-23
Notepad only proposes :
- ANSI
- Unicode
- Unicode big endian
- UTF-8

Re: INIREAD returns ERROR

Posted: 07 Sep 2018, 07:19
by Alguimist
Notepad refers to "UTF-16 LE" as "Unicode".

Re: INIREAD returns ERROR  Topic is solved

Posted: 07 Sep 2018, 07:46
by garry
just a test notepad++ UTF-8-BOM

Code: Select all

#warn
Setworkingdir,%a_scriptdir%
rssini=%a_scriptdir%\test.ini
ifnotexist,%rssini%
    IniWrite,IM_number=IM11223344 , %rssini% ,Header  ,key1
;IniRead, val1, %rssini%,Header ,key1
;msgbox,%val1%
Gui, Add, Button, h25 w150 vE gA1, Open Logfile
Gui, Show, Autosize, INI TEST
return
Guiclose:
exitapp

a1:
FileSelectFile,rssiniX,2,%a_scriptdir%, Please choose a previous IM log file from the logs folder,Supported Files (*.txt;*.ini)
IniRead, valX, %rssini%,Header ,key1
msgbox,Filename=%rssiniX%`nNumber=%valX%
return

Re: INIREAD returns ERROR

Posted: 03 Oct 2018, 05:11
by KRG-23
I have no explanation but that worked
Thank you @garry!

Re: INIREAD returns ERROR

Posted: 03 Oct 2018, 14:32
by ThewarII
Something error in Notepad++
So i choice notepad except specical something notepad can't work.