Keybanger Posted March 24, 2021 Share Posted March 24, 2021 (edited) 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 March 24, 2021 by Keybanger Link to comment Share on other sites More sharing options...
pseakins Posted March 24, 2021 Share Posted March 24, 2021 Put the values into an array and then use one or other of the the array manipulation functions such as _ArrayAdd, _ArrayConcatenate, _ArrayDelete, _ArrayInsert, _ArrayPop, _ArrayPush. Look for examples inthe help. https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayAdd.htm Keybanger 1 Phil Seakins Link to comment Share on other sites More sharing options...
Keybanger Posted March 25, 2021 Author Share Posted March 25, 2021 I'll play around with it. Thanks for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now