Jump to content

possibly stupid question, remove scite warnings?


marko29
 Share

Recommended Posts

Is there anyway to do it, i am searching but hardly find anything.

ex: i dont need warning that i defined variable somewhere else and not on the top(why would i clutter the top of my script unless i really need to anyway?)

I prefer to define my vars whenever possible during runtime.

Also there are warnings like "variable might be used before its definition", i really dont need this so if anyone knows solution

Link to comment
Share on other sites

put Opt("MustDeclareVars", 1) at the top of your script else program poorly and spend hours debugging.

If declarations bother you and you are in to very bad programing practice, you can declare them in a declare them in a separate source file then include the file.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

The closest thing that I can see that might solve your problem is by going into scite and then choosing Tools -> Scite Config and then the tools section tab. Good Luck.

Thanks but already tried that.

The problems i get are mostly array declarations, since i have no idea what will the size of my array be i can't declare it properly on the top, so the only way to set correct size by Global $array is after i get the size integer which happens later during runtime, this way i get bunch of warnings for no good reason and every time i hit "Go" my heart stops when i see red letters, thinking i will need to debug something again, not to mention i need to scroll for a minute in the output window to find the actual "Error" if it happens.

Its not like a enormous issue but you know i would like to see my code compile once without those pesky red letters, i just uhh hate them

Edited by marko29
Link to comment
Share on other sites

Thanks but already tried that.

The problems i get are mostly array declarations, since i have no idea what will the size of my array be i can't declare it properly on the top, so the only way to set correct size by Global $array is after i get the size integer which happens later during runtime, this way i get bunch of warnings for no good reason and every time i hit "Go" my heart stops when i see red letters, thinking i will need to debug something again, not to mention i need to scroll for a minute in the output window to find the actual "Error" if it happens.

Its not like a enormous issue but you know i would like to see my code compile once without those pesky red letters, i just uhh hate them

Redim is your answer. Do you know what a vector is? It is what you a looking for. Try something like its - note it is rough code.

#include <Array.au3>

Global $my_array = 0
$my_array = setArray(5)

_ArrayDisplay($my_array)

Func setArray($size)

    if ($size <= 0) Then
        Return 0
    EndIf

    Local $array[$size]
    Return $array
EndFunc   ;==>setArray

Edit: Yes $array is declared local so in theory this should not work (scope) but it does. I would change "Local $array[$size]" to "ReDim my_array[$size]" and return $my_array if this was an issue.

Edited by bo8ster

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

Redim is your answer. Do you know what a vector is? It is what you a looking for. Try something like its - note it is rough code.

#include <Array.au3>

Global $my_array = 0
$my_array = setArray(5)

_ArrayDisplay($my_array)

Func setArray($size)

    if ($size <= 0) Then
        Return 0
    EndIf

    Local $array[$size]
    Return $array
EndFunc   ;==>setArray

Edit: Yes $array is declared local so in theory this should not work (scope) but it does. I would change "Local $array[$size]" to "ReDim my_array[$size]" and return $my_array if this was an issue.

yes, i v found about redim earlier and indeed its good thing to use but to be honest the real problem is that Autoit is so good and easy to use that it spoiled me so much that i wanted to declare everything anywhere i want. I am very used on #include headers in c++ but perhaps i thought for a second, subconciouslly that everything like that is gone in autoit, guess i ll start waking up and do some old crappy code maintance

Still, i have no idea why it is not good to define/initialize variables whenever i want(in autoit) but i guess there is a good reason for it, behind the scenes in the low level part of autoit, or scite is just complaining because it thinks i might be clueless for not following standard patterns?

Link to comment
Share on other sites

1.) You don't declare global in functions because it is bad programming and it demonstrates you have no idea what you are doing. Read up on scope of vars. Also you will notice good programmers declare all of their global vars at the top of the script. Why? So they don't have to search to find out how/where they were declared, keeping it simple.

2.) AutoIt will not complain if you don't follow standard patterns or if you write the worst code ever, it will do what you tell it to do. The issue will be when you are trying to debug your script and you have no idea what is happening because you wrote crap code. You will post your code on a forum asking for help and get little response because no one else can understand it either.

If you understand the and use the basic programming best practices you can't really go wrong.

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Link to comment
Share on other sites

1.) You don't declare global in functions because it is bad programming and it demonstrates you have no idea what you are doing. Read up on scope of vars. Also you will notice good programmers declare all of their global vars at the top of the script. Why? So they don't have to search to find out how/where they were declared, keeping it simple.

This is stupid, why would i search where i declared the var if i know i did it in function that actually is the only logical place where i should of declare it. Did you ever see a c++ header? The reason everything is predeclared is because of scope, Autoit already has a Global scope keyword so why would you make a sandwich of hundreds of declarations on the top of your code if you dont need it? Maybe i dont see some other reason someone else can figure but this reasoning you present is just silly narrowminded perception that everyone code is same, in a huge program i like organize things and put everything where it matters, not make a pasta in the top of my code.

2.) AutoIt will not complain if you don't follow standard patterns or if you write the worst code ever, it will do what you tell it to do. The issue will be when you are trying to debug your script and you have no idea what is happening because you wrote crap code. You will post your code on a forum asking for help and get little response because no one else can understand it either.

In several days i wrote a mix of spider, scrapper, automation tool with bunch of loops and iterations, still have to post a code here so i have no idea why you think no one can understand my code.

If you understand the and use the basic programming best practices you can't really go wrong.

