Jump to content

Recommended Posts

Posted (edited)

bunch of numbers in an array, i would like to add all these numbers together and output the sum. I have tried 'eval' , 'abs' , 'round' , and 'number' none of which result with desired output (I have also tried spaces and squiggly brackets around the plus sign in fear that the string was formatted incorrectly for math functions), any suggestions would be greatly appreciated. Thanks.

#Include <Array.au3>

Local $Array[10]

$Array[0] = "0"
$Array[1] = "1"
$Array[2] = "2"
$Array[3] = "3"
$Array[4] = "4"
$Array[5] = "5"
$Array[6] = "6"
$Array[7] = "7"
$Array[8] = "8"
$Array[9] = "9"

;~ _ArrayDisplay ($Array)

$string = _arraytostring ($Array, "+")

msgbox (0, '' , $string)

$sum = ???????($string)  ; can this $string be added??

msgbox (0, '' , $sum)
Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Posted

Thanks. And thanks for the enumerating from array solution.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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...