How to write this variable List .= ??? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
d1niel84
Posts: 51
Joined: 20 Oct 2019, 12:28
Location: Germany

How to write this variable List .= ???

Post by d1niel84 » 19 Aug 2022, 14:12

Hello,
How to write it that i have the content and not the name in the FinalValueList? :crazy:

Code snippet

Code: Select all

FieldNumber := 2
Loop, Parse, A_LoopReadLine , `;
{
	Field%A_Index% = %A_LoopField%
}
FinalValueList .= "Field" FieldNumber  "`n"
thx
Daniel

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: How to write this variable List .= ???

Post by BoBo » 19 Aug 2022, 14:57

Code: Select all

Loop, Read, my.csv
	finalValueList .= StrSplit(A_LoopReadLine, ";").2  "`n"
MsgBox % finalValueList

d1niel84
Posts: 51
Joined: 20 Oct 2019, 12:28
Location: Germany

Re: How to write this variable List .= ???

Post by d1niel84 » 19 Aug 2022, 15:18

thx for the reply. I need all content later so i have to loop first.
And then i want to add this fieldnumber "2" content into the list. The field number is a variable = 2
Later i need 5 etc..
I think your solution doesnt work :problem:

User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: How to write this variable List .= ???  Topic is solved

Post by flyingDman » 19 Aug 2022, 16:09

Instead of

Code: Select all

FinalValueList .= "Field" FieldNumber "`n"
use

Code: Select all

FinalValueList .= Field%FieldNumber% "`n"

Code: Select all

Loop, Read, testcsv.csv
	{
	Loop, Parse, A_LoopReadLine , `;
		Field%A_Index% = %A_LoopField%
	FinalValueList .= Field%FieldNumber% "`n"
	}
msgbox % FinalValueList
but if you prefer to work with arrays:

Code: Select all

fileread, var, testcsv.csv
arr := []
for x,y in strsplit(var,"`n")
	arr.push([strsplit(y,",").2, strsplit(y,",").3])	; saves the 2dn and 3rd column in a subarray
msgbox % arr.3.2          								; 3rd row & 2nd of the 2 columns saved (i.e. column 3)
14.3 & 1.3.7

d1niel84
Posts: 51
Joined: 20 Oct 2019, 12:28
Location: Germany

Re: How to write this variable List .= ???

Post by d1niel84 » 20 Aug 2022, 00:56

Thanks, I will have a look at the array.
Greetings Daniel

Post Reply

Return to “Ask for Help (v1)”