Data = Error? fix Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Jonas353
Posts: 64
Joined: 13 Oct 2017, 06:37

Data = Error? fix

29 Oct 2017, 13:01

So i got a save script that saves and writes variable values inside a .ini file. But if i delete alle the values inside the .ini file it should be able to write the values when i open the autohotkey file but instead it gives a value of "Error"
How to fix???

Code: Select all

;//SetTimer
SetTimer, CookiesCounter, 0

FileAppend,
(
[Variables]
ChristmasCookies = 0
)

IniRead, ChristmasCookies, %A_ScriptDir%\Scripts\AutoMiner\Config.ini, Variables, ChristmasCookies, ERROR

CookiesCounter:
IniWrite, %ChristmasCookies%, %A_ScriptDir%\Scripts\AutoMiner\Config.ini, Variables, ChristmasCookies
Noesis
Posts: 301
Joined: 26 Apr 2014, 07:57

Re: Data = Error? fix  Topic is solved

30 Oct 2017, 01:04

Several issues with this script.

First, FileAppend, there isn't a file defined for it so it doesn't do anything, and it's probably not what you want anyway and that should probably be deleted.
Second, set timer, why? and zero period and before the ini file is read. Also the label CookiesCounter is part of the auto execute section as there are no returns, i.e. SetTimer appears to be another redundant statement.

So this script functionally boils down to two statements, the IniRead, and the IniWrite. When you read the ini file you are giving the variable a default value of ERROR, i.e. the last argument in the command. So if there is nothing to read the value for ChristmasCookies becomes the string ERROR, hence when you write it, it writes the value in ChristmasCookies which is naturally going to be ERROR. To fix it use a default value of whatever you want it to be.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750 and 381 guests