Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Search txt文件中的多重搜索字符串和计数_Search_Count_Autohotkey - Fatal编程技术网

Search txt文件中的多重搜索字符串和计数

Search txt文件中的多重搜索字符串和计数,search,count,autohotkey,Search,Count,Autohotkey,我无法将该值传递到另一个数组(ArrayValue),因此 我可以跟踪计数 我的目标:读取包含所有文本文件的文件夹 搜索文本文件内的数组集(即字符串) 每次匹配时,计数器应增加+1 然后在记事本中按顺序打印结果 前。 CAM_NWID=050RN=10 CAM_NWID=012RW=2 CAM_NWID=016RN=6 CAM_NWID=027RN=1 $^F8:: File := "*.txt" ;can include director

我无法将该值传递到另一个数组(ArrayValue),因此 我可以跟踪计数

  • 我的目标:读取包含所有文本文件的文件夹

  • 搜索文本文件内的数组集(即字符串)

  • 每次匹配时,计数器应增加+1

  • 然后在记事本中按顺序打印结果

    前。
    CAM_NWID=050RN=10

    CAM_NWID=012RW=2

    CAM_NWID=016RN=6

    CAM_NWID=027RN=1

  • $^F8::
    File := "*.txt"             ;can include directory -- * is wildcard
    FileHit := ""               ;for reading .txt file
    ArrayName:= []
    ArrayName[1]:= "CAM_NWID=ESH050RN"
    ArrayName[2]:= "CAM_NWID=ESH012RW"
    ArrayName[3]:= "CAM_NWID=ESH016RN"
    ArrayName[4]:= "CAM_NWID=ESH027RN"
    
    ArrayValue:=[]
    ArrayStore:=[]
    ArrayValue[j] := A_LoopField
    ArrayValue[j, k] := A_LoopReadLine
    ArrayCount := 0
    
    InputBox, Directory, Enter the searched directory, Leave empty to use the current directory. Subfolders will 
    
    be also searched., , 300, 150
    if ErrorLevel
    {
        MsgBox, Query canceled.
        Exit
    }
    
    Directory := RegExReplace(Directory, "\\$") ; Removes the leading backslash, if present.
    
    If Directory
    {
        If(!InStr(FileExist(Directory), "D"))
        {
            msgbox Invalid directory
            Exit
        }
        StringRight, DirectoryEndingChar, Directory, 1
        If(DirectoryEndingChar != "\")
            Directory .= "\"
    }
    
    
    Loop, %Directory%%File%, , 1
    {
       FileRead, FileCheck, %A_LoopFileLongPath%
       IfInString, FileCheck, %StringCheck%
          FileHit%A_Index% := A_LoopFileLongPath
    }
    
    Loop,%Directory%%File%, *.txt, FR
    {
    
    for key, val in ArrayName
    
    
        Loop, Read, %A_LoopFileFullPath%, objects.txt
        {
        
            IfInString, A_LoopReadLine, % val
            {
                StringReplace, CurrentLine, A_LoopReadLine, Name(wstring:64)=
                FileAppend, %CurrentLine%`n
                vText := CurrentLine
                StrReplace(vText, CurrentLine, "", vCount)
                ;;MsgBox, % CurrentLine" = " .vCount 
            
            If (CurrentLine = CurrentLine)
            {
            ArrayValue[key,k]:=ArrayValue.Insert(key,A_LoopReadLine) ;;this should be the the point where I can pass the value to another specific index in other array
            }
    
    
    ArrayCount+=1
    ArrayValue[ArrayCount]
    }
    }
    
    
    Loop % ArrayCount
    {
    element := ArrayValue[A_Index]
    MsgBox % "Element Number " . A_Index . " is " . ArrayValue[A_Index]
    }
    }
    return