Jump to content
Sign in to follow this  
inlander

Local vars

Recommended Posts

inlander

When using the Local keyword on a variable within a function, such as in the example:

 
Func Example()
    ; Retrieve the data stored in the clipboard.
    Local $sData = ClipGet()
...
 
EndFunc   ;==>Example
 
is this local to the function, or local to the script?  If local to the function, how would I declare it local to the script?
(I want to check it outside the function.)   Can a function return a value, as in most other languages?
 
Also, I am not used to on-the-fly declarations with an assignment.  How is a variable explicitly declared?
 
TIA for your help.
Inlander

Share this post


Link to post
Share on other sites
Geir1983

Use keyword Return in the function to return a result. Variables decleared inside the function with Local will only exist inside the function.

Share this post


Link to post
Share on other sites
Danyfirex

could be.

1

global $data=""

 

func getdata()

$data=clipget

endfunc

2

local $data=getdata()

func getdata()

return=clipget()

endfunc

3

also could use byref.

Edited by Danyfirex

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  

×