Jump to content
Sign in to follow this  
z0mgItsJohn

Can A Variable Set Another Variable?

Recommended Posts

z0mgItsJohn

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 by John2006

Latest Projects :- New & Improved TCP Chat

Share this post


Link to post
Share on other sites
Xenobiologist

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

Share this post


Link to post
Share on other sites
Fossil Rock

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!

My-Colors.jpg

cuniform2.gif

Share this post


Link to post
Share on other sites
z0mgItsJohn

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

Share this post


Link to post
Share on other sites
z0mgItsJohn

Well I'm Off To Bed Ill Check The Topic Tomorrow @ School ^^

But Please Keep Giving Answers ^^

Edited by John2006

Latest Projects :- New & Improved TCP Chat

Share this post


Link to post
Share on other sites
DW1

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)

Share this post


Link to post
Share on other sites
DirtDBaK

@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]

Share this post


Link to post
Share on other sites
rover

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 by rover

I see fascists...

Share this post


Link to post
Share on other sites
z0mgItsJohn

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.