Jump to content

Search the Community

Showing results for tags 'arrayadd'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. Hi all, I sometimes wanted these functionality in _ArrayAdd function. I still don't know how to achieve it with _ArrayAdd. So i have wrote one. Please tell me if any better ways to do this. ; #FUNCTION# ==================================================================================================================== ; Name ..........: ArrayADD_2D ; Description ...: This Function adds either one column or one row to an existing array and put data from given array to it. ; Syntax ........: ArrayADD_2D(Byref $aArrayTochange, $aValueArray[, $Flag = $AddCol]) ; Parameters ....: $aArrayTochange - [in/out] an array you need to change. Must be a 2D Array ; $aValueArray - an array you need to insert into the first array. Must be a 1D Array ; $Flag - [optional] A flag value. Default is $AddCol. This value determins where to put the second array to first array. $AddCol puts all data to a new column and $AddRow puts all data to a new row. ; Return values .: If success, it will return the changed array. ; Errors - : -1 = First array is not an array ; : -2 = Second array is not an array ; : -3 = First array is not a 2D ; : -4 = Second array is not a 1D array ; : -5 = Second array doesn't have enough elements or more elements to add the first array ; : -6 = $Flag error ; Author ........: kcvinu ; Modified ......: sep 2015 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ArrayADD_2D($aArray1, $aArray2, $AddRow) ; =============================================================================================================================== Global Enum $AddCol, $AddRow Func ArrayADD_2D(ByRef $aArrayTochange, $aValueArray, $Flag = $AddCol) If Not IsArray($aArrayTochange) Then Return -1 If Not IsArray($aValueArray) Then Return -2 If UBound($aArrayTochange, $UBOUND_DIMENSIONS) <> 2 Then Return -3 If UBound($aValueArray, $UBOUND_DIMENSIONS) <> 1 Then Return -4 If $Flag = 0 Then ; we need to add 1 column and put the data in each row $iRows = UBound($aArrayTochange, $UBOUND_ROWS) - 1 $iCols = UBound($aArrayTochange, $UBOUND_COLUMNS) - 1 $iUb_Value = UBound($aValueArray) - 1 If $iRows <> $iUb_Value Then Return -5 ReDim $aArrayTochange[$iRows + 1][$iCols + 2] $iNewCol = UBound($aArrayTochange, $UBOUND_COLUMNS) - 1 For $i = 0 To $iRows $aArrayTochange[$i][$iNewCol] = $aValueArray[$i] Next Return $aArrayTochange ElseIf $Flag = 1 Then ; we need add one row and put the data in each column $iRows = UBound($aArrayTochange, $UBOUND_ROWS) - 1 $iCols = UBound($aArrayTochange, $UBOUND_COLUMNS) - 1 $iUb_Value = UBound($aValueArray) - 1 If $iCols <> $iUb_Value Then Return -5 ReDim $aArrayTochange[$iRows + 2][$iCols + 1] $iNewRow = UBound($aArrayTochange, $UBOUND_ROWS) - 1 For $i = 0 To $iCols $aArrayTochange[$iNewRow][$i] = $aValueArray[$i] Next Return $aArrayTochange Else Return -6 EndIf EndFunc ;==>ArrayADD_2D
×
×
  • Create New...