Jump to content

ezzetabi

Active Members
  • Posts

    1,917
  • Joined

  • Last visited

Everything posted by ezzetabi

  1. What about that? Func _xcopyWithDialog($sStartingDir, $sDestDir, $sSettings = '/i/c/e/d/h/r/y') Local $iPid, $iSDSize, $iODSize If FileExists($sStartingDir) And StringInStr(FileGetAttrib($sStartingDir), 'd') Then $iPid = Run(@comspec & ' /c xcopy "' & $sStartingDir & '" "' & $sDestDir & '" ' & $sSettings) $iSDSize = DirGetSize($sStartingDir) ProgressOn ( "XCopy", "Coping...") While ProcessExists($iPid) $iODSize = DirGetSize($sDestDir) ProgressSet(Round(100 * $iODSize / $iSDSize) ) Sleep(100) WEnd ProgressOff( ) Else Return -1 EndIf EndFunc
  2. Nice job Proph, but you should always put all func in the bottom or in the begin of the script. Putting Functions in the middle as you did is ugly (even if it works exactly at the same way...). In fact your program seems incomplete at the first look. I usually even put a EXIT just before the functions, in order to make clear that the main program is ended, if I need OnAutoItStart() I put it as first function. The program is more tidy that way... ;Main program Exit Func OnAutoItStart() ;Blah EndFunc ;Other funcs....
  3. ...I hate this kind of answers... Why not use XXCopy? It permit also copying NTFS rights! So? What? He asked something different! just use $cmdline[] if $cmdline[0] > 1 Then _CopyDirWithProgress($cmdline[1], $cmdline[2]) ;Some error checking here endif
  4. Grrr blindwig, why you never commented my func? Is it more or less the same...
  5. @Proph It is pretty easy, inside the _FileSeach function subfolders are added in the $sBuffer list. Just check if the name you want exclude matches. If it does do not add it. But I can't do it outright, since I have no time... :| @blitzkrg dirmove is pretty straightforward, just changes those FileCopy with FileMove and just before the end use some thing like: If $sLost <> '' Then;tries to write the log somewhere. If FileWrite($sDestDir & 'notcopied.txt',$sLost) = 0 Then If FileWrite($sOriginalDir & 'notcopied.txt',$sLost) = 0 Then FileWrite(@WorkingDir & '\notcopied.txt',$sLost) EndIf EndIf Else DirRemove ($sOriginalDir, 1) EndIf So the original dir is removed if everything went allright, otherwise unmoved files and all folders will still stay there. About subfolders or not, it is pretty useless. Coping only the root files is extemly easy. Help yourself.
  6. Maybe people should just drop the idea of learning scripting languages... The only two parameters of the func are $sOriginalDir $sDestDir What they could mean?
  7. There is no need of thinking about useless scripts, just use the seach button.
  8. 0.00000000000000101 in base two is about 0.00003814697265625 [ that is (1/2^15) + (1/2^17) ] in base ten... something is wrong. If it is not a bug probably something is wrong in your code. I have a question, not to brag about my code, but since I already done it why do not use my implementation? If you want a real _any2any converter just use the two function altoghter like _Dec2Any(_Any2Dec())...
  9. Wikipedia math sometime have little mistakes or imprecision. Anyway, the idea is simple, since every number is the sum of its digits*base^position (starting from 0) a non iteger have values where position is negative.
  10. Something like this? http://www.autoitscript.com/forum/index.php?showtopic=6899 N00b? Aren't you?
  11. Also accept non integers. http://www.autoitscript.com/forum/index.php?showtopic=7282
  12. Considering the lack of answers I would say that non actually care.
  13. So be it, new version. Also some bug fixing... #include <Array.au3> Dim $Array[101] $Array[1]=100 For $X=1 to 100 if $x<>35 Then $Array[$X]=Int(Random(0, 111)) Else $Array[$X]=$X EndIf Next _ArraySort($Array) $Out='' For $c = 1 to 100 $Out = $out & $c&'='&$Array[$c] & ' ' Next $Out = $Out & @LF $Timer=TimerInit() $Pos=_ArrayBinarySearch($Array,35,1) $ABST=TimerDiff($Timer) $Timer2=TimerInit() $Pos2=_IntBinarySearch($Array,35,1,100) $IBST=TimerDiff($Timer2) $Out=$out & "----ABS----" & @CRLF & "POS:" & $Pos & @CRLF & "Time:" & $ABST & @CRLF & "----IBS----" & @CRLF & "POS:" & $Pos2 & @CRLF & "Time:" & $IBST MsgBox(0,"Stats",$Out) ClipPut($Out) Func _IntBinarySearch(ByRef $avSortedArray, $vSeek, $iStartingPoint, $iEndingPoint) Local $iPivot If $iStartingPoint < 0 Or $iEndingPoint > UBound($avSortedArray) Then $iPivot = -1 Else While $iEndingPoint <> $iStartingPoint $iPivot = $iStartingPoint + Round( ($iEndingPoint - $iStartingPoint) * ($vSeek - $avSortedArray[$iStartingPoint]) / ($avSortedArray[$iEndingPoint] - $avSortedArray[$iStartingPoint]) ) If $iPivot < $iStartingPoint Then $iPivot = $iStartingPoint ElseIf $iPivot > $iEndingPoint Then $iPivot = $iEndingPoint EndIf If $avSortedArray[$iPivot] = $vSeek Then $iEndingPoint = $iPivot $iStartingPoint = $iPivot ElseIf $vSeek < $avSortedArray[$iPivot] And $iEndingPoint <> $iPivot Then $iEndingPoint = $iPivot ElseIf $iStartingPoint <> $iPivot Then $iStartingPoint = $iPivot Else $iPivot = -1 ExitLoop EndIf WEnd EndIf Return $iPivot EndFunc
  14. $sT = 'If they make mistakes, lets follow them! (Remainder lesson)' $sPass = 'a pass!' MsgBox(16,'', _Rot($st, $sPass, 0)) MsgBox(16,'', _Rot($st, $sPass, 1)) Func _Rot(ByRef $sInput, $sPass, $bMode) Local $sChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz' Local $iNofC = StringLen($sChars) Local $c, $iPos, $sChr Local $ipl = StringLen($sPass) Local $isl = StringLen($sInput) Local $aiPass[$ipl] For $c = 0 to $ipl - 1 $aiPass[$c] = Asc(StringMid($sPass, $c + 1, 1)) + 17 Next $sPass = 0 For $c = 1 to $isl $sChr = StringMid($sInput, $c, 1) $iPos = StringInStr($sChars, $sChr, 1) If $iPos > 0 Then If $bMode = 0 Then $sChr = StringMid($sChars, _Mod($aiPass[Mod($c - 1, $ipl)] + $iPos, $iNofC), 1) Else $sChr = StringMid($sChars, _Mod(- $aiPass[Mod($c - 1, $ipl)] + $iPos, $iNofC), 1) EndIf EndIf $sInput = StringLeft($sInput, $c - 1) & $sChr & StringTrimLeft($sInput, $c) Next Return $sInput EndFunc Func _Mod($iDividend, $iDivisor) Local $iMod If $iDivisor <> 0 Then If $iDividend < 0 Then $iDividend = $iDividend * -1 $iMod = Mod($iDividend, $iDivisor) if $iMod = 0 Then Return $iMod Else Return $iDivisor - $iMod EndIf EndIf Return Mod($iDividend, $iDivisor) Else SetError(1) Return '-1.#IND' EndIf EndFunc Exit
  15. As usual binary search it seeks in a sorted array. But instead of using O(log n) time in the average case it should use O(log log n) but it works only with numbers not with every comparable type. ;Scroll down. Check Ezzetabi's post.
  16. The good old seach button... About using non .bmp files the simplest idea is converting them using topng. The basic idea is: 1- convert the non .bmp in a bmp with a different name. 2- set that bmp as background. 3- when you need to change, delete that bmp e restart at point one. So the original file is preserved and only one file at time is in the .bmp format. (This is the soultion 'Run!' uses) Forget about .html since this UDF works only without active desktop.
  17. Func to start any file type with its associated program: Func _ShellExecuteDllCall($sCmd, $sVerb = 'Open', $sArg = '', $sFolder = '') Local $aRet $aRet = DllCall("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", $sVerb, _ "string", $sCmd, "string", $sArg, "string", $sFolder, "long", @SW_SHOWNORMAL) If $aRet[0] > 32 Then Return 1 Else Return 0 EndIf ;return will be 0 if something goes wrong. EndFunc ;==>_ShellExecuteDllCall
  18. Ponterless programming, Fortran style. Just pass two arrays to _ListActivate, inizialize a iterator to 0 that is the sentinel ending node and enjoy. A little test program Dim $a[1], $b[1] Dim $i = 0;Zero is a sentinel node at the end of the list _ListActivate($a, $b) _AddNode(100, $i, $a, $b) _AddNode(200, $i, $a, $b) _AddNode(400, $i, $a, $b) _BackUp($i, $a) _AddNode(300, $i, $a, $b) MsgBox(0,'', 'Add node test') $i = 0 While 1 _Advance($i, $a) If @error Then ExitLoop MsgBox(0,'', _Retrieve($i, $a)) WEnd _Advance($i, $a);pointing to 100 _Advance($i, $a);pointing to 200 _DelNode($i, $a, $b) MsgBox(0,'', 'Delete test') $i = 0 While 1 _Advance($i, $a) If @error Then ExitLoop MsgBox(0,'', _Retrieve($i, $a)) WEnd Exit The code itself: Func _ListActivate(ByRef $avList, ByRef $avSet) ReDim $avList[2][3], $avSet[3] $avList[0][0] = 0;Previous node $avList[0][1] = 0;Value of the node $avList[0][2] = -1;Next node, 0 is a dummy sentinel node $avSet[0] = 1;Logical size of the list $avSet[1] = 2;Real size EndFunc ;_AddNode adds before the itrPos Func _AddNode($vValue, $itrPos, ByRef $avList, ByRef $avSet) Local $iPos $iPos = $avSet[0] $avList[$iPos][1] = $vValue $avList[$iPos][2] = $itrPos $avList[$iPos][0] = $avList[$itrPos][0] $avList[ $avList[$itrPos][0] ][2]= $iPos $avList[$itrPos][0] = $iPos $avSet[0] = $avSet[0] + 1 If $avSet[0] > $avSet[1] / 2 Then __Double($avList, $avSet) EndIf EndFunc Func _DelNode(ByRef $itrPos, ByRef $avList, ByRef $avSet) If $itrPos <> 0 Then Local $iPos = $itrPos $avSet[0] = $avSet[0] - 1 _Advance($itrPos, $avList) $avList[$avList[$iPos][2]][0] = $avList[$iPos][0] $avList[$avList[$iPos][0]][2] = $avList[$iPos][2] If $avSet[0] > 1 Then $avList[$iPos][0] = $avList[ $avSet[0] ][0] $avList[$iPos][1] = $avList[ $avSet[0] ][1] $avList[$iPos][2] = $avList[ $avSet[0] ][2] $avList[$avSet[0]][1] = 0 Else $avList[$iPos][1] = 0 $avList[0][0] = 0 $avList[0][1] = 0 $avList[0][2] = -1 EndIf $avList[$avList[$iPos][0]][2] = $iPos $avList[$avList[$iPos][2]][0] = $iPos If $avSet[0] < $avSet[1] / 2 Then __Half($avList, $avSet) EndIf Else SetError(1) EndIf EndFunc Func _Advance(ByRef $itrPos, ByRef $avList) $itrPos = $avList[ $itrPos ][2] If $itrPos = 0 Then SetError(1) EndFunc Func _BackUp(ByRef $itrPos, ByRef $avList) $itrPos = $avList[ $itrPos ][0] If $itrPos = 0 Then SetError(1) EndFunc Func _Retrieve(ByRef $itrPos, ByRef $avList) If $itrPos <> 0 Then Return $avList[$itrPos][1] Else SetError(1) Return 0 EndIf EndFunc Func __Double(ByRef $fst, ByRef $snd) $snd[1] = $snd[1] * 2 ReDim $fst[ $snd[1] ][3] EndFunc Func __Half(ByRef $fst, ByRef $snd) $snd[1] = $snd[1] / 2 ReDim $fst[ $snd[1] ][3] EndFunc Bug alert, not deeply tested.
  19. Func _MaxMin(ByRef $aArray, ByRef $vMin, ByRef $vMax) Local $c, $iSp If Mod(UBound($aArray), 2) = 0 Then $iSp = 2 If $aArray[0] < $aArray[1] Then $vMin = $aArray[0] $vMax = $aArray[1] Else $vMin = $aArray[1] $vMax = $aArray[0] EndIf Else $iSp = 1 $vMin = $aArray[0] $vMax = $aArray[0] EndIf For $c = $iSp To UBound($aArray) - 1 Step 2 If $aArray[$c] < $aArray[$c + 1] Then If $aArray[$c] < $vMin Then $vMin = $aArray[$c] EndIf If $aArray[$c + 1] > $vMax Then $vMax = $aArray[$c + 1] EndIf Else If $aArray[$c + 1] < $vMin Then $vMin = $aArray[$c + 1] EndIf If $aArray[$c] > $vMax Then $vMax = $aArray[$c] EndIf EndIf Next EndFunc
  20. Since it is a CSV file, why do not you just modify it using Autoit directly? You can load the whole file in a variant, split it at @LF (or @CR or @CRLF as needed) and sort that array. Just make a function that compare correctly the dates or the IDs and use a sorting function that compare lines using that function. E.g. Comparing function for dates in the fourth field of a CSV array... #include <date.au3> Func _Before($sfst, $ssnd) Local $afst = StringSplit($sfst, ',') Local $asnd = StringSplit($ssnd, ',') $afst = $afst[4] $asnd = $asnd[4] $afst = StringSplit($afst, '/') $asnd = StringSplit($asnd, '/') Return _DateToDayValue($afst[1], $afst[2], $afst[3]) < _DateToDayValue($asnd[1], $asnd[2], $asnd[3]) EndFunc
  21. While 1 If _IsPressed(0x1) Then MsgBox(0,'', 'You pressed the left button!') ExitLoop EndIf Sleep(1) WEnd Func OnAutoItstart() Global $DllUser32 = DllOpen('user32') EndFunc Func OnAutoItExit() DllClose($DllUser32) EndFunc Func _IsPressed($hexKey) ; $hexKey must be the value of one of the keys. ; _IsPressed will return 0 if the key is not pressed, 1 if it is. Local $aR $aR = DllCall($DllUser32, "int", "GetAsyncKeyState", "int", $hexKey) If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then Return 1 Else Return 0 EndIf EndFunc ;==>_IsPressed
  22. You may like this...
  23. My script crashed? Very strange. I tested also in very big folders but after a while it gave the correct result. Anyway, if you improved the script share it with us improvements are always welcomed.
  24. I read your post better, if you just want to write a file list in a file. Change the return part of the UDF from If $sOutPut = '' Then $aNull[0] = 0 Return $aNull Else Return StringSplit(StringTrimRight($sOutPut, 1), @LF) EndIf to Return StringTrimRight($sOutPut, 1) (and remove $aNull from declarations) So the function will return a @lf separed list, ready to be write where you want.
×
×
  • Create New...