Jump to content

Recommended Posts

Posted

I have a large script and split it up in multiple au3 files (for large function a different file; udf) and included them in a "main file".

But how can manage the global scope variables so that I can use them in those files. sometimes I need to "communicate" with the main gui, like statusbar updates

Probably I should make an au3 file with all the globals and include them in each udf (with #include-once)?

Posted
Just as you join file with the declaration at the beginning of the main script, you do not need to attach to each file individually.
 
#include "myUDF_Const.au3" ; with global variable
#include "myUDF_FuncSet1.au3"
#include "myUDF_FuncSet2.au3"
#include "myUDF_FuncSet3.au3"

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Here's how I do it in large projects.

Includes.au3

  Quote

#include "Globals.au3"

#include "FileHandling.au3"

#include "WindowHandling.au3"

#include "Communications.au3"

 

Globals.au3

  Quote

#include_once

Global $all

Global $my

Global $globals

 

FileHandling.au3

  Quote

#include_once

#include "Includes.au3"

 

WindowHandling.au3

  Quote

#include_once

#include "Includes.au3"

 

etc..

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

Monkey's are, like, natures humans.

Posted

You've inspired me, I think I change my habits.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

I try not use Globals across UDFs if I can help it. If I need to then I create a wrapper function around the Global for setting and reading the Global variable.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

Although repetative, I like adding all includes needed for every file...so if I'm debugging a function call in any of my scripts, I can use the 'autoit jump' macro...I think that would be a nice enhancement, for a recursive script finder on that :)

I also like to define my globals as some value, but only if not IsDeclared(), in case I wanted them overwritten (which I have a block prior to all includes for those) 

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Posted (edited)

"autoit jump" macro?

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

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
  • Recently Browsing   0 members

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