I would be very grateful

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
legyster
Posts: 106
Joined: 13 Apr 2020, 15:17

I would be very grateful

18 Apr 2020, 15:12

there are thousands of lines, I would like to search for a word from the bottom up when I find the word
in the written file, inform me with a text box,
I would like to put a limit on him to search from the bottom up, just look at 50 lines if you don't find him stop looking.
garry
Posts: 3771
Joined: 22 Dec 2013, 12:50

Re: I would be very grateful

18 Apr 2020, 15:58

example with few lines for test

Code: Select all

aac=
(
Line1 This is a test
Line2 This is a test
Line3 This is a test
Line4 This is the test
Line5 This is a test
Line6 This is var test
Line7 This is a test
Line8 This is a test
Line9 This is a test
)
;x1:= "D:\Temp\MyScript.txt"
;fileread,aac,%x1%               ;- read txt-file to memory
i1=0
i2=0
e:=""
Loop,parse,aac,`n,`r            ;- parse each line by `n ascii-10 (EndOfLine ascii 13,10 )
  {
  x:= A_LoopField               ;- line in variable aac
  i1++
  if (i1=8)
    break                       ;- break here
  if (( inStr(x, " the " ) || inStr(x, " var " )))
    {
    i2++
    e .= i1 . "-" . x . "`r`n"
    }
  }
msgbox,Total lines=%i1%`nfound total %i2%-Lines=`n%e%
exitapp
legyster
Posts: 106
Joined: 13 Apr 2020, 15:17

Re: I would be very grateful

18 Apr 2020, 17:30

Code: Select all

~sc03F::
word01:="            " ;-search word here
FileRead, var, C:\Users\computer\Desktop\MyScript.log
arr := strsplit(var, "`n", "`r")
loop, % ln := arr.length() {
	currln := arr[ln - a_index + 1]
	if % instr(currln, word01) {
		msgbox the word was found
		Break
	}
}
return
what do i have to do for him to search only up to 50 lines
Odlanir
Posts: 659
Joined: 20 Oct 2016, 08:20

Re: I would be very grateful

19 Apr 2020, 03:11

Code: Select all

~sc03F::
word01 := "            " ;-search word here
FileRead, var, C:\Users\computer\Desktop\MyScript.log
arr := strsplit(var, "`n", "`r")
loop, % ln := arr.length() {
   currln := arr.Pop()
   if (instr(currln, word01)) {
      MsgBox % "The word " word01 " was found at line " Ln-A_Index+1
      Break
   }
   if (A_Index > 50) {
      break
   }
}
return
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Google [Bot], roblive and 391 guests