Jump to content

Need to store and remember last value


Recommended Posts

HI. I have been trying to figure this one out and it has me stumped!

This is just a small piece of code from a much larger project I'm working on. Each time a specific hotkey is pressed the value of $Total changes and then Func Accumulate() is called. 
The purpose of the accumulate function is to keep a tally of the changing totals for 40 button presses. For that I need to store each last Accumulated value and add it to the current total.
 I can repeat each line 40 times but there must be a better way. Can someone point me to a helpfile topic that might be useful here. I tied fitting it into a for loop but didn't quite make it work. 

Thanks

 

 

 

Func Accumulate()

    $Count += 1
    
    If $Count = 1 then $Value1 = $Total
    If $Count = 2 then $Value2 = $Total
    If $Count = 3 then $Value3 = $Total

    If $Count = 1 then $Accumulation = $Total 
    If $Count = 2 then $Accumulation = $Total + $Value1
    If $Count = 3 then $Accumulation = $Total + $Value2

EndFunc

Edited by Keybanger
Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...