INIREAD returns ERROR Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
KRG-23
Posts: 19
Joined: 07 Jun 2016, 05:45
Location: France

INIREAD returns ERROR

07 Sep 2018, 03:03

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 !
User avatar
Alguimist
Posts: 428
Joined: 05 Oct 2015, 16:41
Contact:

Re: INIREAD returns ERROR

07 Sep 2018, 03:28

Your ini file is in UTF-8 with BOM.
User avatar
KRG-23
Posts: 19
Joined: 07 Jun 2016, 05:45
Location: France

Re: INIREAD returns ERROR

07 Sep 2018, 04:39

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.
User avatar
Alguimist
Posts: 428
Joined: 05 Oct 2015, 16:41
Contact:

Re: INIREAD returns ERROR

07 Sep 2018, 04:51

Open the ini file in Notepad and save it with the encoding "Unicode" (UTF-16 LE).
User avatar
KRG-23
Posts: 19
Joined: 07 Jun 2016, 05:45
Location: France

Re: INIREAD returns ERROR

07 Sep 2018, 06:27

Notepad only proposes :
- ANSI
- Unicode
- Unicode big endian
- UTF-8
User avatar
Alguimist
Posts: 428
Joined: 05 Oct 2015, 16:41
Contact:

Re: INIREAD returns ERROR

07 Sep 2018, 07:19

Notepad refers to "UTF-16 LE" as "Unicode".
garry
Posts: 3758
Joined: 22 Dec 2013, 12:50

Re: INIREAD returns ERROR  Topic is solved

07 Sep 2018, 07:46

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
User avatar
KRG-23
Posts: 19
Joined: 07 Jun 2016, 05:45
Location: France

Re: INIREAD returns ERROR

03 Oct 2018, 05:11

I have no explanation but that worked
Thank you @garry!
ThewarII
Posts: 49
Joined: 01 Oct 2014, 09:33

Re: INIREAD returns ERROR

03 Oct 2018, 14:32

Something error in Notepad++
So i choice notepad except specical something notepad can't work.
I :superhappy:(happy) when I know about AHK.
I have & am using AHK to do anything in windows microsoft.
The first time, I know it in around year 2013.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: haomingchen1998, robodesign and 244 guests