Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/02/2014 in all areas

  1. Thanks very much. The error message was: 1 - which I discovered means the file cannot be found. So then I looked at the file path and name - - and eventually figured that the @ScriptDir meant that the .au3 file, and the file to be processed, had to be in the same folder/directory. Once I changed the file name from the full path, and put the .au3 file in the same folder - it worked! So thank you for your help. I needed a program like this a few years ago (to turn long text files with lots of records in into files with one record in - for further text analysis purposes) and gave up at that point. So this is great for me - it will help in my research. Having discovered AutoIt and recalling some Basic programming years ago, I might even try my hand now at writing other text processing routines. Stephen
    1 point
  2. ??? Click here: Rev 0.47.0 - 10 Sep 13
    1 point
  3. Of couse yes. _FileListToArrayRec to search the txt. and fileread+dllstructure. Saludos
    1 point
  4. I don't know c well but you can populate an autoit dllstruct with the contents of a file. Give a little more info on your goal.
    1 point
  5. This isn't a recursion problem! Your code produces a memory leak because you load everytime the bitmap in GDI format without releasing it! Either you release it in the loop or you move the _GDIPlus_BitmapCreateFromMemory() functions outside the main loop and release it when closing the script. Br, UEZ
    1 point
  6. I see you still haven't had any suggstions here, I did some tinkering and here is what I came up with: #include "JSON.au3" #include "array.au3" #NoTrayIcon $s = ' [{"z1":"vanueh","on":true}]' $s2 = '{"error":"Error MSG"}' Parse($s) Parse($s2) Exit Func Parse($sTemp) If StringInStr($sTemp, ",") Then $sTemp = StringRegExpReplace($sTemp, "[\[\]{}]", "") $sBreak = StringSplit($sTemp, ",") For $a = 1 To $sBreak[0] $t = _JSONDecode("{" & $sBreak[$a] & "}") _ArrayDisplay($t, "multi " & $a & " of " & $sBreak[0]) Next Else $t = _JSONDecode($sTemp) _ArrayDisplay($t, "single") EndIf EndFunc ;==>Parse It seemed to me the easiest way to deal with the issue. When the result is nested, strip all brackets, split by comma, then add brackets back to each element of the resulting array. Hopefully this offers you some way to move forward with your script. Ian
    1 point
  7. JohnOne

    Memory leak?

    Move declaration outside of function Global $processed Func processed() $processed = IniRead($dir, "Process", "Input", "") EndFunc ;==>processed
    1 point
  8. Here is another example using the Levenshtein Distance or Edit distance algorithm. Also, a string alignment, longest common subsequence. or _TraceBack function which uses the same table/matrix created by the _EditDistance() function. The results of the TraceBack function, eg.:- vintner- | || writ-ers No. of Differences: 5 appropriate m-eaning ||||| ||||| ||| approximate matching No. of Differences: 7 are written to console. MsgBox does not format the display very well. In the above two examples - referring to the middle line between the two strings - the vertical lines indicate matches, the spaces are differences. ; #include <Math.au3> #include <array.au3> ;Edit distance, Levenshtein distance, or Dynamic time warping ; http: www.csse.monash.edu.au/~lloyd/tildeAlgDS/Dynamic/Edit/ ; String alignment, sequence alignment, longest common subsequence. or _TraceBack approach. ; http: books.google.com.au/books?id=STGlsyqtjYMC&pg=PA215&lpg=PA215&dq=string+difference+edit+distane&source=bl&ots=kiQ8vAL_v3&sig=TovNa041KRZDRGIa5bVI9HBMp1E&hl=en&ei=nd-iSt-SGIGYkQXd3OWBBA&sa=X&oi=book_result&ct=result&resnum=9#v=onepage&q=&f=false ; http: en.wikipedia.org/wiki/Sequence_alignment ; http: en.wikipedia.org/wiki/Longest_common_subsequence_problem ; [url="http://www.autoitscript.com/forum/index.php?showtopic=40843&view=findpost&p=303848"]http://www.autoitscript.com/forum/index....p?showtopic=40843&view=findpost&p=303848[/url] Local $sD Local $s1 = "appropriate meaning", $s2 = "approximate matching" ;Local $s1 = "vintner", $s2 = "writers" ;Local $s1='test', $s2='jesT' ;Local $s1 = "456043", $s2 = "1234567" Local $aArr = _EditDistance($s1, $s2) _TraceBack('', '', '', $aArr, StringLen($s1), StringLen($s2), $s1, $s2, $sD) ConsoleWrite(@CRLF & $sD & @CRLF & "No. of Differences: " & $aArr[StringLen($s1)][StringLen($s2)] & @CRLF) ;MsgBox(0, "", $sD & @CRLF & @CRLF & "No. of Differences: " & $aArr[StringLen($s1)][StringLen($s2)]) ;_ArrayDisplay($aArr) Func _EditDistance($s1, $s2) Local $m[StringLen($s1) + 1][StringLen($s2) + 1], $i, $j $m[0][0] = 0; boundary conditions For $j = 1 To StringLen($s2) $m[0][$j] = $m[0][$j - 1] + 1; boundary conditions Next For $i = 1 To StringLen($s1) $m[$i][0] = $m[$i - 1][0] + 1; boundary conditions Next For $j = 1 To StringLen($s2); outer loop For $i = 1 To StringLen($s1) ; inner loop If (StringMid($s1, $i, 1) = StringMid($s2, $j, 1)) Then $diag = 0; Else $diag = 1 EndIf $m[$i][$j] = _Min($m[$i - 1][$j] + 1, _ ; insertion (_Min($m[$i][$j - 1] + 1, _ ; deletion $m[$i - 1][$j - 1] + $diag))) ; substitution Next Next ;_TraceBack('', '', '', $m, StringLen($s1), StringLen($s2), $s1, $s2, $Dis); ;_ArrayDisplay($m) Return $m ; $m[StringLen($s1)][StringLen($s2)] EndFunc ;==>_EditDistance Func _TraceBack($row1, $row2, $row3, $m, $i, $j, $s1, $s2, ByRef $sD) Local $diag, $diagCh If ($i > 0) And ($j > 0) Then $diag = $m[$i - 1][$j - 1] $diagCh = '|'; If (StringMid($s1, $i, 1) <> StringMid($s2, $j, 1)) Then $diag += 1 $diagCh = ' '; } EndIf If ($m[$i][$j] >= $diag) Then _TraceBack(StringMid($s1, $i, 1) & $row1, $diagCh & $row2, StringMid($s2, $j, 1) & $row3, $m, $i - 1, $j - 1, $s1, $s2, $sD); change or match ElseIf $m[$i][$j] = ($m[$i - 1][$j] + 1) Then ; delete _TraceBack(StringMid($s1, $i, 1) & $row1, $diagCh & $row2, '-' & $row3, $m, $i - 1, $j, $s1, $s2, $sD); Else _TraceBack("-" & $row1, $diagCh & $row2, StringMid($s2, $j, 1) & $row3, $m, $i, $j - 1, $s1, $s2, $sD); insertion EndIf ElseIf ($i > 0) Then _TraceBack(StringMid($s1, $i, 1) & $row1, " " & $row2, '-' & $row3, $m, $i - 1, $j, $s1, $s2, $sD); ElseIf ($j > 0) Then _TraceBack("-" & $row1, " " & $row2, StringMid($s2, $j, 1) & $row3, $m, $i, $j - 1, $s1, $s2, $sD); Else ; $i==0 and $j==0 ;ConsoleWrite( @CRLF & $row1 & @CRLF & $row2 & @CRLF & $row3 & @CRLF) $sD = $row1 & @CRLF & $row2 & @CRLF & $row3 & @CRLF EndIf EndFunc ;==>_TraceBack ;
    1 point
×
×
  • Create New...