Jump to content

Simple func not working any more


Recommended Posts

  • Developers

byref means that the value is returned to the variable in the calling code eg:

$a=5
test($a)
msgbox(0,"test", "$a=" & $a); $a will still be 5

Func test($a)
   $a = $a * 10
EndFunc
$a=5
test($a)
msgbox(0,"test", "$a=" & $a); $a will be the retruned result thus 50

Func test(byref $a)
   $a = $a * 10
EndFunc
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

If you don't want to change the value of $a you can use the return option

$a=5
$b=test($a)
msgbox(0,"$a=" & $a, "$b=" & $b); $a stays 5, $b will be the returned result thus 50

Func test($a)
  $a = $a * 10
Return $a
EndFunc

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
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
 Share

  • Recently Browsing   0 members

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