Jump to content

Recommended Posts

Posted

I just started to change most of my scripts by adding this line:

AutoItOption("MustDeclareVars", True)

I just realized how important it is (I know it's kind of shame but better late than never)

Mostly, this mean I have to add "Local" before all variable declaration. Scripts are large and there is many variables. I want to be sure that I didn't declared same variable twice. Is there any option to check this via Scite?

Posted (edited)
  On 11/1/2018 at 9:20 PM, maniootek said:

I just realized how important it is (I know it's kind of shame but better late than never)

Expand  

Cześć.

This only mean that you keep learning :) I had the same problem about 4 years ago.

  On 11/1/2018 at 9:20 PM, maniootek said:

Mostly, this mean I have to add "Local" before all variable declaration.

Expand  

Almost ... not always, sometimes Global instead Local

  On 11/1/2018 at 9:20 PM, maniootek said:

Scripts are large and there is many variables

Expand  

How many lines ? more then 10000 ?

  On 11/1/2018 at 9:20 PM, maniootek said:

I want to be sure that I didn't declared same variable twice. Is there any option to check this via Scite?

Expand  

Try to use this:

; AU3Check settings
#AutoIt3Wrapper_Run_AU3Check=Y
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y

how many ERROR's and WARNINGS's  you get ?
In one of my old script I had more than 500 ... but this is past time - all fixed MANUALLY .... and you now what: 
It was worth it, correct them manually ! ... because I learned even more.

 

Edited by mLipok

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
  On 11/1/2018 at 9:20 PM, maniootek said:

Mostly, this mean I have to add "Local" before all variable declaration

Expand  

Only use Local when the variables are being declared inside of a function, anywhere else is wrong usage (IMNSHO).

And the option you want for Au3Check is the "-w 3" option.

  Quote

-w 3      : already declared var (off)

Expand  

 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted
  On 11/1/2018 at 9:31 PM, BrewManNH said:

IMNSHO

Expand  

But you know... I agree with you.

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
  On 11/1/2018 at 9:31 PM, BrewManNH said:

Only use Local when the variables are being declared inside of a function, anywhere else is wrong usage (IMNSHO).

Expand  

The problem is that I didn't declare variables outside the functions and they were declared as global by default. When I started to include other script files with same variable name inside then script started to working wrong because of this.

This is the reason I started to declare some funtions as local outside the functions.

I don't know why this is not good idea? Or maybe my scripts are wrong designed as some of them are not functions?

Posted (edited)
  On 11/2/2018 at 7:12 AM, maniootek said:

The problem is that I didn't declare variables outside the functions and they were declared as global by default.

Expand  

You can't change this behavior, even if you declare variables as Local in the main part of your script (i.e. outside functions), they will be considered as Global. The following sentence is extracted from a wiki page concerning autoit (link below) :

"A variable declared as Local in the Global scope is still a Global variable, it's only for the sake of code clarity that you'd use the Local declaration in the Global scope."

https://www.autoitscript.com/wiki/Best_coding_practices

imho, the only case where it should be advisable to use the word "Local" to declare variables in the main part of your script (outside functions), this case could happen if you intend to #include <...> this script as a function (or within a function)... within another script.
 

Edited by pixelsearch

"I think you are searching a bug where there is no bug... don't listen to bad advice."

Posted

Thank you all. Now I use au3check with some options to check my code and I started to declare variables in functions and in global scope. I also understand the global scope variable declaration. I wish to know it 9 years ago when I started code in AutoIt :) 

Anyway, I have one more question. I want use au3check with option

  Quote

-w 5: local var declared but not used (off)

Expand  

because it's very helpful, but in case I declare variable for error handler then I got error too. I want notice that I have to declare error handler object to some variable because only this way it is working. Am I right or I miss something?

I want keep au3check with option "-w 5" but I also want my error handler working right way. Any idea?

declared-but-not-used-in-func.PNG

Posted
  On 11/1/2018 at 9:29 PM, mLipok said:

This only mean that you keep learning :) I had the same problem about 4 years ago.

Expand  

@mLipok, I really didn't think you have had any issues with things like this. I mean, you create some really useful stuff on AutoIt. 
Guess we all start at the same point.

Like someone said, Experience is only achieved by the mistakes we made.

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Posted
  On 11/8/2018 at 10:07 AM, Skeletor said:

Experience is only achieved by the mistakes we made.

Expand  

I'm very, very, very, experienced, and I'm sill making stupid things.

But the most important thing is to :
"Stop making the same mistakes or be creative - make new mistakes."

Znalezione obrazy dla zapytania przestaÅ popeÅniaÄ te same bÅÄdy

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 (edited)

use a better naming convention such that you give each variable a unique AND MEANINGFUL name. don't use x everywhere and be lazy. Every Error Handler has it's own name. I don't have this problem, ever. in any language

meaningful names describe the variable and it's use

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Posted

Yes autoitwrapper.ini

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
  On 11/16/2018 at 12:45 PM, mLipok said:

Yes autoitwrapper.ini

Expand  

According to the help file located here i created a file 

  Quote

AutoIt3Wrapper.ini

Expand  

in location:

  Quote

%LOCALAPPDATA%\AutoIt v3\SciTE\AutoIt3Wrapper

Expand  

and inside the file I inserted these lines:

  Quote

[Other]
Run_AU3Check=1
AU3Check_Stop_OnWarning=1
AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7

Expand  

But it does not seemed to work. I see no warning when I run script:

Local $test = "some text" ;local variable in global scope
Func Test()
  $variable = "return" ;no variable declaration
  return $variable
Endfunc

Any idea?

Posted
  On 11/8/2018 at 12:40 PM, mLipok said:

or be creative - make new mistakes.

Expand  

:lol: I can learn you :lol::lol::lol:

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

  Reveal hidden contents

 

Posted (edited)
  On 11/23/2018 at 9:57 AM, caramen said:

:lol: I can learn you :lol::lol::lol:

Expand  

I learn day by day.... :)

 

Edited by mLipok

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 (edited)
  On 11/23/2018 at 11:10 AM, mLipok said:

I learn day by day.... :)

 

Expand  

Should specify :D I can learn you to do creative mistake :P 

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

  Reveal hidden contents

 

Posted

I learn day by day.... ... because I make mistakes day by day so I do not need additional mistakes, because I have a lot of my own.

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
  On 11/23/2018 at 8:20 AM, maniootek said:

Any idea?

Expand  

Post here scite console output.

 

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

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...