Page 1 of 1

Loop (and create a countdown) on a var created from args

Posted: 13 Jan 2019, 14:48
by partof
I am starting my ahk script from a python scrip with an argument "number" (which is an integer but set as a string variable):

Code: Select all

subprocess.call([path_ahk_exe, path_ahk_script_countdown, number])
Then in the ahk script I need to create a Tooltip that countdown from the time set in the args. If Number is set to 15 I should then see 15, 14,... 3,2,1...
But I don't see this, I literally see "15 - A_Index"
Any idea how to solve this? Thanks for your help!

Here is my script:

Code: Select all

Number := %0% , Number += 0  ; convert text to number

Loop %Number%       
	{
		 ToolTip, %  %Number% - A_Index ; if you just use A_Index it starts at 1 2 3 etc
		 Sleep 1000
		}
Tooltip, 0

Re: Loop (and create a countdown) on a var created from args

Posted: 13 Jan 2019, 15:23
by swagfag
its because ure double-derefing Number, also why do it in this archaic way:

Code: Select all

Loop % A_Args[1]
{
	ToolTip % --A_Args[1]
	Sleep 1000
}
ToolTip

Re: Loop (and create a countdown) on a var created from args

Posted: 17 Jan 2019, 14:24
by partof
Sorry for the delay and thanks so much as it's working great!