Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Global - Local - Dim

$
0
0

hey guys I don't understand what Global - Local - Dim do for example here

#include <Constants.au3> ; only required for MsgBox constants
 
Global $Var_1 = "Variable 1"
Global $Var_2 = "Variable 2"
 
; Read the variables
MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "Reading", "In The Main Script" & @CRLF & @CRLF & "Variable 1 = " & $Var_1 & @CRLF & "Variable 2 = " & $Var_2)
 
; Read the variables in a function
_Function()
 
; And now read the variables again - see that $iVar_2 has changed
MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "Reading", "Back In The Main Script" & @CRLF & @CRLF & "Variable 1 = " & $Var_1 & @CRLF & "Variable 2 = " & $Var_2)
 
Func _Function()
    ; Read the variables
    MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "Reading", "In The Function" & @CRLF & @CRLF & "Variable 1 = " & $Var_1 & @CRLF & "Variable 2 = " & $Var_2)
    ; Now let us change one of the variables WITHIN the function
    $Var_2 = "Changed Variable 2"
EndFunc

 

 I have copied it and used it works fine then I removed " Global " and still it works fine same as before nothing changes so what does global do hope someone will explain what they do exactly and sorry for bad english thank you.

 


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>