I have a txt file i want to read content of each and save it into a variable
For eg :- read file1.txt, line1 is saved in variable1
Line2 in variable 2
And so on
Pls hlp in baby steps
Read txt file save content of each line in variable
Re: Read txt file save content of each line in variable
Fileread document into variable
Have a look at the https://autohotkey.com/docs/commands/StringSplit.htm command and function. Split on `n be sure to omit `r
Try something post code if you get stuck.
Alternatively you can use a parsing loop - https://autohotkey.com/docs/commands/LoopParse.htm - (see example #2)
Have a look at the https://autohotkey.com/docs/commands/StringSplit.htm command and function. Split on `n be sure to omit `r
Try something post code if you get stuck.
Alternatively you can use a parsing loop - https://autohotkey.com/docs/commands/LoopParse.htm - (see example #2)
Re: Read txt file save content of each line in variable
Code: Select all
pFile :="pass.txt"
oTexto := Object()
oFile := FileOpen(pFile,"r")
If (!IsObject(oFile)) {
Msgbox 0x40000,, % "ERROR Opening file " pFile
ExitApp
}
While (!oFile.AtEOF) {
oTexto[A_index] := RegExReplace(oFile.ReadLine(),"\v+")
}
oFile.Close()
run prefix %oTexto1% open_this_on_coordinates_x1y1 postfix
run prefix %oTexto2% open_this_on_coordinates_x2y2 postfix
run prefix %oTexto3% open_this_on_coordinates_x3y3 postfix
run prefix %oTexto4% open_this_on_coordinates_x4y4 postfix
run prefix %oTexto5% open_this_on_coordinates_x5y5 postfix
,
,
,
run prefix %oTexto10% open_this_on_coordinates_x10y10 postfix
pls help
Re: Read txt file save content of each line in variable
alternative is i make one more txt file containing "open_this_on_coordinates_x1y1" values
then
read from both files
then
loop % otext0.maxindex()
{
run prefix otexto[A_index] ptestp[A_index] postfix
sleep 25 sec
}
as both files will always contain 10 lines so no problem will occur acc to me
then
read from both files
then
loop % otext0.maxindex()
{
run prefix otexto[A_index] ptestp[A_index] postfix
sleep 25 sec
}
as both files will always contain 10 lines so no problem will occur acc to me
-
- Posts: 440
- Joined: 28 Apr 2018, 21:59
Re: Read txt file save content of each line in variable
Unless you really want to make it an object, just use the Loop, Read, pass.txt and save it that way.
For example
For example
Code: Select all
Loop, Read, pass.txt
Line%A_Index% := A_LoopReadLine
Who is online
Users browsing this forum: CrowexBR, mebelantikjaya, ositoMalvado and 290 guests