Sum all table column cell values?

Hi there,

I am searching and beating my head over this all day...
I need to find a way to sum all cell values from a table column, BUT when the number of rows is unknown.

Can somebody help?

Thanks in advance!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Use a loop that increments columns and then increments rows when self.columnCounter=tableColumns(tableName).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited March 2013

    Hi @iPavel

    Make a boolean attribute called Trigger, integer attribute for Count, and the integer for the sum:

    When Trigger is false
    When yourStartAddingboolean is true
    Change Attribute Count to Count+1
    Change Attribute Sum to Sum+tableCellValue(YourTable,Count,1)
    Change Attribute Trigger to true

    -----

    When Count = tableRowCount(YourTable)
    Change Attribute yourStartAddingboolean to false

    -----

    When Trigger is true and yourStartAddingboolean is true
    Change Attribute Trigger to false

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • iPaveliPavel Member Posts: 24
    Thanks, guys! I appreciate the help!
  • gameviccigamevicci Member, PRO Posts: 306
    Before you're going mad: REMEMBER THAT YOU CAN'T SUM BOOLEAN VALUES!!!!!!

    However @gyroscope thanks a lot :) !!
Sign In or Register to comment.