In my pursuit of applying 'good coding practice' to AutoIt, I draw your attention to the Const keyword and ask whether I should I use it in my own code when I already have an understanding of what the code is doing? Or should I use it for the purposes of debugging as Au3Check will flag a syntax error?
#include <Constants.au3>
Example()
Func Example()
Local $sMessage = 'Some message that is assigned to a variable which won''t be changed i.e. constant variable.' ; This won't change
Local $iVar = 0 ; This variable in local scope will be changed.
For $i = 1 To 10
$iVar += 1
Next
MsgBox($MB_SYSTEMMODAL, '$iVar=' & $iVar, $sMessage)
EndFunc ;==>Example
OR should I use it regardless?
#include <Constants.au3>
Example()
Func Example()
Local Const $sMessage = 'Some message that is assigned to a variable which won''t be changed i.e. constant variable.' ; This won't change
Local $iVar = 0 ; This variable in local scope will be changed.
For $i = 1 To 10
$iVar += 1
Next
MsgBox($MB_SYSTEMMODAL, '$iVar=' & $iVar, $sMessage)
EndFunc ;==>Example
Invoke an Au3Check error.
#include <Constants.au3>
Example()
Func Example()
Local Const $sMessage = 'Some message that is assigned to a variable which won''t be changed i.e. constant variable.' ; This won't change
Local $iVar = 0 ; This variable in local scope will be changed.
; Creates an error as previously being declared as a Const.
$sMessage = ''
For $i = 1 To 10
$iVar += 1
Next
MsgBox($MB_SYSTEMMODAL, '$iVar=' & $iVar, $sMessage)
EndFunc ;==>Example