jaberwacky Posted January 5, 2009 Posted January 5, 2009 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 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
xxbrentonxx Posted January 5, 2009 Posted January 5, 2009 Im much the same as you with AutoIT having just stared two days ago lol but couldnt you just use Dim $var = 0?
jaberwacky Posted January 5, 2009 Author Posted January 5, 2009 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? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
BrettF Posted January 5, 2009 Posted January 5, 2009 Assign/Eval. What sort of reason do you need for that? Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
jaberwacky Posted January 5, 2009 Author Posted January 5, 2009 Assign/Eval.What sort of reason do you need for that?Just wondering if it were even possible. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
xxbrentonxx Posted January 5, 2009 Posted January 5, 2009 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.
BrettF Posted January 5, 2009 Posted January 5, 2009 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 Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
jaberwacky Posted January 5, 2009 Author Posted January 5, 2009 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,BrettCool. Agreed. I didn't want to do it myself, just wondering if it were possible.Thanks to all posters! =D Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum?
bo8ster Posted January 5, 2009 Posted January 5, 2009 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]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now