z0mgItsJohn Posted January 10, 2008 Share Posted January 10, 2008 (edited) Ok... I Am Working Of A System And I Want The Func To Be Able To Set A Return... Heres What I'm Talking About... Func _Add ($Add_1 , $Add_2 , $Return) $Return = $Add_1 + $Add_2 EndFunc ;Example _Add (5 , 5 , $Add_Equal ) ; I Want $Add_Equal To Be The Return Value.... Without Haveing To Set It In The Top MsgBox (0, "Test", $Add_Equal,0) Can Anyone Help Me Please! :/ Please Give Me An Example.. If You Can Help Me... Edited January 10, 2008 by John2006 Latest Projects :- New & Improved TCP Chat Link to comment Share on other sites More sharing options...
Xenobiologist Posted January 10, 2008 Share Posted January 10, 2008 HI, Func _Add($Add_1, $Add_2) Return $Add_1 + $Add_1 EndFunc ;==>_Add ;Example ; I Want $Add_Equal To Be The Return Value.... Without Haveing To Set It In The Top MsgBox(0, "Test", _Add(5, 5), 0) So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Fossil Rock Posted January 10, 2008 Share Posted January 10, 2008 Func _Add ($Add_1 , $Add_2 , $Return) $Return = $Add_1 + $Add_1 Return ($Return) EndFuncoÝ÷ Ú«¨µéÚ Can Anyone Help Me Please! :/ Please Give Me An Example.. If You Can Help Me... Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
z0mgItsJohn Posted January 10, 2008 Author Share Posted January 10, 2008 That Dose Not Answer My Question! :/ Latest Projects :- New & Improved TCP Chat Link to comment Share on other sites More sharing options...
z0mgItsJohn Posted January 10, 2008 Author Share Posted January 10, 2008 Ahh! Fossil Rock You Posted Before I Was About To Post The One Above The One Above Is For Xenobiologist Latest Projects :- New & Improved TCP Chat Link to comment Share on other sites More sharing options...
z0mgItsJohn Posted January 10, 2008 Author Share Posted January 10, 2008 Can I Make $Return = A Different Var... Without Edited The Func? Please Help >.< Latest Projects :- New & Improved TCP Chat Link to comment Share on other sites More sharing options...
z0mgItsJohn Posted January 10, 2008 Author Share Posted January 10, 2008 (edited) Well I'm Off To Bed Ill Check The Topic Tomorrow @ School ^^ But Please Keep Giving Answers ^^ Edited January 10, 2008 by John2006 Latest Projects :- New & Improved TCP Chat Link to comment Share on other sites More sharing options...
DW1 Posted January 10, 2008 Share Posted January 10, 2008 This must be a typo $Return = $Add_1 + $Add_1... $1 + $1? you mean $1 + $2 right? If you are going to hardcode the "$Add_Equal" in "_Add (5 , 5 , $Add_Equal )" then why not just hardcode the return: Func _Add ($Add_1 , $Add_2 ) Return $Add_1 + $Add_2 EndFunc $Add_Equal = _Add (5 , 15 ) MsgBox (0, "Test", $Add_Equal,0) AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DirtDBaK Posted January 10, 2008 Share Posted January 10, 2008 @John2006: there is an Edit button. But Anyways if you could tell what you mean by: $Return = A Different Var... Without Edited The Func?If you mean that You want to use the $Return variable outside of the function and inside of the function it would be something like this: Global $Return _Add(1,1) ;This should equal 2 MsgBox(0,'',$return) ;should be 2 $Return = $Return + 7 MsgBox(0,'',$return) ;2+7 = 9 therefore the answer should be nine _Add(3,4); 3+4 = 7 so the answer would be 7 MsgBox(0,'',$return) Func _Add($var_1,$var_2) ;Adds var 1 and Var 2 into the $return var $Return = $var_1 + $var_2 Endfunc Notice this way the var $return doesn't have to be just inside the fucntion, nor do you have to pass it. See the globals work so that functions read the var the same way the script outside of functions do. The code you posted has local vars thats why you must use Return() to return that local var. Hope that helps! [center][/center] Link to comment Share on other sites More sharing options...
rover Posted January 10, 2008 Share Posted January 10, 2008 (edited) Local $Add_Equal _Add (5 , 5 , $Add_Equal) MsgBox (0, "Test", $Add_Equal,0) Func _Add ($Add_1 , $Add_2 , ByRef $Return) $Return = $Add_1 + $Add_2 EndFunc Edited January 10, 2008 by rover I see fascists... Link to comment Share on other sites More sharing options...
z0mgItsJohn Posted January 10, 2008 Author Share Posted January 10, 2008 Local $Add_Equal _Add (5 , 5 , $Add_Equal) MsgBox (0, "Test", $Add_Equal,0) Func _Add ($Add_1 , $Add_2 , ByRef $Return) $Return = $Add_1 + $Add_2 EndFunc Thank You So Much Rover ^^ My Question Was Answered The Topic Can Be Closed Now ~~ Latest Projects :- New & Improved TCP Chat 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