Jump to content

Functions & Variable Declarations


Recommended Posts

Hi!

I'm not completely new to coding but I am new to AutoIt. I still have much to learn about programming.

I was just wondering about something useless and so I thought I'd make a post to see your thoughts. Could you make a function that would declare and initialize a variable? It would work by passing the name of the variable and the initial value as arguments.

I'm sure that there is no point in this function.

Thanks!

Matt

Link to comment
Share on other sites

Im much the same as you with AutoIT having just stared two days ago lol but couldnt you just use

Dim $var = 0
?

Well, yar, I guess you could, but where's the fun in that?

Link to comment
Share on other sites

IMO it is very stupid to use a function to create your variables. Debugging will become 100 times harder. You will run into many problems. Just use the tried and proven methods. Global and Local are the best.

Cheers,

Brett

Link to comment
Share on other sites

IMO it is very stupid to use a function to create your variables. Debugging will become 100 times harder. You will run into many problems. Just use the tried and proven methods. Global and Local are the best.

Cheers,

Brett

Cool. Agreed. I didn't want to do it myself, just wondering if it were possible.

Thanks to all posters! =D

Link to comment
Share on other sites

As said before, scope will be an issue, use Global or Local instead of Dim. Dim sets it to Local by default so it won't be seen out side of the function like other programming languages. See the helpfile for more info.

I have a file that has all of my Global vars declared then I include it into my scripts - #include "global.au3" Makes things simple.

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

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