cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Erich
Booster

Total of array values

Ok, I am feeling brain dead at the moment..

Does anyone have a clean method for getting the sum total of all the values in an array?

For example if you a have a 3 dimension array with values of 2'-0": 1'-4": 2'-3" I need the result of 5'-7"
Erich

AC 19 6006 & AC 20
Mac OS 10.11.5
15" Retina MacBook Pro 2.6
27" iMac Retina 5K
3 Replies 3
Karl Ottenstein
Moderator Emeritus
Not sure what you mean by "clean", Erich. Do you want something more than just a loop, iterating through the indices and summing things up?

Cheers,
Karl

PS I've been brain dead for two days, so can commiserate. 😉
Vote for Wish: Copy/Paste in 3D

AC 29 USA and earlier   •   hardware key   •   macOS Taho 26.1 MacBook Pro M2 Max 12CPU/30GPU cores, 32GB
Frank Beister
Moderator
dim var[3][4]

result=0
for i=1 to vardim1(var)
for j=1 to vardim2(var)
result=result+var
next j
next i

print result
text2 0,0,result
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
Erich
Booster
Thanks guys. My new son is making sure I can't think straight anymore and I couldn't figure out how to get my loop to work right. Frank hit it right on the nose. I just needed the dummy variable to be the place holder in the loop.
Erich

AC 19 6006 & AC 20
Mac OS 10.11.5
15" Retina MacBook Pro 2.6
27" iMac Retina 5K

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!