SwordHunter4Ever Posted March 28, 2009 Share Posted March 28, 2009 (edited) Hey guys I have a command that I need to use at specific points in a script. I however don't want to type it out five hundred times. Is there anyway to write it once and then use a shorter command to run that large one? (I have much bigger ones.. but I figured for ease of explanation I'll use a shorter one) Here is the command, Sleep(1500) $coord = PixelSearch( $pos[0] + $xload1, $pos[1] + $yload1, $pos[0] + $xload2, $pos[1] + $yload2, 0x8C8C8C ) If Not @error Then Sleep($short) EndIf If @error Then Sleep(1000) EndIf Is there a command that will direct my script to that command and have it run that? but the one I type into my script will be short like "DO $command1" and that script up there would be defined as $command1? EXAMPLE: would be to have the long command at the start of the script and then through the script a goto command telling it to read those lines... However goto has been removed (its been a long time since I really scripted) so I don't know how to do it anymore. The reason for doing this is I'll be able to edit one master command and it will change them all throughout the script. Edited March 28, 2009 by SwordHunter4Ever Link to comment Share on other sites More sharing options...
maqleod Posted March 28, 2009 Share Posted March 28, 2009 just declare it as a function [u]You can download my projects at:[/u] Pulsar Software Link to comment Share on other sites More sharing options...
SwordHunter4Ever Posted March 28, 2009 Author Share Posted March 28, 2009 (edited) just declare it as a functionHow would I go about doing this?Sorry I'm not the greatest at this... (I'm going to go look in the helpfile, but if you could tell me what you know that would help as well).Alright I found how to call a function, now I just need to know how to write one x_XOr define something as one. Edited March 28, 2009 by SwordHunter4Ever Link to comment Share on other sites More sharing options...
maqleod Posted March 28, 2009 Share Posted March 28, 2009 (edited) How would I go about doing this? Sorry I'm not the greatest at this... (I'm going to go look in the helpfile, but if you could tell me what you know that would help as well). at the end of your script, or alternatively in an include file, you would have: Func _MyFunc($argument1,$argument2) ;place your code here EndFunc and then you would just call it in your script like: _MyFunc($1,$2) EDIT: of course the arguments can be any number, including none if you don't need them Edited March 28, 2009 by maqleod [u]You can download my projects at:[/u] Pulsar Software Link to comment Share on other sites More sharing options...
SwordHunter4Ever Posted March 28, 2009 Author Share Posted March 28, 2009 at the end of your script, or alternatively in an include file, you would have: Func _MyFunc($argument1,$argument2) ;place your code here EndFunc and then you would just call it in your script like: _MyFunc($1,$2) EDIT: of course the arguments can be any number, including none if you don't need themSo if I didn't have an argument it would look like Func _Myfunc() ;code here EndFunc and then call it by _MyFunc() Link to comment Share on other sites More sharing options...
maqleod Posted March 28, 2009 Share Posted March 28, 2009 So if I didn't have an argument it would look likeFunc _Myfunc();code hereEndFuncand then call it by_MyFunc()exactly [u]You can download my projects at:[/u] Pulsar Software Link to comment Share on other sites More sharing options...
CodyBarrett Posted March 29, 2009 Share Posted March 29, 2009 and you NEED to have all of the parameters you set included so this would need to be _MyFunc ($i, $j) Func _MyFunc ($i, $j) EndFuncoÝ÷ Û*.çn±ëazƦzv¦z̨¹Æ§®¶seô×gVæ2b33cµf#Âb33cµf#"¤gVæ2ô×gVæ2b33c¶Âb33c¶¢¤VæDgVæ BUT YOU NEED To have all the parameters you specify [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
SwordHunter4Ever Posted March 29, 2009 Author Share Posted March 29, 2009 and you NEED to have all of the parameters you set included so this would need to be _MyFunc ($i, $j) Func _MyFunc ($i, $j) EndFuncoÝ÷ Û*.çn±ëazƦzv¦z̨¹Æ§®¶seô×gVæ2b33cµf#Âb33cµf#"¤gVæ2ô×gVæ2b33c¶Âb33c¶¢¤VæDgVæ BUT YOU NEED To have all the parameters you specifyYou lost me... here is my code, ;loadscreen waiter Func _Loading() $coord = PixelSearch( $pos[0] + $xload1, $pos[1] + $yload1, $pos[0] + $xload2, $pos[1] + $yload2, 0x8C8C8C ) If Not @error Then Sleep(500) EndIf If @error Then Sleep(2000) EndIf EndFunc and here is how I'm calling it, Call("_Loading") I'ms lightly confused by what you mean when you say "I need to have all the parameteres I sepcify", could you edit my code for me x_X or explain it a bit better? Thanks a ton ^^ Link to comment Share on other sites More sharing options...
CodyBarrett Posted March 29, 2009 Share Posted March 29, 2009 well ill explain it.. to call a fun c with parameters.. you need to have the specified amount (im pretty sure)say.. your using this() you cant go this() func this($i,$j) endfunc you CAN do this this() Func This() endfunc AND This($i,$j) Func this ($i,$j) endfunc [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
LiveOnTheFly Posted March 29, 2009 Share Posted March 29, 2009 You lost me... here is my code, ;loadscreen waiter Func _Loading() $coord = PixelSearch( $pos[0] + $xload1, $pos[1] + $yload1, $pos[0] + $xload2, $pos[1] + $yload2, 0x8C8C8C ) If Not @error Then Sleep(500) EndIf If @error Then Sleep(2000) EndIf EndFunc and here is how I'm calling it, Call("_Loading") I'ms lightly confused by what you mean when you say "I need to have all the parameteres I sepcify", could you edit my code for me x_X or explain it a bit better? Thanks a ton ^^ You don't need to sue call() to call a user defined function. You could just do _Loading() 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