Page 1 of 1

HaveItem does not work if uppercase letters are used

Posted: Tue Apr 04, 2023 10:03 pm
by amiga23
If I put a key with uppercase letters into a table, HaveItem does not find it. I found some similar issues in the forum, but these claim that table keys are case sensitive, so I consider this a bug in HaveItem().

I guess there is a LowerStr() in HaveItem, which should not be there.

Code: Select all

table = {}
table["Hello AMIGA"] = "AMIGA"

DebugPrint(table["Hello AMIGA"])
DebugPrint(HaveItem(table, "Hello AMIGA"))  ; Does not find it -> BUG
DebugPrint(HaveItem(table, "hello amiga"))  ; Does not find it -> correct

table = {}
table["HelloAMIGA"] = "AMIGA"

DebugPrint(table["HelloAMIGA"])
DebugPrint(HaveItem(table, "HelloAMIGA"))   ; Does not find it -> BUG
DebugPrint(HaveItem(table, "helloamiga"))   ; Does not find it -> correct

table = {}
table["hello amiga"] = "AMIGA"

DebugPrint(table["hello amiga"])
DebugPrint(HaveItem(table, "Hello AMIGA"))  ; Does find it -> BUG
DebugPrint(HaveItem(table, "hello amiga"))  ; Does find it -> correct

table = {}
table["helloamiga"] = "AMIGA"

DebugPrint(table["helloamiga"])
DebugPrint(HaveItem(table, "HelloAMIGA"))  ; Does find it -> BUG
DebugPrint(HaveItem(table, "helloamiga"))  ; Does find it -> correct

Re: HaveItem does not work if uppercase letters are used

Posted: Tue Apr 04, 2023 10:13 pm
by amiga23
Hmm okay, RawGet() is the function to use. But that is confusing, what is this automatic lower case good for?

Re: HaveItem does not work if uppercase letters are used

Posted: Thu Apr 13, 2023 3:34 pm
by airsoftsoftwair
amiga23 wrote: Tue Apr 04, 2023 10:13 pm Hmm okay, RawGet() is the function to use. But that is confusing, what is this automatic lower case good for?
In contrast to Lua, Hollywood doesn't distinguish between upper and lower case for convenience's sake. Some internal VM mechanics make it necessary that Hollywood does an upper/lower case distinction when it comes to table items. It tries to hide the fact that it does that from users as much as possible but in some scenarios it's impossible to avoid. See here for some more info: viewtopic.php?p=16467#p16467