Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Please, add a command to clean all variables at once.


  • Please log in to reply
20 replies to this topic
CleanVariables
  • Guests
  • Last active:
  • Joined: --
On my test script I have to skip the first 8 or 9 lines to begin cleaning the variables.

Here is the listvars contents right before you parse the OUT variable.

The first 9 lines need to be skipped before cleaning the variables.

This changes on each script.


Local Variables for CleanGlobalVars()
--------------------------------------------------


Global Variables (alphabetical)
--------------------------------------------------
0[1 of 3]: 0
ErrorLevel[1 of 3]: 0
out[0 of 0]:  
VarOne[9 of 63]: 123456789
VarTwo[4 of 7]: 0005

We need to determine where to start cleaning variables in this line
if   A_Index < 3   ; skip the first two lines


sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008
CleanGlobalVars() {



	global



	ListVars

	ControlGetText, out, Edit1, ahk_class AutoHotkey

	WinHide, ahk_class AutoHotkey

	Loop, parse, out, `n, `r

		if	(!p :=	InStr(A_LoopField,"[")) || RegExMatch(A_LoopField,"^\d+\[")

			continue

		else	v :=	SubStr(A_LoopField,1,p-1), VarSetCapacity(%v%,0)



}


CleanVariables
  • Guests
  • Last active:
  • Joined: --
We may be able to check A_LoopField for invalid variable characters and then skip it if it contains an invalid character.

CleanVariables
  • Guests
  • Last active:
  • Joined: --

CleanGlobalVars() {

	global

	ListVars
	ControlGetText, out, Edit1, ahk_class AutoHotkey
	WinHide, ahk_class AutoHotkey
	Loop, parse, out, `n, `r
		if	(!p :=	InStr(A_LoopField,"[")) || RegExMatch(A_LoopField,"^\d+\[")
			continue
		else	v :=	SubStr(A_LoopField,1,p-1), VarSetCapacity(%v%,0)

}



That works!!

thanks

guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
should declare local out, p, v as well i believe

kakashi524
  • Members
  • 103 posts
  • Last active: Apr 18 2015 11:41 PM
  • Joined: 25 Feb 2013

I know the post is old, but I tried the function and it does clean variables. I was just wondering what the point is. I mean, at first I thought it was done so it could free up memory, but after trying it out it seems to use additional memory (50-100K). I'm using this:

CleanGlobalVars() {
	global
	local out, p, v
	ListVars
	ControlGetText, out, Edit1, ahk_class AutoHotkey
	WinHide, ahk_class AutoHotkey
	Loop, parse, out, `n, `r
		if	(!p :=	InStr(A_LoopField,"[")) || RegExMatch(A_LoopField,"^\d+\[")
			continue
		else	v :=	SubStr(A_LoopField,1,p-1), VarSetCapacity(%v%,0)
}