Jump to content
Sign in to follow this  
atzoref

Warnings: possibly used before declaration

Recommended Posts

atzoref

Hi,

I can't understand why these warnings shows up.

What can be the possible reasons?

Becuse it seems to be Ok , they are actuall declare.

(Also I uses some other scripts, when the main script contains them with includes)

Thanks

Share this post


Link to post
Share on other sites
water

Please post the code and the error messages you get (line number, name of variable in error is needed).


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
ZacUSNYR

You're using a variable before you declare it. If you post the code we explain it further.

Share this post


Link to post
Share on other sites
Syed23

ok .. add the below line to your code next to Header files. And when you run the code that will tell you what are all the variables need to be declared before compile or executing..

[autoit]

Opt("MustDeclareVars",1)

[/autoit]

Hope this helps you!

Edited by Syed23

Thank you,Regards,[font="Garamond"][size="4"]K.Syed Ibrahim.[/size][/font]

Share this post


Link to post
Share on other sites
water

Hi Syed,

it's exactly the other way round. Somewhere in his code there is already this Opt statement or a wrapper directive and somewhere he has an undeclared variable.

But without code and the full error message it's hard to say where the problem is.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
atzoref

It's a little bit hard to post the code here because I'm using some other scripts with the main script. Download Link for the program: http://www.mediafire.com/?xajej65p06q22bw (The main script is: AMT_Main_tmp.au3 I give you a little explantion For Example: In the main script I write:

#include "SomeOtherScript.au3"
Global Const $TEMP = 2
Then I'm running here a function which exist in "SomeOtherScript.au3" which uses this Global Const var Thats All.

Edited by atzoref

Share this post


Link to post
Share on other sites
water

The Constant is defined after the #include, right?

As AutoIt is interpreted top down the Constant is unknown to AutoIt when the Syntax check is beeing done. Example:

Func test()
    ConsoleWrite($Global & @CRLF)
EndFunc
Global Const $Global = 2
Test()

Move the Const to the top of the file and everyhting will be fine:

Global Const $Global = 2
Func test()
    ConsoleWrite($Global & @CRLF)
EndFunc
Test()

But I would recommend to define all variables and constants you need in the include-file itself.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
atzoref

yes it help,

I raise them aboce the includes so it works now.

I put them in the main script because they are used by some scripts (not only by one)

Edited by atzoref

Share this post


Link to post
Share on other sites
Juvigy

Good practice:

Create/Declare all global constants in a file and include it in the begining of the main script.

@PS Very usefull for large scripts with a lot of constants and global variables.

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.