Jump to content

Find and replace and generate logs


Recommended Posts

Func _fnr()
    $time = _Now()
    ;MsgBox(0, "hello", $timestr)
    $count = _GUICtrlListView_GetItemCount($ListView1)
    ;Local $logfile = $open & "\" & $time & ".log"
    Local $sLog = "itworks.log"
    MsgBox(0, "hello", $count)
    For $i = 0 To $count
        $find = _GUICtrlListView_GetItemText($ListView1, $i)                ;<====== 
        $replace = _GUICtrlListView_GetItemText($ListView1, $i, 1)          ;<======
        If StringStripWS($find, $STR_STRIPALL) = "" Then ContinueLoop       ;$find mustn't be empty
        If StringStripWS($replace, $STR_STRIPALL) = "" Then ContinueLoop    ;$reolace mustn't be empty
        MsgBox(0, "test", $find & " " & $replace)
        ;For $j = 1 To $FileList[0]         ;don't use more than one Filelist can be added to $List1
        For $j = 0 To _GUICtrlListBox_GetCount($List1) - 1
            $sFile = _GUICtrlListBox_GetText($List1, $j)
            MsgBox(0, "hello", $sFile,2)
            ;_ReplaceInFile($sLog, $sFile, $find, $replace)
        Next
    Next

    ;MsgBox(0, "Test", $a)
EndFunc   ;==>_fnr

 

 

Link to comment
Share on other sites

Thanks! Btw, I did this:

If $CmdLine[0] > 0 Then
    Global $FileList = _FileListToArrayRec($CmdLine[1], "*.*",1,1,1,2)
    $sLog = @ScriptDir& "\" & $date & ".log"
    For $i=1 to $FileList[0]
    For $j=2 to $CmdLine[0] Step 1
        If Mod($j,2)=0 Then
        ;$sFile=$CmdLine[1]
            $find=$CmdLine[$j]
            $replace=$CmdLine[$j+1]
            ;if @error Then ContinueLoop
        ;Else
        ;   $replace=$CmdLine[$j]
        ;   if @error Then ContinueLoop
        EndIf

    $sFile=$FileList[$i]
    _ReplaceInFile($sLog, $sFile, $find, $replace)
    Next
    Next
    Exit
EndIf

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...