ghettochild Posted June 25, 2004 Share Posted June 25, 2004 Arg!!! i need to be a fun curu in 24hrs and I cant understand! all my scripts use redundant "mini scripts" help... please... Link to comment Share on other sites More sharing options...
ezzetabi Posted June 25, 2004 Share Posted June 25, 2004 Well... How can we help you? Do you have any particular question? Link to comment Share on other sites More sharing options...
pekster Posted June 26, 2004 Share Posted June 26, 2004 Well, I can supply you with some basic information and see where that gets you.Functions are used to preform a task that you plan to use more than once in your script, or want to have access to without writing all the code out when you call it. There are two basic types of functions: those that return a value, and those that don't. If you just want to replace a bunch of code in your script (say, 15 lines of code that you use in 3 or 4 places) you could use a function that contains these 15 lines. So at the end of your script, you would define a function that includes these 15 lines, and call MyFunc() whenever you wanted these to occur. Your "main body" of the script will pick up at the next line as if the code was in the place of the script.The 2nd reason you might use a function is to do a calculation or manipulate data in a specific manor. You can do this two ways, and one is by returning a variable. A simple example is giving a function one number as a paramater, having the function add 1 to that number it was given, and return the result. See "number adding example" below. You could also change the variable it was given in the paramater instead of returning a value. See "number adding example 2" below.You have two basic features of functions you with: the ability to return a value, and the ability to accept paramaters.If you have a more specific questions, let me know and hopefully someone will reply with an answer that helps.Number adding example:$input = InputBox("Give me a number", "Numer please:") MsgBox(0, "Result", "Your number plus 1 is " & AddOne($input)) Func AddOne($number) return $number + 1 ;return one more than we gave it EndFuncNumber adding example 2:$data = InputBox("Give me a number", "Number please:") AddOneToVar($data) MsgBox(0, "Result", "Your number plus 1 is " & $data) Func AddOneToVar(ByRef $input) $input = $input + 1 EndFunc [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes. 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