Cant Reset Array Keeps Getting Higher ...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
roonyrooxcess
Posts: 61
Joined: 20 Nov 2020, 21:29

Cant Reset Array Keeps Getting Higher ...

14 Jun 2021, 11:20

Hi, Im trying to reset an array, but cant figure out how, I've tried clearing all variables in the loop, but nothing works ... lol

Basically the script should just check variables from 1 to 10, & reset the array, but it just keeps getting larger ...

Thanks!

Code: Select all

; Create pre-generated AutoHotkey script
; with a basic template or import your own
#SingleInstance, Force

Every5Seconds:=0
MultilineInc:=0

Goto Main

Main:

{

MultilineInc++

;FileRead, CurrentPrice1, D:\12\Temp\Price.txt
;CurrentPrice1 := StrReplace(CurrentPrice1,",", "")
;
;CopyToMultiline%MultilineInc%:=CurrentPrice1

CopyToMultiline1   =1  
CopyToMultiline2   =2  
CopyToMultiline3   =3  
CopyToMultiline4   =4  
CopyToMultiline5   =5  
CopyToMultiline6   =6  
CopyToMultiline7   =7  
CopyToMultiline8   =8  
CopyToMultiline9   =9  
CopyToMultiline10  =10  
CopyToMultiline11  =11  
CopyToMultiline12  =12  
CopyToMultiline13  =13  
CopyToMultiline14  =14  
CopyToMultiline15  =15  
CopyToMultiline16  =16  
CopyToMultiline17  =17  
CopyToMultiline18  =18  
CopyToMultiline19  =19  
CopyToMultiline20  =20  



	D .= CopyToMultiline%MultilineInc% "`n"
		;D := Trim(D, "`n")
		
;msgbox % D

Every5Seconds++
tooltip % Every5Seconds
;5 Seconds
if Every5Seconds =10
{	
MultilineInc:=0
Every5Seconds:=0

goto checkAverage

}


;Sleep 900

Goto Main
}

Return












checkAverage:
{
x:=0
greaterCount = 0
firstValue :=CopyToMultiline1

;msgbox % D

a:=D



for i, v in array := StrSplit(a, "`n") {

	x++

	if (x = 1) {
		firstValue := v
		continue
	}
	(v >= firstValue) ? greaterCount++
}
x := greaterCount
y := array.length()
(x >= y // 2) ? result := x " of " y " are higher possibly trending up" "`n" MultilineInc "`n" D : result := x " of " y " are higher possibly trending down" "`n" MultilineInc "`n" D 
Tooltip, % result

firstValue:=[]
greaterCount:=[]
i:=[]
array:=[]
v:=[]
x:=[]
y:=[]
MultilineInc:=0
sleep 2000

Goto Main


}

Return









`::
{
Send {esc}
Sleep 100
Send {LControl down}
sleep 100
Send {s}
sleep 100
Send {LControl up}

Reload
}
Return
User avatar
mikeyww
Posts: 27369
Joined: 09 Sep 2014, 18:38

Re: Cant Reset Array Keeps Getting Higher ...

14 Jun 2021, 11:31

One thing I noticed is that you are using multiple variables as both single values and objects. That typically leads to both confusion and errors in the coding. If you simplify your script by eliminating non-essential lines, you can shorten it and then test it line by line, to see what is happening.
roonyrooxcess
Posts: 61
Joined: 20 Nov 2020, 21:29

Re: Cant Reset Array Keeps Getting Higher ...

14 Jun 2021, 11:34

oh yea, i used the x wrong ... fixed, but it still gives the same problem, the array keeps getting higher ...

Code: Select all

; Create pre-generated AutoHotkey script
; with a basic template or import your own
#SingleInstance, Force

Every5Seconds:=0
MultilineInc:=0

Goto Main

Main:

{

MultilineInc++

;FileRead, CurrentPrice1, D:\12\Temp\Price.txt
;CurrentPrice1 := StrReplace(CurrentPrice1,",", "")
;
;CopyToMultiline%MultilineInc%:=CurrentPrice1

CopyToMultiline0   =  20
CopyToMultiline1   =  20
CopyToMultiline2   =  19
CopyToMultiline3   =  18
CopyToMultiline4   =  17
CopyToMultiline5   =  16
CopyToMultiline6   =  15
CopyToMultiline7   =  14
CopyToMultiline8   =  13
CopyToMultiline9   =  12
CopyToMultiline10  =   11
CopyToMultiline11  =   10
CopyToMultiline12  =   9
CopyToMultiline13  =   8
CopyToMultiline14  =   7
CopyToMultiline15  =   6
CopyToMultiline16  =   5
CopyToMultiline17  =   4
CopyToMultiline18  =   3
CopyToMultiline19  =   2
CopyToMultiline20  =   1




	D .= CopyToMultiline%MultilineInc% "`n"
		;D := Trim(D, "`n")
		
;msgbox % D

Every5Seconds++
tooltip % Every5Seconds
;5 Seconds
if Every5Seconds =10
{	
MultilineInc:=0
Every5Seconds:=0

goto checkAverage

}


;Sleep 900

Goto Main
}

Return












checkAverage:
{
x:=0
greaterCount = 0
firstValue :=CopyToMultiline1

;msgbox % D

a:=D



for i, v in array := StrSplit(a, "`n") {

	xs++

	if (xs = 1) {
		firstValue := v
		continue
	}
	(v >= firstValue) ? greaterCount++
}
x := greaterCount
y := array.length()




if (x > y // 2)

{
	result := x " of " y " are higher possibly trending up" "`n" MultilineInc "`n" D
		
		Tooltip, % result

}

if (x < y // 2)

{
	result := x " of " y " are higher possibly trending up" "`n" MultilineInc "`n" D
		
		Tooltip, % result

}

Tooltip, % result
xs:=0
firstValue:=[]
greaterCount:=[]
i:=[]
array:=[]
v:=[]
x:=[]
y:=[]
MultilineInc:=0
sleep 2000

Goto Main


}

Return









`::
{
Send {esc}
Sleep 100
Send {LControl down}
sleep 100
Send {s}
sleep 100
Send {LControl up}

Reload
}
Return
User avatar
mikeyww
Posts: 27369
Joined: 09 Sep 2014, 18:38

Re: Cant Reset Array Keeps Getting Higher ...

14 Jun 2021, 11:44

I do not know the goal, but if you append to D without resetting it, it would continue to grow.
roonyrooxcess
Posts: 61
Joined: 20 Nov 2020, 21:29

Re: Cant Reset Array Keeps Getting Higher ...

14 Jun 2021, 11:47

Thanks, Totally missed that one ...

Much appreciated!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee, Google [Bot] and 149 guests