Case Sensitivity

HaasScript is a case-sensitive language, which means that you need to make sure you write each and every command and variable the same way they were created. For example, let’s look at the code below:

-- define a variable
SomeVariable = "Hello"

-- manipulate our variable
someVariable = SomeVariable .. " World!"

-- print the result
Log( SomeVariable )

…do you see anything wrong in it? No? Well you should! The above code actually has defined two different variables instead of just one. Still can’t see it? Well if you look closely, you can see that our first variable is written with an upper-case S, whereas the part where we manipulate it, it is actually written with lower-case. So what is actually happening here?

  • We create a variable called SomeVariable and assign a value “Hello” to it
  • We create another variable called someVariable and assign SomeVariable’s value to it with a concatenation for ” World!”
  • We print the value of SomeVariable, which will just output “Hello”

And as mentioned, the same rules apply for built-in and custom commands, functions and table/object indices to name a few more:

close = closePrices() -- error: unknown reference

pos_dir = Getpositiondirection() -- error: unknown reference

some_object = {
    key1 = 5,
    Key2 = 10
}

Log( some_object.key2 ) -- no error, but outputs "nil" since "key2" doesn't exist

And the list goes on…

Back to: HaasScript Fundamentals > Getting Started