loungesraka.blogg.se

Idupe windows
Idupe windows











idupe windows

Then in AutoIt, we'll do same and use StringSplit with Chr(1), leading to these new pics : I think Chr(1) is not a bad choice (it shouldn't be found in usual strings) and JS will again return a string, inserting a Chr(1) at the end of each row of the array.

idupe windows

To avoid this, we could use array.join() instead of array.toString() and choose the separator we want. There is now an extra element in the returned string and the pic above reflects it : 13 elements instead of 12 => Array variable has incorrect number of subscripts or subscript dimension range exceeded.: The script exits with Fatal error and Autoscript console shows : Let's change the string element "DD2" to "D,D2" and let's run the preceding script, this will happen :

Idupe windows code#

Just made a simplification in the code and applied it to the concerned posts of precedent page in this there is a potential issue with the JavaScript native separator (comma) used in array.toString() to separate rows, with a fatal error in AutoIt script.įor example, imagine there is a comma in any string of the column to be sorted. Same for "B2" (which was on 5th row) etc. The pic in the middle shows the "links" between the unsorted column 2 and the sorted column 2įor example the cell "A2" WAS placed on the 2nd row before it was sorted, so now it's easy to "grab" all the other columns concerning "A2" after it's sorted, then fill the new empty matrix. run ( "ArraySorting2D", $o_ExtColmn, $o_Numeric, $o_ascending ) $o_Obj = 0 ConsoleWrite("$o_SortData = " & $o_SortData & = Local $o_SortArry = StringSplit ( $o_SortData, ',', 2 ) 1D array of sorted elements (+ indexes b4 sort) _ArrayDisplay($o_SortArry, "$o_SortArry") Local $o_Index empty 2D array to be filled Local $iRow = - 1 For $i = 0 To Ubound ( $o_SortArry ) - 1 Step 2 $iRow += 1 For $j = 0 To $iNb_Cols - 1 $o_Index = $o_array ] Next Next Return $o_Index = EndFunc Func _ErrorHandler ( $oError ) EndFunc from JsArray.toString() Return $o_SortArry EndIf = original array is 2D from now on = Local $o_ExtColmn 1D array of UNsorted elements For $i = 0 To UBound ( $o_array ) - 1 $o_ExtColmn = $o_array Next Local $o_SortData = $o_Obj. run ( "ArraySorting1D", $o_array, $o_Numeric, $o_ascending ) $o_Obj = 0 Local $o_SortArry = StringSplit ( $o_SortData, ',', 2 ) comma delim. AddCode ( $o_CBlock ) = If $iNb_Cols = 0 Then when original array is 1D Local $o_SortData = $o_Obj. #ce #include #include "3" LarsJ Opt ( "MustDeclareVars", 1 ) Global $g_iRows = 10000, $g_iCols = 6, $g_aArray _Example2 ( ) Func _Example2 ( ) _Generate _All ( $g_aArray ) _ArrayDisplay ( $g_aArray, "UNsorted", Default, Default, Default, _ "Strings|Integers*|Floats*|Dates*|Times*|R/C*" ) Local $hTimer2 = TimerInit ( ) Local $iCol_Sort = 0 Local $x_Result2 = _ArraySortJs ( $g_aArray, $iCol_Sort, False, True ) col $iCol_Sort, numeric (True), ascending (True) If Then Exit Msgbox ( 0, "_ArraySortJs", "error " & ) ConsoleWrite ( "JScript: sorted in = " & Int ( TimerDiff ( $htimer2 ) ) & " ms" & ) _ArrayDisplay ( $x_Result2, "sorted (col " & $iCol_Sort & ")", Default, Default, Default, _ "Strings|Integers*|Floats*|Dates*|Times*|R/C*" ) EndFunc = Func _Generate _All ( ByRef $g_aArray ) LarsJ ConsoleWrite ( "$g_iRows = " & $g_iRows & " $g_iCols = " & $g_iCols & ) $g_aArray = FAS _Random2DArrayAu3 ( $g_iRows, "sifdtr", "abcdefghijklmnopqrstuvwxyz" ) EndFunc =>_Generate_All #FUNCTION# = Name.: _ArraySortJs = Func _ArraySortJs ( $o_array, $o_Column = 0, $o_Numeric = True, $o_ascending = True ) = If Not IsArray ( $o_array ) Then Return SetError ( 1, 0, - 1 ) Local $iNb_Cols = Ubound ( $o_array, 2 ) If ( $iNb_Cols = 1 ) And ( $o_Column > 0 ) Then Return SetError ( 1, 0, - 1 ) If ( $iNb_Cols > 1 ) And ( $o_Column > $iNb_Cols - 1 ) Then Return SetError ( 1, 0, - 1 ) = Local $o_CBlock = _ 'function GetArray(arr)' = Local $ObjErr = ObjEvent ( "AutoIt.Error", "_ErrorHandler" ) Local $o_Obj = 0 $o_Obj = ObjCreate ( "ScriptControl" ) $o_Obj. _ArrayDisplay($x_Result, "sorted (col " & $iCol_Sort & ")") Local $x_Result = _ArraySortJs($arry, $iCol_Sort, False, True) col $iCol_Sort, string, ascending _ArrayDisplay($arry, "UNsorted (col " & $iCol_Sort & ")") $x_Result = _ArraySortJs($arry, 0, False, False) col 0, string, descending Local $x_Result = _ArraySortJs($arry, 0, True, True) col 0, numeric (True), ascending (True)













Idupe windows