If something is annoying in this world its those people like you who just cant bother to ask questions and follow everything they are told, how ever in life can you improve things that way?

Also since you talk about programming practices you made a function that just wastes space, in the post before

All that code you wrote is useles and not needed, just as i said makes a pasta you dont need and which confuses things.

Global $my_array = 0
$my_array = setArray(5)

_ArrayDisplay($my_array)

Func setArray($size)

    if ($size <= 0) Then
        Return 0
    EndIf

    Local $array[$size]
    Return $array
EndFunc   ;==>setArray

:x

could replace it with just redim

Edited by marko29
Link to comment
Share on other sites

  • Moderators

marko29,

To return to your initial question before someone says something that they come to regret. :shifty:

If you do not wish SciTE (or to be more correct AutoIt3Wrapper) to check your code using Au3Check when you run, build or compile, you need to create an ini file to tell it not to do so. There is an example ini file at "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.ini.example" if you have a standard install.

Setting the "Run_AU3Check=0" line and saving the file as "AutoIt3Wrapper.ini" in the same folder as the example will prevent Au3Check from running and you should no longer get the warnings. :P

Personally I find the Au3Check warnings of great help, particularly as clicking on them takes me straight to the error line in SciTE, but if that is what you want..... :x

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

marko29,

To return to your initial question before someone says something that they come to regret. :shifty:

If you do not wish SciTE (or to be more correct AutoIt3Wrapper) to check your code using Au3Check when you run, build or compile, you need to create an ini file to tell it not to do so. There is an example ini file at "C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.ini.example" if you have a standard install.

Setting the "Run_AU3Check=0" line and saving the file as "AutoIt3Wrapper.ini" in the same folder as the example will prevent Au3Check from running and you should no longer get the warnings. :P

Personally I find the Au3Check warnings of great help, particularly as clicking on them takes me straight to the error line in SciTE, but if that is what you want..... :x

M23

M23, but that would probably remove errors as well so it would really be a dumb thing to do. I also find it great but for ERRORS.

Anyway since i can't stand the warnings cluttering my output where i need to look for real error among them i just decided to declare everything on the top, i still dont see why declaring every single variable on top makes your code more readable or cleaner as the guy before says(i will mention that for some things i understand its good thing to do, but for every single variable? I find it silly since there is Global keyword

Anyway what else is the reason for Global keyword if by default everything outside Local is Global? I guess that guy who says i have no idea what am i doing will not answer that. The only logical answer is that Global keyword exists to give you flexibility which obviously Scite sometimes will not understand.

Link to comment
Share on other sites

  • Moderators

marko29,

One case where you might need Global other than at the original declaration is if you need to clear a Global array within a function to make sure you only get the elements that will be filled that run. Either you clear the array by clearing each element individually in a loop, or you redeclare the array in the same scope as originally - using Dim is deprecated as you then are not sure quite what scope you have set. :P

Of course, ideally you should try to have as few Global variables as possible - less chance of overwriting them by mistake - so you should not have an enormous list at the top of your script. But it is best to declare them there - declaring a Global variable inside a function is fine when you start coding, but what if you move the function within the script or decide to use the variable in another function which comes earlier in execution? :x

Experience over the years has shown that declaring Global variables at the start is good practice - ignore that at your own risk and peril! :nuke:

M23

P.S. These are the Au3Check parameters - you set them by adding the #AutoIt3Wrapper_au3check_parameters= directive to the top of your script. Perhaps you can find a setting which better suits your preferred coding style.

The default is -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6. :shifty:

Usage: Au3Check [-q] [-d] [-u file] [-w[-] n].. [-v[-] n].. [-I dir].. file.au3
            -q      : quiet (only error/warn output)
            -d      : as Opt("MustDeclareVars", 1)
            -I dir  : additional directories for searching include files
            -U -|file : output unreferenced UDFs and global variables
            -w 1      : already included file (on)
            -w 2      : missing #comments-end (on)
            -w 3      : already declared var (off)
            -w 4      : local var used in global scope (off)
            -w 5      : local var declared but not used (off)
            -w 6      : warn when using Dim (off)
            -v 1      : show include paths/files (off)
            -v 2      : show lexer tokens (off)

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I used to have similar problems, and used similar arguments to you. Eventually I got so annoyed at the errors I made myself program under the strictest mode (-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 - I don't think that's the default, but Melba seems to say that it is). I can honestly say that it's done my programming wonders. It forces you (among coding properly) to slow down and think about what you are writing. And besides, I haven't had an error like that in a long time now, I've learnt how to write code properly.

Spaghetti coding is the best way to describe it. Although you think you are writing in clear sequences, until it cooks, and you end up with a big mess.

Link to comment
Share on other sites

One other thing to take in consideration ... in relation to potential forum help on posted code. I for one usually only eyeball code that fails certain "#AutoIt3Wrapper_AU3Check_Parameters=..." settings. Now I don't count for much and I don't know about others ... but it could play a role in getting a lot of Eyeball "try <this> or <that>" answers or a direct "change <this> to <that>" or your doing <this/that> wrong answer.

(+Same as Mat)

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

I didnt think it matterd where you declare your global variable, so long as its in the global scope, and before its called upon to be used.

Is that correct? I think so, as when you use obfuscator with the striponly switch thats how it winds up, and the scripts work fine.

I think there may be some confusion here (probably just on my part) with declarations of vatiables and (a word escaping my grey matter , meaning activation) of variables.

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

Monkey's are, like, natures humans.

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