Jump to content

arraysum?


beestinga
 Share

Recommended Posts

Searching around, I found a few places that people were requesting such features as _ArraySum, _ArrayMult, etc.

did such a tool ever come to fruition. It would be nice to be able to add a number to all elements of an array, or to add two arrays together with a single function.

I'm most interested in multi-dimensional arrays, but i could see single dimension arrays benefiting from this as well.

-Stinga

Link to comment
Share on other sites

Hi beestinga,

Please create descriptive topics.

Using one word topics makes it really difficult to use the search feature, and those that could probably answer your question will probably not even read your thread.

Doing it enough could cause your posting privileges to be taken away all together, and we don't want that :) .

Thanks.

Link to comment
Share on other sites

Hi beestinga,

Please create descriptive topics.

Using one word topics makes it really difficult to use the search feature, and those that could probably answer your question will probably not even read your thread.

Doing it enough could cause your posting privileges to be taken away all together, and we don't want that :) .

Thanks.

Is this a bot?
Link to comment
Share on other sites

Is this a bot?

Yes it is... But I wouldn't get all upset about it(Trust me).

To answer your question I've never seen anything like "Arraysum"

Try forum searching.

Somebody here might have some old UDF that does the trick too. Let's just hope...

Link to comment
Share on other sites

@beestinga...Make your own UDF...Here is what I would do...

#include <Array.au3>

$String="1,2,3,4,5"
$Array=StringSplit($String,",")
$Sum=0

For $x=1 to UBound($Array)-1
$Sum=$Sum+$Array[$x]
Next

MsgBox(4096,"",$Sum)

Or

#include <Array.au3>

$String="1,2,3,4,5"
$Array=StringSplit($String,",")

$Total=_ArrayToString($Array,"+",1)
$Sum=Execute($Total)

MsgBox(4096,"",$Sum)

:)

Edited by DjDeep00
Link to comment
Share on other sites

@beestinga...Make your own UDF...Here is what I would do...

#include <Array.au3>

$String="1,2,3,4,5"
$Array=StringSplit($String,",")
$Sum=0

For $x=1 to UBound($Array)-1
$Sum=$Sum+$Array[$x]
Next

MsgBox(4096,"",$Sum)

Or

#include <Array.au3>

$String="1,2,3,4,5"
$Array=StringSplit($String,",")

$Total=_ArrayToString($Array,"+",1)
$Sum=Execute($Total)

MsgBox(4096,"",$Sum)

:)

Thanks, DjDeep for your ideas. I guess I'll need to whip something up.

-Jason

Link to comment
Share on other sites

  • Moderators

The time it took you to post you could have done:

Func _ArraySum(ByRef $a_array, $i_lbound1 = 0, $i_lbound2 = 0)
    Local $i_ubound1 = UBound($a_array, 1) - 1
    Local $i_ubound2 = UBound($a_array, 2) - 1
    Local $i_add = 0
    
    If $i_ubound2 > 0 Then
        For $i = $i_lbound1 To $i_ubound1
            For $n = $i_lbound2 To $i_ubound2
                $i_add += Number($a_array[$i][$n])
            Next
        Next
    Else
        For $i = $i_lbound1 To $i_ubound1
            $i_add += Number($a_array[$i])
        Next
    EndIf
    
    Return $i_add
EndFunc
Bot or no bot, 1 word titles are annoying. There are two parts to a title... The title, and a description.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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