Jump to content

Recommended Posts

Posted (edited)

a 2-Dimensional Version of _ArrayAdd

i hope someone need the Script

#region #### Includes ============================================================================================================
#include-once
#include <array.au3>
#endregion ======================================================================================================================
 
#cs
#CURRENT# =====================================================================================================================
  _ArrayAdd_2dim
#CURRENT# =====================================================================================================================
#ce
 
; #Function -  _ArrayAdd_2dim ======================================================================================================================================
; Parameters ....: $avArray = Array to add with additional Array
;    $newARRAY = aditional Array
; Error .........: 1 = Master Array is no Array
;    2 = add. Array is no Array
;    3 = Master Array is no 2D Array
;    4 = add. Array is no 2D Array
; Return ........: 0 = All OK
; Description ...: to ad a 2dimensional Array to another 2 dimensional Arry
; ==========================================================================================================================================================================
Func _ArrayAdd_2dim(ByRef $avArray, $newARRAY)
If Not IsArray($avArray) Then Return SetError(1, 0, -1)
If Not IsArray($newARRAY) Then Return SetError(2, 0, -1)
If UBound($avArray, 0) <> 2 Then Return SetError(3, 0, -1)
If UBound($newARRAY, 0) <> 2 Then Return SetError(4, 0, -1)
 
Local $i, $j,$jj
;##################################################################
;### check which Array is the Biggest
;##################################################################
 
If UBound($avArray,2) > UBound($newARRAY,2) then $newdim = UBound($avArray,2)
If UBound($avArray,2) < UBound($newARRAY,2) then $newdim = UBound($newARRAY,2)
 
;##################################################################
;### Redim the Array Size
;##################################################################
 
ReDim $avArray[(UBound($avArray,1))+(UBound($newARRAY,1))][$newdim] ; 1 Array zeile hinzufügen
 
;##################################################################
;### add the Array
;##################################################################
 
for $i = (UBound($avArray)-1) to (UBound($avArray))-(UBound($newARRAY)) Step -1
   $j = UBound($newARRAY)-$jj-1
   for $k = 0 to (UBound($newARRAY,2)-1)
    ConsoleWrite('+$avArray['&$i&']['&$k&'] = $newARRAY['&$j&']['&$k&']'&@CRLF)
     $avArray[$i][$k] = $newARRAY[$j][$k]
   Next
   ConsoleWrite(@CRLF)
   $jj +=1
Next
;~ _ArrayDisplay($avArray)
return(0)
EndFunc

_ArrayAdd_2dim.au3

Edited by draco105457
Posted (edited)

- Suggest using a empty string("") as SetError() return data. As that's the general default when a AutoIt function, that generally returns a array, fails(error)(or fails to return a array as data.)

(that was before I noticed the leading ByRef of course.)

- oops, you seems to have broken your code box.

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Posted

- Suggest using a empty string("") as SetError() return data. As that's the general default when a AutoIt function, that generally returns a array, fails(error)(or fails to return a array as data.)

- oops, you seems to have broken your code box.

"", 0 or False is considered the same in boolean expressions. except "" allocates a string

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Posted

I'm not sure how this relates to _ArrayAdd. With _ArrayAdd a new element is added (and its value is declared) to a one dimensional array. I would expect a two dimensional version to also add data. A new row or column of values ought to be added, otherwise it is simply a Redim.

Posted

@Shaggi

Both true (Within AutoIt(and other Type-less languages)), but I fail to see your point.

(I overlooked the Byref use. Previous message corrected.)

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Posted (edited)

While i dont know autoit internals (this may be optimized),

If this is true. (not knowing AutoIt's internals)

Than how can you be sure about ...

allocating a string is slower and thus should be avoided.

It makes sense that that's also the case in AutoIt, but that's about it. Unless you have some direct or indirect proof ... its still only a guess.

Think your going to be hard pressed to log a significant difference in using a 'empty string' or 'zero as number' as function return data. Besides AutoIt is not like assembly, where speed differences are bigger relative to different used commands/data-types)

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Posted

I would suggest contacting a moderator >> http://www.autoitscript.com/forum/index.php?app=members&module=list&max_results=30&filter=7&sort_order=asc&sort_key=members_display_name&st=0&b=1

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...