Jump to content
Sign in to follow this  

#include in a conditional statement

Recommended Posts


I'm attempting to write a script that includes files depending on the Operating system that the script is running on.

I understand that I cannot use variables in an #include statement.

So I tried to use a switch statement to include the files I needed, and I kept getting an error that the closing conditional statement was unavailable.

Here is an example of what I'm talking about.

When I attempt to run foo.au3, I get ->

Error: "If" statement has no matching "EndIf" statement

Could someone suggest how they handle dynamic calling of other autoit files, or how to handle including autoit files in conditional statements.


;; foo.au3

$myVar = "test"

if $myVar = "test" Then
    #include "bar.au3"

;; bar.au3

Func bar()

Share this post

Link to post
Share on other sites

Hello, and welcome to the forums!

You should not do this, this way. You should keep your bar function in, and then us If @OS = "WIN_XP" or whatever, then call it. When compiling the Aut2Exe puts all in includes in the script, where they are, so if you have that, when you compile it, it will put the function in that area, which is cannot be.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.