Jump to content

Recommended Posts

Posted

I was wondering if there was a way to pass a parameter to a function via reference?

For instance, in the code snippet below my variable is being passed in by value and my initial variable is not changed. Whats the easiest way to pass a pointer to the function so my initial variable is modified?

$outside_var = "null"

foo($outside_var)

Func foo($inside_var)
$inside_var = "Ive been changed!"
EndFunc

Im pretty sure it has to be possible, but I must just be missing the syntax. Also, how do I return something from a function?

$returned_var = foo()

Func foo()
$dummy_var = "Ive returned!"
[i]return $dummy_var ;??? no idea, just throwing something out there[/i]
EndFunc

Any help is appreciated.

Thanks

Posted

  ander868 said:

I was wondering if there was a way to pass a parameter to a function via reference?

For instance, in the code snippet below my variable is being passed in by value and my initial variable is not changed. Whats the easiest way to pass a pointer to the function so my initial variable is modified?

$outside_var = "null"

foo($outside_var)

Func foo($inside_var)
$inside_var = "Ive been changed!"
EndFunc

Im pretty sure it has to be possible, but I must just be missing the syntax. Also, how do I return something from a function?

$returned_var = foo()

Func foo()
$dummy_var = "Ive returned!"
[i]return $dummy_var;??? no idea, just throwing something out there[/i]
EndFunc

Any help is appreciated.

Thanks

Look up the keyword ByRef in the help file.

George

  Reveal hidden contents
Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Posted

Geosoft,

Thanks. got exactly what I needed

Siao,

No one is forcing you read the forum if you have no desire to help. If you're just gonna post some useless comment then don't bother. Read the forum title.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...