Easier way to add columns?


I think I remember reading somewhere there was an easier way to add up a column of a table rather than going tabelvaluecell plus tabelvaluecell plus ect

Was this correct? Is there another way and quicker way to add up all the values in a column?

Comments

  • mounted88mounted88 Member Posts: 1,113
    edited October 2013
    Is there a sum function in the expression editor? If there is you should be able to use that. Just like a excel spreadsheet.

    Not at my computer to look at the moment.
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited October 2013
    Maybe a timer loop:

    Change Attribute: self.tableRow = 0
    Timer: Every 0 seconds
    ..Rule: If self.tableRow < tableRowCount(table)
    ....Change Attribute: self.tableRow = self.tableRow + 1
    ....Change Attribute: self.columnTotal = self.columnTotal + tableCellValue(table, self.tableRow, column)

    EDIT: The dots at the start of the lines are to show how each thing is nested.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Loops are a much more efficient way to sum column values.

    And @KevinCross, you can use option/alt+space on the forums to
         indent text.

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

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Awesome! Thanks @tatiang. I will try and remember that
Sign In or Register to comment.