Jump to content

Alecsis1

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by Alecsis1

  1. Hello! Try something like this Opt('MustDeclareVars', True) Local $colItems, $objWMIService, $objItem $objWMIService = ObjGet("winmgmts:") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL") ; If IsObj($colItems) Then For $objItem In $colItems ConsoleWrite("Model: " & $objItem.Model & @CRLF) ConsoleWrite("S/N : " & StringStripWS($objItem.SerialNumber, 3) & @CRLF) ; cut out excessive spaces ConsoleWrite(@CRLF) ; make output easier to read Next ConsoleWrite("Done" @CRLF) Else MsgBox(16, "Error", "No drives Found.") EndIf ; Exit All my disks present:
  2. Too many sites like this generate versions and URLs via scripts. Sad but true 😠 For example try this direcy link to .zip archive https://download-chromium.appspot.com/dl/Win
  3. Hi! There's no need to do Local $sHTML = BinaryToString($sHTMLBIN) Your $sHTMLBIN is already a text string 🙂
  4. To avoid excessive useless comparisons replace For $i = 1 To UBound($array)-1 ; after sort $array[0] is the <max> by definition If $array[$i] = $maxvalue Then $counter +=1 Next with For $i = 1 To UBound($array)-1 ; after sort $array[0] is the <max> by definition If $array[$i] < $maxvalue Then ExitLoop ; eliminate redundant compares $counter +=1 Next Test with array of 1 million numbers #include <Array.au3> ; Local $array[1000000], $i, $counter, $maxvalue ; $array[0]=22 $array[1]=13 $array[2]=11 $array[3]=99 $array[4]=2 $array[5]=17 $array[6]=99 $array[7]=23 $array[8]=99 $array[9]=74 Local $hTimer, $DeltaT ConsoleWrite("Array size = " & UBound($array) & @CRLF) $hTimer = TimerInit() For $i = 10 To UBound($array)-1 $array[$i] = Random(0, 98, 1) Next $DeltaT = TimerDiff($hTimer) ConsoleWrite("Delta T (init) = " & $DeltaT & @CRLF) $hTimer = TimerInit() _ArraySort($array, 1) ; sort in descending order $DeltaT = TimerDiff($hTimer) ConsoleWrite("Delta T (sort) = " & $DeltaT & @CRLF) ; $maxvalue = $array[0] ; max value $counter = 1 ; # of max value detections ; $hTimer = TimerInit() For $i = 1 To UBound($array)-1 ; after sort $array[0] is the <max> by definition If $array[$i] < $maxvalue Then ExitLoop ; eliminate redundant compares $counter +=1 Next $DeltaT = TimerDiff($hTimer) ConsoleWrite("Delta T (count) = " & $DeltaT & @CRLF) ConsoleWrite("Max value " & $maxValue & " occurs " & $counter & " time(s)." & @CRLF) ; --- end of job --- >"C:\DevTools\AutoIt3\SciTE\..\AutoIt3.exe" /ErrorStdOut "D:\Alecsis\Prog\AutoIt\_Debug\tt4.au3" Array size = 1000000 Delta T (init) = 1436.309 Delta T (sort) = 52488.0108 Delta T (count) = 0.0094 Max value 99 occurs 3 time(s). >Exit code: 0 Time: 54.13
  5. One more example #include <Array.au3> ; Local $array[10], $i, $counter, $maxvalue ; $array[0]=22 $array[1]=13 $array[2]=11 $array[3]=99 $array[4]=2 $array[5]=17 $array[6]=99 $array[7]=23 $array[8]=99 $array[9]=74 _ArraySort($array, 1) ; sort in descending order ; $maxvalue = $array[0] ; max value $counter = 1 ; # of max value detections ; For $i = 1 To UBound($array)-1 ; after sort $array[0] is the <max> by definition If $array[$i] = $maxvalue Then $counter +=1 Next ConsoleWrite("Max value " & $maxValue & " occurs " & $counter & " time(s)." & @CRLF) ; --- end of job ---
  6. Hello! Try something like this: Func web_extraction($sToDo) ; $sToDo: 'Extract' = extracts information from websites.. ; $sToDo: 'GetInfo' = return information collected before ; Local Static $var[362] ; for example, 362 items If $sTodo = 'Extract' Then ..does some code... ...extracts information from websites.. and fills the array with info $var[0] = "extracted info 1" $var[0] = "extracted info 2" ... etc ... Return EndIf If $sTodo = 'GetInfo' Then ...does some code if needed Return $var EndIf EndFunc
  7. Hello everyone! Cross-platform support imho is not too necessary. AutoIt was designed as a Windows-oriented tool from the very start… Multithreading? Easy to say but may take a long time and too much efforts to implement. Other features: Variables/constants must be pre-declared. Therefore no chances for a whole lot of nasty bugs caused by such undeclared ones. Basic set of preprocessor capabilities as #define/#undefine, #if/#elseif/#endif might be useful. At this moment, Local and Global declarations in main module are equivalent. I suggest Local declarations to be not accessible within functions, for example Global $a Local $b ; some code .... Func Test() ConsoleWrite($a) ; Ok ConsoleWrite($b) ; should cause compile-time error EndFunc Introduce Scope/EndScope block for temporary local variables/constants, and declare own local ones like here Local $a, $b, $c ; some code .... Scope Local $a ; not the same as $a declared above Local $x, $y ; accessible within this block only ; some code .... EndScope ConsoleWrite($x) ; ERROR! $x is not declared at this point While(True) Local $x ; same behavior as within scope/endsope block above ; some code .... WEnd For $i = 1 to 10 ; if $i is not declared yet, it's declared and visible within For/Next only Local $k ; same behavior as within scope/endsope block above ; some code .... Next ; and so on PS Sorry for my weak English
  8. Hello! Try something like this. Btw, sorry for my bad English… vimmyMS.zip
×
×
  • Create New...