IniRead fails for one entry Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
kdaube
Posts: 86
Joined: 02 Nov 2015, 03:11

IniRead fails for one entry

16 Feb 2023, 05:27

Dear all,
I'm clueless what might happen here.
the ini file contains this:

Code: Select all

[Project]
appName   = FMbuildTB
...
[en]
appTitle  = Build FM tool bars
appDescr  = FMbuildTB builds Tool Bars for FrameMaker.
appHint   = The utility will be installed in the user area (%appdata%\D+DD). A shortcut to the utility will be established in Startmenu\D+DD.
instTitle  = Install utility FMbuildTB
...
When reading from this file with appLang := "en" and iniFIle

Code: Select all

iniFile := A_ScriptDir . "\InstallThis\\config.ini"
appLang := "en"
  IniRead, appName,    %iniFile%, Project,  appName
  IniRead, appHint,    %iniFile%, %appLang%, appHint
  IniRead, instTitle,  %iniFile%, %appLang%, instTitle      ; ERROR
  IniRead, appTitle,   %iniFile%, %appLang%, appTitle
  IniRead, appDescr,   %iniFile%, %appLang%, appDescr
  ...
all items are correctly read, with the exception of instTitle. I get ERROR.
I have checked with hex display for strange things in the text, moved the code lines in different orde, checked code page, renamed to gurkTitle → no solution found so far.
What else should I look for?
Klaus Daube, Zürich, CH
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: IniRead fails for one entry  Topic is solved

16 Feb 2023, 05:36

1. Double-check your INI file.
2. Save your INI file.
3. Use only the code shown in your post, in your testing. ... and all other code should be removed, though you could add MsgBox to display what is read.
4. Use only the INI file that you have posted here.
5. If you have multiple INI files, check to see that you are accessing the one that you think you are.
Last edited by mikeyww on 16 Feb 2023, 05:39, edited 1 time in total.
User avatar
kdaube
Posts: 86
Joined: 02 Nov 2015, 03:11

Re: IniRead fails for one entry

16 Feb 2023, 05:38

BTW immediateley after the statement

Code: Select all

  IniRead, instTitle,  %iniFile%, %appLang%, instTitle      ;
MsgBox %ErrorLevel%
ErrorLevel is zero which is as documented. How to find the cause then?
Klaus Daube, Zürich, CH
User avatar
mikeyww
Posts: 27372
Joined: 09 Sep 2014, 18:38

Re: IniRead fails for one entry

16 Feb 2023, 05:40

See my steps to resolve.

How are you determining the line that generates the error?

A shorter script is also sufficient.

Code: Select all

#Requires AutoHotkey v1.1.33
iniFile := A_ScriptDir . "\InstallThis\config.ini"
appLang := "en"
IniRead, instTitle,  %iniFile%, %appLang%, instTitle
Msgbox % instTitle
Windows does not require a double backslash before file names.

image230216-0543-001.png
Output
image230216-0543-001.png (4.14 KiB) Viewed 342 times
Attachments
config.ini
INI file
(311 Bytes) Downloaded 17 times
User avatar
kdaube
Posts: 86
Joined: 02 Nov 2015, 03:11

Re: IniRead fails for one entry

16 Feb 2023, 05:46

mikeyww, again, you hit the nail!
«If you have multiple INI files, check to see that you are accessing the one that you think you are.»

I really used the wrong one which did not include this entry!
Klaus Daube, Zürich, CH

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: apeironn, madensuyu1, peter_ahk and 367 guests