read empty (array) value from ini results in a filepath in editfield Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
peter_ahk
Posts: 118
Joined: 13 Feb 2024, 14:49

read empty (array) value from ini results in a filepath in editfield

Post by peter_ahk » 01 May 2024, 11:38

hello

for my macro launcher i ran into an unexpected problem that being when i read from ini into the editfield and the ini had nothing to show it will show this: C:\Users\Peter\AppData\Local\Temp but i want it to show nothing if there is nothing so i wonder is there some sort of errorlevel for edit fields that i can use to keep it empty (unless the user decides to use it) or perhaps another solution ive looked but cant find a clue so perhaps someone can point me in the right direction?

in my gui i have this:

Code: Select all

Gui,19: Add , Text , x330 y10 w100 h25 Right   , Macro Note
Gui,19: Add , Edit , x440 y10 w760 h25 -E0x200 , % MacroNotes[CurrentButtonNR]
i tested using a msgbox and when i have nothing in the ini it gets the value from it shows an empty msgbox and if i fill in something in the ini it will show that so it works only problem is that filepath that it shows when there was nothing in the ini i never wanna see that
see.png
see.png (4.19 KiB) Viewed 461 times
edit: i do intent to use a variable for the editfield to save user input thats not there in the code above cozs i have not written it jet, i do have a gLabel that i wont use
Last edited by peter_ahk on 01 May 2024, 22:02, edited 1 time in total.

User avatar
mikeyww
Posts: 27146
Joined: 09 Sep 2014, 18:38

Re: read empty value from ini results in a filepath in editfield

Post by mikeyww » 01 May 2024, 17:46

Hello,

The control will show whatever you tell it to show. You can use :arrow: If to test your condition and then show one value or the other, accordingly.

peter_ahk
Posts: 118
Joined: 13 Feb 2024, 14:49

Re: read empty value from ini results in a filepath in editfield

Post by peter_ahk » 01 May 2024, 21:09

mikeyww wrote:
01 May 2024, 17:46
Hello,

The control will show whatever you tell it to show. You can use :arrow: If to test your condition and then show one value or the other, accordingly.
ive tried that but i probably did it wrong, in trying things out i found a way but i dont understand the why here

i am trying to understand why loading from ini again does give me the result i need and having the value in an array does not
now just before the edit i read it from ini (again) and use that instead

Code: Select all

IniRead, TempEdit , Settings\Button %CurrentButtonNR% Settings Preset %buttonpresetNR%.ini , setupinfo , Button %CurrentButtonNR% Macro Notes
Gui,19: Add , Edit , x440 y10 w760 h25 -E0x200 , %TempEdit%
my loading to array i already had

Code: Select all

MacroNotes := []
Loop 664	{         
					IniRead temp	, % "Settings\Button " A_Index " Settings Preset " buttonpresetNR ".ini"
									, setupinfo
									, % "Button " A_Index " Macro Notes"
									MacroNotes.Push(temp)
				}

User avatar
mikeyww
Posts: 27146
Joined: 09 Sep 2014, 18:38

Re: read empty value from ini results in a filepath in editfield

Post by mikeyww » 01 May 2024, 21:38

I am finding it difficult to understand your goal and your script. I suggest that you follow four steps closely.
  1. Post the script that you are using-- a script that the forum reader can run to demonstrate the problem that you are experiencing.
  2. Post your INI file.
  3. Describe what happens when you run your script.
  4. Describe what should happen instead.

peter_ahk
Posts: 118
Joined: 13 Feb 2024, 14:49

Re: read empty value from ini results in a filepath in editfield  Topic is solved

Post by peter_ahk » 01 May 2024, 21:51

yeah not gonna post a 80000 lines script here mikey

the problem: when i have nothing behind = in my ini it will show C:\Users\Peter\AppData\Local\Temp in my edit field (that is if i use the value from the array that i did test and confirmed working with a messagebox here and that is also already in use elsewhere in my script working just fine)

anyway i found a solution in trying out things by loading the value again so i have it in a different format and that does work odly enought trying to set my new value with := gives the same C:\Users\Peter\AppData\Local\Temp result. so i have a solution i just dont understand why this happends with a value from array and not with something i just loaded and have in between %%

Post Reply

Return to “Ask for Help (v1)”