
Komag
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2015
02:21 PM
BUG - case sensitivity in AA.Delete() - solved, ParseJson()
I have a function that sets a new associative array (AA) value:
m.cAA.puz[ 1].teleTrap = 1 ' Store puz info
Later I wanted to delete it, so I ran:
? m.cAA.puz[ 1].Delete("teleTrap") ' Reset to default where key/value doesn't exist, potentially cuts down on save game size
But it wasn't working - which is why I added the ?, and it always prints "false" - why???
Then I tried:
? m.cAA.puz[ 1].Delete("teletrap") ' Reset to default where key/value doesn't exist, potentially cuts down on save game size
WORKS!
Turns out when I assigned the value, it was assigned as "teletrap" all lower case, and when I go to use .Delete(), it's case sensitive! This seems like a bug to me. I don't care if it saves the key string all lower case even though I entered some caps, but I wanna have my cake and eat it too - allow the delete command to not care if I enter caps there too!
m.cAA.puz[ 1].teleTrap = 1 ' Store puz info
Later I wanted to delete it, so I ran:
? m.cAA.puz[ 1].Delete("teleTrap") ' Reset to default where key/value doesn't exist, potentially cuts down on save game size
But it wasn't working - which is why I added the ?, and it always prints "false" - why???
Then I tried:
? m.cAA.puz[ 1].Delete("teletrap") ' Reset to default where key/value doesn't exist, potentially cuts down on save game size
WORKS!
Turns out when I assigned the value, it was assigned as "teletrap" all lower case, and when I go to use .Delete(), it's case sensitive! This seems like a bug to me. I don't care if it saves the key string all lower case even though I entered some caps, but I wanna have my cake and eat it too - allow the delete command to not care if I enter caps there too!
6 REPLIES 6

NewManLiving
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2015
02:49 PM
Re: BUG - case sensitivity in AA.Delete()
What happens when you call setmodecasesensitive
My Channels: 2D API Framework Presentation: https://owner.roku.com/add/2M9LCVC
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )
Updated: 11-11-2015 - Completed Keyboard interface
The Joel Channel ( Final Beta )

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2015
03:01 PM
Re: BUG - case sensitivity in AA.Delete()
Are you calling SetModeCaseSensitive on the AA? If you don't call that, it should work the way you want:
--Mark
BrightScript Debugger> a={}
BrightScript Debugger> a.teleTrap = 1
BrightScript Debugger> ?a.Delete("teleTrap")
true
--Mark

Komag
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2015
04:23 PM
Re: BUG - case sensitivity in AA.Delete()
No, I've never called SetModeCaseSensitive in my life! 8-)
When I try your test in debugger it works just like you show it working for you.
So something must be different...testing...
When I try your test in debugger it works just like you show it working for you.
So something must be different...testing...

Komag
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2015
04:38 PM
Re: BUG - case sensitivity in AA.Delete()
AHA! I found the answer! 😄
I was also testing my saving and loading using registry info. I do that via FormatJson() and ParseJson(), so I just reviewed them and see "Any roAssociativeArray objects in the returned objects will be case sensitive". So that explains it! 😉
I suppose it's not a bug then, just something to be aware of.
I was also testing my saving and loading using registry info. I do that via FormatJson() and ParseJson(), so I just reviewed them and see "Any roAssociativeArray objects in the returned objects will be case sensitive". So that explains it! 😉
I suppose it's not a bug then, just something to be aware of.
EnTerr
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2015
10:11 AM
Re: BUG - case sensitivity in AA.Delete() - solved, ParseJso
Yep, it's a feature necessitated by JSON being case-sensitive itself. If regular case-insensitive AAs were returned, that will risk "folding" multiple elements into one, like say for "{a: 97, A: 65}". So the parser creates all its AAs case-sensitive

Komag
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2015
01:27 PM
Re: BUG - case sensitivity in AA.Delete() - solved, ParseJso
Got it. I have no experience with Json (not a programmer), but that makes sense.
BTW, I was ECSTATIC to discover FormatJson() and ParseJson(), makes my life 100 times easier than saving and loading a zillion bits of data into individual registry entries! 8-)
BTW, I was ECSTATIC to discover FormatJson() and ParseJson(), makes my life 100 times easier than saving and loading a zillion bits of data into individual registry entries! 8-)