Pilot123 Posted July 12, 2015 Share Posted July 12, 2015 (edited) I need help please,If you have a loop that reads a dynamic 2-d Array(2 colums). How can you go about doing something (example: show message box), only when a new row is introduced to the array and also if both elements in a row changes at the same time. Do nothing if you remove a row.1.) Let's say for example in loop 1 of the code: the array has 'no' elements in it, then do nothing.2.) Loop 2, Row Col0 Col1 [0] A B ; do something, because a new row is intoduced in the array, with new elements3.) Loop 3, Row Col0 Col1 [0] C B ; do nothing, because only Col0 of Row0, value has changed4.) Loop 4, Row Col0 Col1 [0] C B [1] D E ; do something, because new row is introduced, Row15.) Loop 5, Row Col0 Col1 [0] F B [1] G E ; do nothing, because only col0 of rows 0 and 1, has changed5.) Loop 6, Row Col0 Col1 [0] G E ; do nothing, because only row0 from the previous loop was removed. Edited July 12, 2015 by Pilot123 Link to comment Share on other sites More sharing options...
JohnOne Posted July 12, 2015 Share Posted July 12, 2015 (edited) See where you have "do something"?Put the code you want to, there.If you do not understand that, then post an example proper. Edited July 12, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 12, 2015 Moderators Share Posted July 12, 2015 Pilot123,This works for me with the cases you posted:expandcollapse popupLocal $aArray[][] = [["A", "B"]] ConsoleWrite(_ArrayCheck($aArray) & @CRLF) Local $aArray[][] = [["C", "B"]] ConsoleWrite(_ArrayCheck($aArray) & @CRLF) Local $aArray[][] = [["C", "B"], ["D", "E"]] ConsoleWrite(_ArrayCheck($aArray) & @CRLF) Local $aArray[][] = [["F", "B"], ["G", "E"]] ConsoleWrite(_ArrayCheck($aArray) & @CRLF) Local $aArray[][] = [["G", "E"]] ConsoleWrite(_ArrayCheck($aArray) & @CRLF) Func _ArrayCheck($aCurrent_Array) Static Local $aPrevious_Array Local $bRet = False ; Check size of new array $iPrev_Size = UBound($aPrevious_Array) $iCurr_Size = UBound($aCurrent_Array) Select Case $iCurr_Size < $iPrev_Size ; Deleted row Case $iCurr_Size > $iPrev_Size ; Added row $bRet = True Case Else ; Need to check if both elements in a row have changed For $i = 0 To $iCurr_Size - 1 If ($aCurrent_Array[$i][0] <> $aPrevious_Array[$i][0]) And ($aCurrent_Array[$i][1] <> $aPrevious_Array[$i][1]) Then $bRet = True ; No need to check further ExitLoop EndIf Next EndSelect ; Store current array for next $aPrevious_Array = $aArray ; Return result Return $bRet EndFuncPlease ask if you have any questions.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Pilot123 Posted July 12, 2015 Author Share Posted July 12, 2015 (edited) Edited July 12, 2015 by Pilot123 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 12, 2015 Moderators Share Posted July 12, 2015 Pilot123,I take it you are lost for words when you look at the solution I posted?M23 kylomas 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Pilot123 Posted July 12, 2015 Author Share Posted July 12, 2015 LOLMelba23, you made my day!! I was struggling with this all day.I adapted the code a little bit, to get a feeling of how I'll use it in the rest of my code.Thanks a million!!expandcollapse popupLocal $aArray[][] = [["A", "B"]] ;ConsoleWrite(_ArrayCheck($aArray) & @CRLF) $status = _ArrayCheck($aArray) MsgBox(0, "My Array","Did it change? "&$status,2) Local $aArray[][] = [["C", "B"]] ;ConsoleWrite(_ArrayCheck($aArray) & @CRLF) $status = _ArrayCheck($aArray) MsgBox(0, "My Array","Did it change? "&$status,2) Local $aArray[][] = [["C", "B"], ["D", "E"]] $status = _ArrayCheck($aArray) MsgBox(0, "My Array","Did it change? "&$status,2) Local $aArray[][] = [["F", "B"], ["G", "E"]] ;ConsoleWrite(_ArrayCheck($aArray) & @CRLF) $status = _ArrayCheck($aArray) MsgBox(0, "My Array","Did it change? "&$status,2) Local $aArray[][] = [["G", "E"]] ;ConsoleWrite(_ArrayCheck($aArray) & @CRLF) $status = _ArrayCheck($aArray) MsgBox(0, "My Array","Did it change? "&$status,2) Func _ArrayCheck($aCurrent_Array) Static Local $aPrevious_Array Local $bRet = False ; Check size of new array $iPrev_Size = UBound($aPrevious_Array) $iCurr_Size = UBound($aCurrent_Array) Select Case $iCurr_Size < $iPrev_Size ; Deleted row Case $iCurr_Size > $iPrev_Size ; Added row $bRet = True Case Else ; Need to check if both elements in a row have changed For $i = 0 To $iCurr_Size - 1 If ($aCurrent_Array[$i][0] <> $aPrevious_Array[$i][0]) And ($aCurrent_Array[$i][1] <> $aPrevious_Array[$i][1]) Then $bRet = True ; No need to check further ExitLoop EndIf Next EndSelect ; Store current array for next $aPrevious_Array = $aArray ; Return result Return $bRet EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 12, 2015 Moderators Share Posted July 12, 2015 Pilot123,Delighted I could help.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jchd Posted July 13, 2015 Share Posted July 13, 2015 I question the very need for that. Array elements don't change or get added by white magic. So it must be your code which does that. Doing that, why not maintain a changed flag at the time you change the array, such changed flag you can test and reset in other part of your code? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
guinness Posted July 13, 2015 Share Posted July 13, 2015 I agree, if you're adding or deleting and then afterwards checking, is quite an expensive operation every time. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 13, 2015 Moderators Share Posted July 13, 2015 jchd & guinness,I imagined that the array was generated spontaneously from an external source - _FileListToArray style - so that there was not an automatic notification of any change and a direct check was the only way to go.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jchd Posted July 13, 2015 Share Posted July 13, 2015 Then Isn't it a good reason to make a private modified version checking that on the fly? Just asking, I ain't counting cycles. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Pilot123 Posted July 13, 2015 Author Share Posted July 13, 2015 (edited) Hi everyone,The code I have needs to check a website http://poweralert.co.za/poweralert5/slider_1.php that has a slider 'graph' in it. The content changes every half a hour.The code needs to check when a specific color column group is added. The reference point( in my code) is the red arrow at the bottom that represents the current time slot.Lets say the time now is 20h16, then the red arrow will point to the column(time slot) 20h00 - 20h30. Lets say I want to monitor the red column groups. When you initially start the code it will identify two red column groups. The first red column group is at the red arrow, and the end of that group(to the right), ends in the 21h30 and 22h00 column, which means that the first column is currently active from 20h00 and will end at 22h00. Column two starts at 07h00 and continues to 21h00 but does not necessarily end there. So, if you look at that page again just after 20h30(when webpage content refreshes), you'll see that all columns shifted one position to the left from the arrows perspective. The first red column group would now be active from 20h30 up to 22h00, but as you can see, it is still the same group(not a new group). If you look at the second red column group, you'll see that it still starts at 07h00 and now continues up to 09h30(still the same group).The amount of red groups during a 24 hour period may change, as well of the size of the red group. One red group could just as well be only two columns wide(representing 1 full hour).What I want from the code is to notify me(by e-mail) when it is initially launched, how many red groups there are, as well as the beginning and end times of each. So for this example in the picture below it will indicate: Two groups identified: Group 1: 20h00 - 22h00 Group 2: 07h00 - 21h00. The code will then check again in a couple of minutes(31min) if a new group is identified, if it can still only see the two previously identified groups, it does nothing. Like mentioned before the code will send me an e-mail when a new group is identified. If someone can help me to improve the code (make it shorter), I will appreciate it .Here is my code so far, had some help from other members of this forum with snippets of the code.expandcollapse popup#include <IE.au3> ; for display only #include <MsgBoxConstants.au3> ; for showing a message box #include <Array.au3> #Include <String.au3> #Include <INET.au3> ;Global $aArrayB[64] ; Will make space for 64 elements in 1-D array and name it $aArrayB. ; --------------------------------------------------------------------------------------------------------------------------------- ; Step -1: ; Create an IE browser window ; --------------------------------------------------------------------------------------------------------------------------------- Local $oIE = _IECreate("http://www.poweralert.co.za/poweralert5/slider_1.php", 0, 0, 0) ; loading url hidden, don't wait for page loading $var = _IELoadWait($oIE, 0, 20000) ; wait for page loading -> timeout 20 sec MsgBox(0,"","Page Loaded...", 1) ; --------------------------------------------------------------------------------------------------------------------------------- ; Step -2: ; Get the 24hour timespan from the Poweralert slider (from left to right) and write it to an array ; --------------------------------------------------------------------------------------------------------------------------------- If $var = 1 Then ; if the _IELoadWait command is succesfull (Success=1), then do the following => $source = _INetGetSource("http://www.poweralert.co.za/poweralert5/slider_1.php") ; Gets the source from an URL without writing a temp file Else ; else if the _IELoadWait command fails then do the following => MsgBox($MB_ICONWARNING, "Timeout", "...loading page -> maybe bad connection!", 3) ; display a message box with an exclamation-point icon. This message box will timeout after 3sec or select the OK button Exit ; terminates your script EndIf $aInput = _StringBetween($source, '<td valign="top">', '</td>') ; Find strings between two string delimiters inside the html source. _StringBetween returns an array (We will get "1","2', ....."24' that represents hours of the day in 24h format. Every half of an hour is represented by the string " " $aGetTime = _StringBetween($source, 'class="text02">', '</td>') ; Gets the time from html source and will be placed in array $aGetTime[0] _ArrayDisplay($aGetTime) ; --------------------------------------------------------------------------------------------------------------------------------- ; Step -3: ; The script below accesses the dynamic 1D-array created by "$aInput = _StringBetween($source, '<td valign="top">', '</td>')" ; This dynamic 1D-array will have either 64 or 65 elements(index0 to index63/64). Reason for this is that for every half ; of an hour(example: 13h30),the html code generated by the php script on the poweralert.co.za server, adds an extra ; real space( ) at the end of the text on the poweralert time slider, that we don't need. ; This script checks if the array, "$aInput" has that extra element included, or not. If the array only includes the 64 ; elements we need, then we also assign the variable "$aMatches" to that array, and use this new name for further processing. ; If "$aInput" includes the extra unwanted 64th element(from Index0 to 64), then create a new 1d-array "$aMatches", that contains ; index0 up to index 63 (64elements), and copy indexes from the input array to this new array. ; This new array "$aMatches", will be used for further processing. ; --------------------------------------------------------------------------------------------------------------------------------- Local $iRows = UBound($aInput, $UBOUND_ROWS) ; Total number of rows found in the array. ;MsgBox($MB_SYSTEMMODAL, "Row count", "The array has " & $iRows & " rows") ; Displays a message box showing amount of rows counted If $iRows = 64 then ; example: if total rows equals 64, then we know the array is the size we need. ;$aArrayA = $aInput Local $aArrayA[$iRows-14] if IsArray($aInput) Then for $i = 14 to UBound($aInput) -1 ; this loops in order to read index0 up to 63, and write it to the new array $aArrayA[$i-14] = $aInput[$i] ; clone data from $aInput to this new array, "$aArrayA" Next _ArrayDisplay($aArrayA, "Final Array") ; display unformatted $aArrayA EndIf ; _ArrayDisplay($aArrayA, "Final Array") ; display $aArrayA ElseIf $iRows = 65 then Local $aArrayA[$iRows-15] ; create another array with ( 65-1=64 when implemented) rows, this space will be filled by contents of $aInput if IsArray($aInput) Then ; check if "$aInput" is an array for $i = 14 to UBound($aInput) -2 ; this loops in order to read index0 up to 63, and write it to the new array $aArrayA[$i-14] = $aInput[$i] ; clone data from $aInput to this new array, "$aArrayA" Next _ArrayDisplay($aArrayA, "Final Array") ; display unformatted $aArrayA EndIf Else MsgBox($MB_SYSTEMMODAL, "Out of range", "Array out of range !!") EndIf ; --------------------------------------------------------------------------------------------------------------------------------- ; Step -4: ; This script will format all elements of the 1-d array "$aArrayA", to the 24Hour format. ; This will also format all the (" ") elements, to the 24Hour format(every 1/2 hour of an hour) ; --------------------------------------------------------------------------------------------------------------------------------- if isarray($aArrayA) then ;check if it is an array if ubound($aArrayA) >= 50 then ;check if it have atleast 64 items because you are using up to 64 items ($aArrayA[63] is the 64th item) $aArrayA[0] = $aGetTime[0] ;writes the time from $aGetTime[0] to $aArrayA[0] For $i = 1 To 49 If $aArrayA[$i] <> " " then $aArrayA[$i] = $aArrayA[$i] & ":00" Else Endif Next For $i = 1 To 49 If $aArrayA[$i] = " " then $var1 = $aArrayA[$i - 1] $var2 = StringReplace($var1, ":00", "") $aArrayA[$i] = $var2 & ":30" Else Endif Next _ArrayDisplay($aArrayA, "Output") ; display formatted $aArrayA Else ;~ MsgBox(0,"","less then 64 items found in $aArrayA array") filewrite('debug.txt', "$aArrayA only had " & ubound($aArrayA) & " items" & @CRLF) EndIf Else ;~ MsgBox(0,"","$aArrayA was not an array!!") filewrite('debug.txt', "$aArrayA was not an array" & @CRLF) EndIf ; --------------------------------------------------------------------------------------------------------------------------------- ; Step -5: ; Get all images for poweralert slider, from red arrow on slider to the end on the right of slider, and write it to an array ; --------------------------------------------------------------------------------------------------------------------------------- Global $aArrayB[50] ; Will make space for 50 elements in 1-D array and name it $aArrayB. For $i = 17 to 66 ; for image no.17 to image no.66 in html source gives a total of 50 images (Image no.17 is from the red cursor up to image no.66 at the end of the slider to the right) Local $oImg = _IEImgGetCollection($oIE, $i) ; get references to all 50 Images (image 17 to 66). -----Just get info for images no.17 up to No.66 $sInfo = $oImg.nameProp $e = $i - 17 ; we have an array with 50 elements but the last index is 49, ( start index at 0 and end at 649). ;MsgBox($MB_SYSTEMMODAL, "64 Images", $sInfo) $aArrayB[$e] = $sInfo ;Assign some data ; ConsoleWrite($arrayA[$e] & @LF) Next _IEQuit($oIE) ; quit IE _ArrayDisplay($aArrayB, "1D display") ; display array for all images of poweralert slider, from red arrow on slider to the end on the right. ; ------------------------------------------------------------------------------------------ ; Step -6: ; Code by "Chimp" - Autoit Forum ; https://www.autoitscript.com/forum/topic/173678-group-array-indexes-with-the-same-values/ ; ------------------------------------------------------------------------------------------ ;#include <Array.au3> ; Input arrays ;Local $aArrayA[14] = ["red", 3, "red", 2, "red", 13, "red", 6, "red", 3, "red", 10, "red", "red"] ; Array with lookup values ;Local $aArrayB[14] = ["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India", "Juliet", "Kilo", "Lima", "Mike", "November"] Local $aResult = _FindGroups($aArrayB, "bar_red.gif", 0) If Not @error Then _ArrayDisplay($aResult, @extended & " groups found") Else MsgBox(0, "Error", "no groups found") EndIf ; now use indexes found in the $aResult array as indexes to point to values in your second array $aArrayA ; (we just use indexes from the first array to get the wanted data from the second array) Local $aMatches[UBound($aResult)][4] ; create another array with same number of rows as $aResult to hold first array and corresponding matches from the second array if IsArray($aResult) Then for $i = 0 to UBound($aResult) - 1 $aMatches[$i][0] = $aResult[$i][0] ; clone data from $aResult $aMatches[$i][1] = $aResult[$i][1] $aMatches[$i][2] = $aArrayA[$aResult[$i][0]] ; Get values from $aArrayA according to indexes from the $aResult array $aMatches[$i][3] = $aArrayA[$aResult[$i][1]] Next _ArrayDisplay($aMatches, "Correspondences with second array") EndIf ; -------------------------------------------------------------------------- ; General purpose function to find how a value is groupped within an 1D array ; $aArrayB : the input array ; $sTarget : the value to search string or value (i.e. 0 is <> from "0") ; $iCase : Case sensitive search 0=no 1=yes ; ; returns : on success: ; a 2D array with as many rows as many groups are found ; [n][0] and [n][1] index of first [0] and last [1] position of the n group ; @extended contains the number of rows (groups) found ; on error: ; returns -1 and set @error to 1 ; ------------------------------------------------------------------------- Func _FindGroups(ByRef $aArrayB, $sTarget, $iCase = 0, $iCompare = 2) Local $Targets = _ArrayFindAll($aArrayB, $sTarget, 0, 0, $iCase, $iCompare) If IsArray($Targets) Then _ArraySort($Targets, 1) Local $i = UBound($Targets) Local $aStack[$i + 1][2] ; make room for all possible indexes (only some of them will be usually used) $i -= 1 ; start parsing from last element back to first _Push($aStack, $Targets[$i]) While $i If $Targets[$i] = $Targets[$i - 1] - 1 Then ; do nothin and continue parsing Else _Push($aStack, $Targets[$i]) _Push($aStack, $Targets[$i - 1]) EndIf $i -= 1 WEnd _Push($aStack, $Targets[$i]) Return SetError(0, $aStack[0][0], _ArrayExtract($aStack, 1, $aStack[0][0])) EndIf Return SetError(1, 0, -1) EndFunc ;==>_FindGroups Func _Push(ByRef $aStack, $Value) ; 2D stack for internal use $aStack[0][1] = Not $aStack[0][1] $aStack[0][0] += $aStack[0][1] $aStack[$aStack[0][0]][Not $aStack[0][1]] = $Value EndFunc ;==>_Push ; ################################################################################### ; Set the end time of the selected group, by refering to the group's last time slot ; ################################################################################### Local $iMatchRows = UBound($aMatches, $UBOUND_ROWS) ; Total number of rows found in the array. MsgBox($MB_SYSTEMMODAL, "$aMatches", "The array has " & $iMatchRows & " rows. Getting the correct end times for the selected group") ; Displays a message box showing amount of rows counted. ---- Use for debugging if IsArray($aMatches) Then ; check if the array named "$aMatches" is indeed an array. If it is, then do the following... for $i = 0 to UBound($aMatches) - 1 $aSplit = StringSplit($aMatches[$i][3], ':') If $aSplit[1] = 23 and $aSplit[2] = 30 Then $aMatches[$i][3] = "00:00" ElseIf $aSplit[2] = 30 Then $aMatches[$i][3] = $aSplit[1]+1 & ":00" Else EndIf IF $aSplit[2] = 00 Then $aMatches[$i][3] = $aSplit[1] & ":30" Else EndIf Next _ArrayDisplay($aMatches, "Modified $aMatches-- Actual group start and end times") Else EndIf ; ------------------------------------------------------------------------------------------ ; Step -8 ; ; ------------------------------------------------------------------------------------------ Edited July 13, 2015 by Pilot123 Link to comment Share on other sites More sharing options...
JohnOne Posted July 13, 2015 Share Posted July 13, 2015 You are under using the IE UDFIt's ideal for this sort of thing.If you're going to use _INetGetSource then there is no point of even opening an IE window. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Pilot123 Posted July 13, 2015 Author Share Posted July 13, 2015 I'm still new at this. So far the only way I know, or can find, to get to my goal is the code I currently have. Could you give me an example please. Link to comment Share on other sites More sharing options...
kylomas Posted July 13, 2015 Share Posted July 13, 2015 (edited) Pilot123,I might get the table like this...#include <ie.au3> #include <array.au3> ; http://www.poweralert.co.za/poweralert5/slider_1.php Local $oIE = _IECreate("http://www.poweralert.co.za/poweralert5/slider_1.php", 0, 0, 0) ; loading url hidden, don't wait for page loading $var = _IELoadWait($oIE, 0, 20000) ; wait for page loading -> timeout 20 sec MsgBox(0,"","Page Loaded...", 1) local $aTBL ; Variable for result table from html Local $otbls = _IETableGetCollection($oIE) ; get collection of all tables, @EXTENDED is # of tables returned local $idxLastTable = @extended ; save @EXTENDED if not isobj($otbls) then exit msgbox(17,'ERROR','No tables returned') ; Exit if no tables $otbls = _IETableGetCollection($oIE, $idxLastTable-1) ; get last table object pointer using index saved from @EXTENDED $aTBL = _IETableWriteToArray($otbls, true) ; Write result array _arraydisplay($aTBL) ; Display arraykylomas Edited July 13, 2015 by kylomas code correction Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now