Sign in to follow this  
Followers 0

#include ? [Solved]

4 posts in this topic

#1 ·  Posted (edited)

Never written a script large enough where I though I migh need them, but decided to try anyway.

But it appers I dont understand them enough.

Main script

#include 'MyInclude.au3'

Global $var = "variable"



Func _MsgBox()

It turns out A global var from main script does not carry across includes, which is the opposite of what I thought.

I know I can put everything in one .au3, but Im just curious as to the reason I get warnings about undeclared variables.

If anyone has the time to explain I'd appreciate it.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post

Link to post
Share on other sites

#3 ·  Posted (edited)

Well I'd say luckily declaring Global variables in one script does not in any way affect the included scripts' variables. I woulnd't really like that. If you want to pass variables around, do so in a function call. For example, you could have passed it as an argument if you built a function _MsgBox($var) :mellow:

~ edit

Apparently it does work if you include it after declaration (@Yashied) .. ah well, I always start with includes anyway so it luckily will not affect me :(

Edited by d4ni

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  
Followers 0