Formatting issue

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
RextTG
Posts: 10
Joined: 24 Nov 2015, 13:16

Formatting issue

24 Nov 2015, 13:19

So I'm writing a function for the first time... Why does it think this is unexpected?

Code: Select all

QuickLaunchFunction(slot)
{
	IfWinNotExist, FileList[slot] {
		CurrentSlot := slot
		CurrentSlotName := FileList[slot]
		MsgBox, , Title, Current Slot: %slot%, 1
		Run, % A_WorkingDir "\NumbpadLayouts\" FileList[slot]
		QuickLaunch = false
	}
} ; <--- It thinks this is unexpected

~Numpad0::
~Numpad1::QuickLaunchFunction(1)
~Numpad2::QuickLaunchFunction(2)
~Numpad3::QuickLaunchFunction(3)
~Numpad4::QuickLaunchFunction(4)
~Numpad5::QuickLaunchFunction(5)
~Numpad6::QuickLaunchFunction(6)
~Numpad7::QuickLaunchFunction(7)
~Numpad8::QuickLaunchFunction(8)
~Numpad9::QuickLaunchFunction(9)
~NumpadEnter::
~NumpadAdd::
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

Re: Formatting issue

24 Nov 2015, 13:26

IfWinNotExist (and all ifwin.. commands) do not support OTB style braces.
it's expecting the { to be part of the title, not a code-block.

Also, not sure, but you you might also need to force an expression for ahk to see the array:
IfWinNotExist, % FileList[slot]
rawr. fear me.
*poke*
Is it December 21, 2012 yet?
RextTG
Posts: 10
Joined: 24 Nov 2015, 13:16

Re: Formatting issue

24 Nov 2015, 13:50

That fixed it thanks! It didn't need the force either
RextTG
Posts: 10
Joined: 24 Nov 2015, 13:16

Re: Formatting issue

24 Nov 2015, 13:53

Okay so I don't want the function to go without first checking this if statement... However when I run it it never actually checks the if statement. It opens the function then just stops...
(I commented it out cuase it doesn't work yet I know its commented)

I have something that changes quicklaunchfunction to 1 earlier so I don't know why its doing this

Code: Select all

;QuickLaunchFunction(slot) {
;	MsgBox, , Title, "function active, slot " %slot% "| Quick Launch" %QuickLaunch%, 1
;	if (QuickLaunch > 0) {
;	MsgBox, , Title, "thing is true", 1
;		IfWinNotExist, FileList[slot] 
;		{
;			CurrentSlot := slot
;			CurrentSlotName := FileList[slot]
;			MsgBox, , Title, Current Slot: %slot%, 1
;			Run, % A_WorkingDir "\NumbpadLayouts\" FileList[slot]
;			QuickLaunch = 0
;		}
;	}
;}

;~Numpad0::
;~Numpad1::QuickLaunchFunction(1)
;~Numpad2::QuickLaunchFunction(2)
;~Numpad3::QuickLaunchFunction(3)
;~Numpad4::QuickLaunchFunction(4)
;~Numpad5::QuickLaunchFunction(5)
;~Numpad6::QuickLaunchFunction(6)
;~Numpad7::QuickLaunchFunction(7)
;~Numpad8::QuickLaunchFunction(8)
;~Numpad9::QuickLaunchFunction(9)
;~NumpadEnter::
;~NumpadAdd::
User avatar
kczx3
Posts: 1640
Joined: 06 Oct 2015, 21:39

Re: Formatting issue

24 Nov 2015, 14:19

Is the variable QuickLaunch set as Global? The only place in your code I see its value getting set is in the function and setting it to 0. It will need to either be passed into the function as a param or set as Global outside the function. Or you can have the first line within your function be the word Global (I think).
User avatar
tidbit
Posts: 1272
Joined: 29 Sep 2013, 17:15
Location: USA

Re: Formatting issue

24 Nov 2015, 14:23

QuickLaunch is never defined. it'll be blank/false/0. it'll never do anything inside that if.
unless QuickLaunch is made GLOBAL elsewhere, if not, that could be it.

also, "I have something that changes quicklaunchfunction to 1 earlier so I don't know why its doing this"
you have something that sets quicklaunchfunction to 1, but not QuickLaunch ?
rawr. fear me.
*poke*
Is it December 21, 2012 yet?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Google [Bot], Nerafius and 113 guests