FadetoGrey Posted May 10, 2009 Share Posted May 10, 2009 I've got a hugh chunk of code that I need to keep copying and pasting, but is there a way I can just put it into one variable so all that code won't cramp up the page? I never want it to go away either, it needs to stay alive forever. Link to comment Share on other sites More sharing options...
Qousio Posted May 10, 2009 Share Posted May 10, 2009 I've got a hugh chunk of code that I need to keep copying and pasting, but is there a way I can just put it into one variable so all that code won't cramp up the page? I never want it to go away either, it needs to stay alive forever.We don't know what the code is so its hard to answer your question. Link to comment Share on other sites More sharing options...
FadetoGrey Posted May 10, 2009 Author Share Posted May 10, 2009 We don't know what the code is so its hard to answer your question. Maybe variable was the wrong word perhaps? Really just a name of a piece of code so I don't have to keep copy and pasting it. Say if I wanted this code to be put into a variable (or a shortcut name, whatever): Do $xchange = 29 While $xchange <= 49 $xchange = $xchange + 1 WEnd Until 20 = 21 how would you do that? Link to comment Share on other sites More sharing options...
Mat Posted May 10, 2009 Share Posted May 10, 2009 (edited) Turn it into a function... Func _Code () Do $xchange = 29 While $xchange <= 49 $xchange = $xchange + 1 WEnd Until 20 = 21 EndFunc;==>_Code Thats a ridiculous pice of script though... but you get the idea. to use the code in the script just use "_Code ()" eg MsgBox (48, "", _Code ()) Func _Code () Return 3 EndFunc;==>_Code Edited May 10, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
FadetoGrey Posted May 10, 2009 Author Share Posted May 10, 2009 Turn it into a function... Func _Code () Do $xchange = 29 While $xchange <= 49 $xchange = $xchange + 1 WEnd Until 20 = 21 EndFunc;==>_Code Thats a ridiculous pice of script though... but you get the idea. to use the code in the script just use "_Code ()" eg MsgBox (48, "", _Code ()) Func _Code () Return 3 EndFunc;==>_Code So I just put _Code () anywhere and it'll run it, right? Link to comment Share on other sites More sharing options...
Mat Posted May 10, 2009 Share Posted May 10, 2009 (edited) Yep! its amazing isnt it. Just make sure the actuall function is somewhere in the script. all the functions you use (like msgbox) are written in a similar way, and automatically included, you are just writing your own. (That last sentence is dramatically oversimplified...) MsgBox (48, "", _Code ()) MsgBox (48, _Code (), "") MsgBox (48, "", 5 * _Code ()) Func _Code () Return 3 EndFunc;==>_Code etc!! Edited May 10, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
Qousio Posted May 10, 2009 Share Posted May 10, 2009 Yep! its amazing isnt it.Wow I thought that guy wanted a script that puts a part of code into your clipboard, so I hesitated to answer.But yeah, its amazing he doesn't know what a function is. Since the scripts I was spoon feeding him had functions Link to comment Share on other sites More sharing options...
Developers Jos Posted May 10, 2009 Developers Share Posted May 10, 2009 Wow I thought that guy wanted a script that puts a part of code into your clipboard, so I hesitated to answer.But yeah, its amazing he doesn't know what a function is. Since the scripts I was spoon feeding him had functions I am surprised that your are surprised about it. The OP doesn't really care about trying to learn and research first, just wants his "problem" resolved as fast as possible.I bet he will try any script you post as a solution to his problem without understanding it fist.Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Qousio Posted May 10, 2009 Share Posted May 10, 2009 I am surprised that your are surprised about it. The OP doesn't really care about trying to learn and research first, just wants his "problem" resolved as fast as possible.I bet he will try any script you post as a solution to his problem without understanding it fist.JosOh well, no more mr. nice guy from me then.He has to learn someday right ? Link to comment Share on other sites More sharing options...
Mat Posted May 10, 2009 Share Posted May 10, 2009 have I missed something? Or is it just be mean to noobs day? I know it took me a while to get my head around the ins and outs of parameters and functions. I just read the helpfile though... @FadeToGrey - Whatever you do, read the helpfile first - It knows best, and is desceptively easy to understand. MDiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
Developers Jos Posted May 10, 2009 Developers Share Posted May 10, 2009 (edited) have I missed something? Or is it just be mean to noobs day? I know it took me a while to get my head around the ins and outs of parameters and functions. I just read the helpfile though...@FadeToGrey - Whatever you do, read the helpfile first - It knows best, and is desceptively easy to understand.MDieselIt is not mean to noobs day and as far as I can tell I am not being mean, just honest. I see many newcomers lately, of which i guess most are still young and want to start making bots and they largely are being very impatient and not willing to spend anytime to learn/read/research before starting to create many threads/posts asking question that clearly show they haven't put much thought into the questions.So, I have no issue with anybody that demonstrates the will to learn. Edited May 10, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
FadetoGrey Posted May 10, 2009 Author Share Posted May 10, 2009 Yep! its amazing isnt it. Just make sure the actuall function is somewhere in the script. all the functions you use (like msgbox) are written in a similar way, and automatically included, you are just writing your own. (That last sentence is dramatically oversimplified...) MsgBox (48, "", _Code ()) MsgBox (48, _Code (), "") MsgBox (48, "", 5 * _Code ()) Func _Code () Return 3 EndFunc;==>_Code etc!! Thanks, just what I needed, makes the coding easier, you know. Link to comment Share on other sites More sharing options...
Mat Posted May 10, 2009 Share Posted May 10, 2009 (edited) no probs, thats what its supposed to do.@Jos: Thats OK then, I thought the op had done something horribly wrong and was reposting the same thing for the 5th time, in which case I probably would have ignored it...@FadeToGreyhave you seen some of the functions I made? check out these ones!@Jos part 2: Don't worry Jos, it's school holidays soon, and as GeoSoft (I think) said: "and just a reminder, not long until school is out for 1/2 the world. That's when the annual crop of total idiots start to come out in strength. You know the ones, their shoe size is larger than their IQ. " Edited May 10, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
FadetoGrey Posted May 10, 2009 Author Share Posted May 10, 2009 @FadeToGreyhave you seen some of the functions I made? check out these ones!Which one do I put into AutoIt? First or Second? Link to comment Share on other sites More sharing options...
Mat Posted May 10, 2009 Share Posted May 10, 2009 You can use the first... It was more of an example of the layout of a UDF (User Defined Function). These functions can be used by anyone running on autoit, and be useful to them, See what I mean?MDieselThe helpfile (as always) has an entire section devoted to functions! check here for an online version AutoIt Project Listing Link to comment Share on other sites More sharing options...
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