Jump to content

#include in a conditional statement


 Share

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.

Thanks

;; foo.au3

$myVar = "test"

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

;; bar.au3

Func bar()
EndFunc
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...