Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/16/2015 in all areas

  1. you inspired me: without arrayadds or redim - still needs the sorting on the first array #include <Array.au3> Global $aFirstArray[10][2] = [["Type1", "Subtype1"],["Type1", "Subtype2"], _ ["Type1", "Subtype3"],["Type2", "Subtype4"], _ ["Type2", "Subtype5"],["Type3", "Subtype5"], _ ["Type4", "Subtype6"],["Type4", "Subtype7"], _ ["Type5", "Subtype8"],["Type5", "Subtype9"]] _ArrayDisplay($aFirstArray, "This") ; This is the desired output array ; Like a Parent(Type) header, then Children (Subtypes) bel;ow it Global $sFinal = "" $lasttype = "" for $i = 0 to ubound($aFirstArray) - 1 $type = $aFirstArray[$i][0] If $type = $lasttype then $sFinal &= $aFirstArray[$i][1] & "," Else $sFinal &= $aFirstArray[$i][0] & "," $sFinal &= $aFirstArray[$i][1] & "," EndIf $lasttype = $type next $aFinal = stringsplit(stringtrimright($sFinal , 1), "," , 2) _ArrayDisplay($aFinal)
    1 point
  2. Same idea than boththose, without _Array functions (but the array must be sorted for it works). #Include <Array.au3> Local $aFirstArray[10][2] = [["Type1", "Subtype1"],["Type1", "Subtype2"], _ ["Type1", "Subtype3"],["Type2", "Subtype4"], _ ["Type2", "Subtype5"],["Type3", "Subtype5"], _ ["Type4", "Subtype6"],["Type4", "Subtype7"], _ ["Type5", "Subtype8"],["Type5", "Subtype9"]] Local $aResult[ UBound($aFirstArray) * 2], $sLast, $n = 0 For $i = 0 To UBound($aFirstArray) - 1 If $aFirstArray[$i][0] <> $sLast Or $n = 0 Then $sLast = $aFirstArray[$i][0] $aResult[$n] = $sLast $n += 1 $aResult[$n] = $aFirstArray[$i][1] Else $aResult[$n] = $aFirstArray[$i][1] EndIf $n += 1 Next Redim $aResult[$n] _ArrayDisplay($aResult) An other idea could be to use a SQLite memory database, (interesting for a big array, I think).
    1 point
  3. Gianni

    Parsing/converting array!

    quite easy also using _ArrayUniqe and _ArrayFindAll (bonus: there is no need to sort by Type) #include <Array.au3> ; In the following array, you see that Type1 one has 3 SubTypes, ; Subtype1, Subtype2, and Subtype3. ; ; Type 2 has 2 subtypes, type3, only 1 etc... ; ; Of course this is not fixed size array and the anount of subtypes vary ; The array is sorted by type though Global $aFirstArray[10][2] = [["Type1", "Subtype1"],["Type1", "Subtype2"], _ ["Type1", "Subtype3"],["Type2", "Subtype4"], _ ["Type2", "Subtype5"],["Type3", "Subtype5"], _ ["Type4", "Subtype6"],["Type4", "Subtype7"], _ ["Type5", "Subtype8"],["Type5", "Subtype9"]] _ArrayDisplay($aFirstArray, "This") Local $aTypes = _ArrayUnique($aFirstArray) ; list of single types that are in the $aFirstArray Local $aWantedArray[UBound($aFirstArray) + $aTypes[0]] ; make room for output. All subtypes + single Types Local $aSubTypesNdx, $iPointer = 0 ; internal use ; For $i = 1 To $aTypes[0] $aSubTypesNdx = _ArrayFindAll($aFirstArray, $aTypes[$i]) ; find all subtypes of the same type $aWantedArray[$iPointer] = $aTypes[$i] ; header for next subtypes $iPointer += 1 ; point to next free element For $iSubtype = 0 To UBound($aSubTypesNdx) - 1 ; peek all subtypes $aWantedArray[$iPointer] = $aFirstArray[$aSubTypesNdx[$iSubtype]][1] ; populate output $iPointer += 1 ; point to next free element Next ; _ArrayDisplay($aWantedArray) ; shows WantedArray while is populated Next _ArrayDisplay($aWantedArray, "To This")
    1 point
  4. #include <Array.au3> ; In the following array, you see that Type1 one has 3 SubTypes, ; Subtype1, Subtype2, and Subtype3. ; ; Type 2 has 2 subtypes, type3, only 1 etc... ; ; Of course this is not fixed size array and the anount of subtypes vary ; The array is sorted by type though Global $aFirstArray[10][2] = [["Type1", "Subtype1"],["Type1", "Subtype2"], _ ["Type1", "Subtype3"],["Type2", "Subtype4"], _ ["Type2", "Subtype5"],["Type3", "Subtype5"], _ ["Type4", "Subtype6"],["Type4", "Subtype7"], _ ["Type5", "Subtype8"],["Type5", "Subtype9"]] _ArrayDisplay($aFirstArray, "This") ; This is the desired output array ; Like a Parent(Type) header, then Children (Subtypes) bel;ow it Global $aSecondArray[0] $lasttype = "" for $i = 0 to ubound($aFirstArray) - 1 $type = $aFirstArray[$i][0] If $type = $lasttype then _ArrayAdd($aSecondArray , $aFirstArray[$i][1]) Else _ArrayAdd($aSecondArray , $aFirstArray[$i][0]) _ArrayAdd($aSecondArray , $aFirstArray[$i][1]) EndIf $lasttype = $type next _ArrayDisplay($aSecondArray, "To This") **This is totally assuming the first array is sorted by type as in the example
    1 point
  5. You can add Labels and PopUp menu for each Label.
    1 point
  6. Free is the best kind of cheap
    1 point
  7. Obviously not....it was just an example. You don't need a loop I was just showing that I can get any number line. $text = "this is some text on line 1" & @CRLF & "text on line 2" & @CRLF & "another line of text (line 3)" & @CRLF & "line 4" & @CRLF & "this is the final line (5)" $linenum = 4 $pattern = "^(?:[^\n]*\n){" & $linenum - 1 & "}([^\n]*)" $test = StringRegExp($text, $pattern, 1) ConsoleWrite('Text on line ' & $linenum & ' is: "' & StringStripCR($test[0]) & '"' & @CRLF) EDIT: jchd beat me to it by milliseconds
    1 point
  8. It's possible without making an array of all the lines: $text = "this is some text on line 1" & @CRLF & "text on line 2" & @CRLF & "another line of text (line 3)" & @CRLF & "line 4" & @CRLF & "this is the final line (5)" For $linenum = 1 to 5 $pattern = "^(?:[^\n]*\n){" & $linenum - 1 & "}([^\n]*)" $test = StringRegExp($text, $pattern, 1) ConsoleWrite('Text on line ' & $linenum & ' is: "' & StringStripCR($test[0]) & '"' & @CRLF) Next
    1 point
  9. Are you sure the text consists of lines? Meaning, does it actually contain @CR and/or @LF characters? If so, then this should work: $text = "hello1" & @CRLF & "hello2" & @CRLF & "hello3" & @CRLF & "hello4" & @CRLF & "hello5" $array_of_lines = StringRegExp($text, "(?m)^.*$", 3) MsgBox(0, 0, "Third line: " & $array_of_lines[2]) (Note that the third line is array element 2, as the array result of that StringRegExp call is 0-based.) Of course, if speed is paramount you should benchmark all possible approaches.
    1 point
  10. Test it and don't make assumptions.
    1 point
  11. nathan546

    Config file

    How do you make a config file.
    1 point
  12. You can automate visual keyboard W + R > OSK.EXE or Run > OSK.EXE After that, ControlClick maybe ? MouseClick ?
    1 point
  13. Use the proper #pragma() statement to set it to produce a Console Exe. #pragma compile(Console, true) Jos
    1 point
  14. trancexx

    Int64 to hex.

    You mean something like this: $iNumber = -1067353106670363250 ConsoleWrite($iNumber) ConsoleWrite(" = ") $tInt64 = DllStructCreate("int64") DllStructSetData($tInt64, 1, $iNumber) $tSubStructure = DllStructCreate("ptr;ptr", DllStructGetPtr($tInt64)) $sHexQword = Hex(DllStructGetData($tSubStructure, 2)) & Hex(DllStructGetData($tSubStructure, 1)) ConsoleWrite($sHexQword & @CRLF)
    1 point
×
×
  • Create New...