Sign in to follow this  
Followers 0
jaberwacky

Functions & Variable Declarations

9 posts in this topic

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

Share this post


Link to post
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
?

Share this post


Link to post
Share on other sites

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

All that matters is it works and your coding is understandable and not messy.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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]

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  
Followers 0