#Include only when if statement is true

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Elenkhos
Posts: 31
Joined: 27 Feb 2018, 09:08

#Include only when if statement is true

18 Jul 2018, 09:11

I need to store one part of my main script in different path for security reasons. This subscript includes a subroutine (or function) which main script calls by a hotkey.

The problem is that the main script is used by two computers which only desktop has access to the subscript file. If the main script is executed in laptop it generates an error (target label does not exist) and the script is not loaded.

What would you suggest as a solution? This is what I came up with but it doesn’t work. I guess # statements cannot be nested:

Code: Select all

#If (Desktop = 1)
	#Include *i SubScript.ahk
#If
Well, as I was writing this post a realised that I can add the subroutine label to the main script before #Include as a workaround. This is quite dirty solution and works only with one subroutine:

Code: Select all

#If (Desktop = 1)
	Subroutine:
	#Include *i SubScript.ahk
#If
So I’m welcoming more elegant ways to overcome this issue.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada and 247 guests