Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/11/2017 in all areas

  1. OK. Here it is. The final output.txt is the exact copy of your example.txt - so said WinMerge (which was used for precise comparison) All this could be done more compact but I left it as is for better readability and understanding I included some comments, feel free to ask if you need more detailed explanations about the expressions Have fun ;FileDelete(@ScriptDir & '\output.txt') $a = FileRead(@ScriptDir & '\ahihi.txt') ;$a = FileRead(@ScriptDir & '\New For Process.txt') ; insert a newline before $00, $T etc if they are not preceded by colon $a = StringRegExpReplace($a, '(?<!^|:)(?=\$(?:00|01|03|10|20|25|30|40|45|110|115|120|T|F|200|220))', @crlf) ; delete all content behind $00: and \$200: $a = StringRegExpReplace($a, '(?<=\$00:|\$200:).+', "") ; delete whole lines $01, $03, $30 including newlines $a = StringRegExpReplace($a, '\$(?|01|03|30):.+\R', "") ; delete $=<$=T3*1 $=L01836000613000341*000341 and $=L01836000613000341*000341 things $a = StringRegExpReplace($a, '(\$=<\$=T3\*\d\s*)?(\$=L\d+\*\d+)?', "") ; delete $=P1298*NNNN and \$=> $a = StringRegExpReplace($a, '(\$=P\d+\*\d+)|(\$=>)', "") ; delete footnotes, not including n1 etc or next $x $a = StringRegExpReplace($a, '(\$%\$\?\$%[^\$]+Footnotes[^\$]+)(?=n\d+)?', "") ; insert a newline before $%$?$%, some $T and $M $a = StringRegExpReplace($a, '((?<!^|:)(?=\$%\$\?\$%))|((?<=[a-z]:)(?=\$[TM]))', @crlf) ; move $=S from end of line to start of next line $a = StringRegExpReplace($a, '(\$=S)(\R)', "$2$1") ; OPTIONALS ; replace unwanted newlines in text parts by a horizontal space $a = StringRegExpReplace($a, '(\$T|\$%\$\?\$%)\V+?\K(?<=\w|\.)\R(?=\h?\w)', " ") ; replace multi horizontal spaces by only one $a = StringRegExpReplace($a, '\h+', " ") ; remove horizontal space between $I and $U $a = StringRegExpReplace($a, '(?<=\$I)\h+(?=\$U)', "") FileWrite("output.txt", $a)
    1 point
  2. Malkey

    Shorten the code

    Another example. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> _Checkbox_EditCtrl() Func _Checkbox_EditCtrl() Local $hGUI = GUICreate("Example", 400, 410) Local $Number = 20, $iRows = 10, $iSpacing = 5 Local $Error[$Number] ; Array holding Checkbox controls ids Local $Edit[$Number] ; Array holding Edit controls ids ; Create checkbox controls. For $i = 0 To $Number - 1 ; id's are sequentially numbered starting at $Error[0] $Error[$i] = GUICtrlCreateCheckbox("ChkBx" & $i + 1, $iSpacing + (Int($i / $iRows) * 190), ((40 * Mod($i, $iRows)) + $iSpacing), 80, 20) ; Next ; Create Edit controls. For $i = 0 To $Number - 1 ; id's are sequentially numbered starting at $Edit[0] $Edit[$i] = GUICtrlCreateEdit("Edit" & $i + 1, $iSpacing + 80 + (Int($i / $iRows) * 190), ((40 * Mod($i, $iRows)) + $iSpacing), 95, 40, BitOR($ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL), BitOR($WS_EX_CLIENTEDGE, $WS_EX_ACCEPTFILES)) ; GUICtrlSetState($Edit[$i], $GUI_Disable) Next GUISetState(@SW_SHOW, $hGUI) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ;, $idClose ExitLoop Case $Error[0] To $Error[($Number - 1)] $iIndex = $msg - $Error[0] ; Array Index GUICtrlSetState($Edit[$iIndex], (BitAND(GUICtrlRead($Error[$iIndex]), $GUI_CHECKED) = $GUI_CHECKED ? BitOR($GUI_Enable, $GUI_FOCUS) : $GUI_Disable)) EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>_Checkbox_EditCtrl
    1 point
  3. And then there was this. #include <GUIConstantsEx.au3> $Form1 = GUICreate("Form1", 158, 202) $Edit1 = GUICtrlCreateEdit("", 8, 16, 137, 121) GUICtrlSetData(-1, "Edit1" & @CRLF & "another") $Label1 = GUICtrlCreateLabel("Total Number of Lines : ", 8, 160, 110, 17) $additionsLabel = GUICtrlCreateLabel("", 120, 160, 36, 17) GUISetState(@SW_SHOW) While 1 GUICtrlSetData($additionsLabel, StringSplit(GUICtrlRead($Edit1), @LF)[0]) ; This is true. $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
    1 point
  4. BrewManNH

    Gui Runtime

    This should give you some ideas on where to go from here. $Timer = TimerInit() For $I = 1 To 10000 $seconds = TimerDiff($Timer) / 1000 $iDays = Int($seconds / 86400) $iHours = Int(($seconds - ($iDays * 86400)) / 3600) $iMinutes = Int((($seconds - ($iDays * 86400)) - ($iHours * 3600)) / 60) $iSeconds = Int(((($seconds - ($iDays * 86400)) - ($iHours * 3600) - ($iMinutes * 60)) * 60) / 60) ConsoleWrite($iDays & " Days " & $iHours & " Hours " & $iMinutes & " Minutes " & $iSeconds & " Seconds since this was started" & @CRLF) Sleep(1000) Next
    1 point
  5. Nice. The more I have infos, the more I can make suggestions
    1 point
  6. why Autoit not updated from 2015 is it Dead Project Or Problems not found or new futures not required.
    1 point
  7. Using the Windows 'Scripting.Dictionary' also seems to be a quite fast method to remove duplicate rows , of course attached example needs some extra polishing regarding reading and processing the input file in chunks, it's just a quick proof of concept. #include <file.au3> Dim $aRecords $timer = TimerInit() Global $oDict = ObjCreate('Scripting.Dictionary') $oDict.CompareMode = 1 If Not _FileReadToArray("test.txt", $aRecords) Then MsgBox(4096, "Error", " Error reading log to Array error:" & @error) Exit EndIf ConsoleWrite("Records ORG: " & $aRecords[0] & @CRLF) ConsoleWrite(TimerDiff($timer) & @CRLF & @CRLF) For $x = 1 To $aRecords[0] If Not $oDict.Exists($aRecords[$x]) Then $oDict.Add($aRecords[$x], 1) EndIf Next ConsoleWrite("Records Dup Removed: " & $oDict.Count() & @CRLF) ConsoleWrite(TimerDiff($timer) & @CRLF & @CRLF) ; None duplicate rows For $i In $oDict.Keys() ConsoleWrite($i & @crlf) Next
    1 point
×
×
  • Create New...