Sign in to follow this  
Followers 0
gamerman2360

Var Names

4 posts in this topic

Var names can be anything. As long as it does not start with the @ symbol.. Why?

MsgBox(0, "Test", Assign("@", "")); returns 0
MsgBox(0, "Test", Assign("@test", "")); returns 0
MsgBox(0, "Test", Assign("te@st", "")); returns 1
I think thats the only naming limitation. There is no built in length limit.

Share this post


Link to post
Share on other sites



Var names can be anything. As long as it does not start with the @ symbol.. Why?

MsgBox(0, "Test", Assign("@", "")); returns 0
MsgBox(0, "Test", Assign("@test", "")); returns 0
MsgBox(0, "Test", Assign("te@st", "")); returns 1
I think thats the only naming limitation. There is no built in length limit.
What do Macros start with? @ComSpec etc....

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Var names can be anything. As long as it does not start with the @ symbol.. Why?

MsgBox(0, "Test", Assign("@", "")); returns 0
MsgBox(0, "Test", Assign("@test", "")); returns 0
MsgBox(0, "Test", Assign("te@st", "")); returns 1
I think thats the only naming limitation. There is no built in length limit.
Might want to re-check that.

Edit:

I should have stated.

Vars must be any of the following characters:

a-z

A-Z

0-9

_

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Vars can be null(Edit: ment to say "any character, even null", also I know this isn't what the help file states but it can be done.), but of course it has to be defined in Assign().

Are var names and macros evaluated in the same way? Would Eval("@ScriptName") return the script name or $@ScriptName?

...

Nope

Tests so far:

MsgBox(0, "Test", Assign("@", "")); returns 0
MsgBox(0, "Test", Assign("@test", "")); returns 0
MsgBox(0, "Test", Assign("te@st", "")); returns 1
MsgBox(0, "Test", Eval("@ScriptName")); returns ""

$msg = ""
For $i = 0 To 255
    If Not Assign(Chr($i), $i, 2) Then $msg &= $i
Next
MsgBox(0, "Test", $msg); Returns 64
Assign(Chr($i), $i, 2) sets the vars to $i because it would hit the var used in the for loop $i and reset it :\. Edited by gamerman2360

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  
Followers 0