Could I ask about the scope of variables created with the /var <variable name> ?
I was researching something else and looking for clues all over the place and (re-) stumbled upon this from the mIRC help (.chm) file :Local variables are variables that exist only for the duration of the script in which they are created and can only be accessed from within that script. They can be created with the /var command:
which suggests local variables are accessible anywhere within a script.Wikichip variables - mIRC
expands upon this with :Local Variables are given local scope. They are created for the duration of the script that made them and they can only be accessed from within the code line, or block in which they were created in. Once the script has finished, the variable is deleted.
Now that agrees and then disagrees with the help file.
'they can only be accessed from within the code line
' - that has to be wrong. If you can only access it from 'the line' then you cant use it on any other line, or does that refer to a one line 'code block' ? In which case - why mention it ?
'or block in which they were created in.
' makes more sense and agrees with (just about) every other languages, but then follows that with :
'Once the script has finished, the variable is deleted.
I thought it was local to the code block (alias ?) In which case it would be deleted as soon as the code block is finished with and recreated if the code block was called again.
Now that raised another question.
Just what is a 'code block
' ? I had assumed it was an alias, or an On Event block, and have some global variables to allow access between the different code blocks.
'until the script has finished
' suggests that /var items are 'Global' within the script.
Could some one please defing local scope in an understandable manner, devoid of contradictions ?