jugador Posted July 15, 2021 Share Posted July 15, 2021 (edited) Slight modification of @Melba23 _ArrayColInsert. version 1.0 (support) > insert single blank row > insert 1D Array expandcollapse popup#include <Array.au3> Local $o_Eg[6][] = [['A', 11, 22, 33, 44], _ ['B', 11, 22, 33, 44], _ ['C', 11, 22, 33, 44], _ ['D', 11, 22, 33, 44], _ ['E', 11, 22, 33, 44], _ ['F', 11, 22, 33, 44]] _ArrayDisplay($o_Eg) Local $fillArray[6] = ['XX', 'XX', 'XX', 'XX', 'XX', 'XX'] _ArrayDisplay($fillArray) __ArrayColInsert($o_Eg, 5) _ArrayDisplay($o_Eg) __ArrayColInsert($o_Eg, 0) _ArrayDisplay($o_Eg) __ArrayColInsert($o_Eg, 0, $fillArray) _ArrayDisplay($o_Eg) __ArrayColInsert($o_Eg, UBound($o_Eg, 2), $fillArray) _ArrayDisplay($o_Eg) ; #FUNCTION# ============================================================================= ; Name...........: __ArrayColInsert() ; ========================================================================================= Func __ArrayColInsert(ByRef $aArray, $iColumn = 0, $ArrayFill = '') If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $bArray[UBound($aArray, 1)] If IsArray($ArrayFill) Then If (UBound($aArray, 1) <> UBound($ArrayFill, 1)) Then Return SetError(1, 0, -1) $bArray = $ArrayFill Endif Local $iDim_1 = UBound($aArray, 1) Switch UBound($aArray, 0) Case 1 Local $aTempArray[$iDim_1][2] Switch $iColumn Case 0, 1 For $i = 0 To $iDim_1 - 1 $aTempArray[$i][(Not $iColumn)] = $aArray[$i] $aTempArray[$i][$iColumn] = $bArray[$i] Next Case Else Return SetError(3, 0, -1) EndSwitch $aArray = $aTempArray Case 2 Local $iDim_2 = UBound($aArray, 2) If $iColumn < 0 Or $iColumn > $iDim_2 Then Return SetError(3, 0, -1) ReDim $aArray[$iDim_1][$iDim_2 + 1] For $i = 0 To $iDim_1 - 1 For $j = $iDim_2 To $iColumn + 1 Step -1 $aArray[$i][$j] = $aArray[$i][$j - 1] Next $aArray[$i][$iColumn] = $bArray[$i] Next Case Else Return SetError(2, 0, -1) EndSwitch Return UBound($aArray, 0) EndFunc to download Array Insert Column ( version 2.0 )https://www.autoitscript.com/forum/topic/206264-_arraycolinsert/?do=findComment&comment=1485725 Edited March 2, 2022 by jugador Link to comment Share on other sites More sharing options...
water Posted July 15, 2021 Share Posted July 15, 2021 Could you please be so kind and add some documentation to your example scripts? Why is your code better than the original function? Is it faster? Does it add functionality? Does it fix a bug? Unfortunately my cristal ball doesn't tell me JLogan3o13 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
jugador Posted July 15, 2021 Author Share Posted July 15, 2021 In Autoit 3.3.14.5 version (that's what I am using) ; #FUNCTION# ==================================================================================================================== ; Author ........: Melba23 ; Modified.......: ; =============================================================================================================================== Func _ArrayColInsert(ByRef $aArray, $iColumn) So @water you don't need cristal ball to know the difference 😛. Besides example is given just run it . Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 15, 2021 Moderators Share Posted July 15, 2021 jugador, i agree with water. Please do offer some explanations of why you felt the need to create your specific UDF and how it differs from any existing function. 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...
jugador Posted July 15, 2021 Author Share Posted July 15, 2021 @Melba23 now I am confuse 🤔 seeing you asking for explanation with default _ArrayColInsert you can only insert blank column but now you can insert blank column and also can insert 1D array (like $fillArray from 1st post) Local $fillArray[6] = ['XX', 'XX', 'XX', 'XX', 'XX', 'XX'] Link to comment Share on other sites More sharing options...
Nine Posted July 15, 2021 Share Posted July 15, 2021 @jugador Maybe it is clear for you. But not everybody remembers exactly all the parameters of all the functions. This is why it is a good practice to give a bit of an explanation when posting an example. You will most likely get a larger audience doing so... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 15, 2021 Moderators Share Posted July 15, 2021 jugador, Quote @Melba23 now I am confuse 🤔 seeing you asking for explanation As Nine pointed out above, not everyone remembers every parameter for every function. Even though I wrote the current versions of some of your recent _Array* examples I had to go and look at the details in the Help file before I spotted the difference in your versions. Explaining theses differences when you post would help everyone to see why you felt the need to produce slightly different functionalities. And please do not take this as criticism of the UDFs themselves - if they are good enough we might even add them to the standard library. 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...
jugador Posted July 16, 2021 Author Share Posted July 16, 2021 (edited) Don't feel updating 1st post as it complete different code Array Insert Column ( version 2.0 ) > insert single / multiple blank row > support insertion of 1D & 2D Array Now do run the code for better explanation #include <Array.au3> #include "ArrayInsertCol.au3" Local $o_Eg[6][] = [['A', 11, 22, 33, 44], _ ['B', 11, 22, 33, 44], _ ['C', 11, 22, 33, 44], _ ['D', 11, 22, 33, 44], _ ['E', 11, 22, 33, 44], _ ['F', 11, 22, 33, 44]] Local $fillArray_A[6] = ['PP', 'PP', 'PP', 'PP', 'PP', 'PP'] Local $fillArray_C[6][] = [['AA', 'BB'], ['AA', 'BB'], ['AA', 'BB'], ['AA', 'BB'], ['AA', 'BB'], ['AA', 'BB']] ;__ArrayColInsert_V2($o_Eg, 1, '', 4) __ArrayColInsert_V2($o_Eg, 0, '', 6) ;__ArrayColInsert_V2($o_Eg, 0, $fillArray_A) ;__ArrayColInsert_V2($o_Eg, 1, $fillArray_A) ;__ArrayColInsert_V2($o_Eg, UBound($o_Eg, 2), $fillArray_A) ;__ArrayColInsert_V2($o_Eg, 0, $fillArray_C) ;__ArrayColInsert_V2($o_Eg, 1, $fillArray_C) ;__ArrayColInsert_V2($o_Eg, UBound($o_Eg, 2), $fillArray_C) _ArrayDisplay($o_Eg) ;__ArrayColInsert_V2($fillArray_A, 1, '', 2) ;__ArrayColInsert_V2($fillArray_A, 0, '', 4) ;__ArrayColInsert_V2($fillArray_A, 0, $fillArray_C) ;__ArrayColInsert_V2($fillArray_A, 1, $fillArray_C) ;_ArrayDisplay($fillArray_A) __ArrayColInsert_V2 UDF ArrayInsertCol.au3 Edited March 2, 2022 by jugador Link to comment Share on other sites More sharing options...
jugador Posted August 15, 2021 Author Share Posted August 15, 2021 (edited) Array Insert Column ( version 2.0 ) example link https://www.autoitscript.com/forum/topic/207912-array-add-multiple-columns-with-data-array-right-add/?do=findComment&comment=1499926 Edited April 8, 2022 by jugador 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