Internal error - decl not semanted
Monkey Forums/Monkey Programming/Internal error - decl not semanted
| ||
What does this error message mean, and how do I fix it? Here's where it occurs: [monkeycode] currPattern[Current_Pattern - 4] += String(t.bttnID) [/monkeycode] |
| ||
Hi, c.k.! Using this works: [monkeycode] currPattern[Current_Pattern - 4] = currPattern[Current_Pattern - 4] + String(t.bttnID) [/monkeycode] I wonder why. |
| ||
It looks like a compiler bug to me. If you can't use the += operator on array items, it should at last provide a proper compiler error |
| ||
Before I turned currPattern into an array, it worked fine. [monkeycode] Field currPattern:String = "" currPattern += t.bttnID [/monkeycode] |
| ||
I've placed a bug report here: http://www.monkeycoder.co.nz/Community/posts.php?topic=4767 |
| ||
edit: never mind this post, I didn't realize it was an array of strings and ones again rushed a reply. strings are immutable, indexing string as array returns integer, string[index] is a read only property. use ToChars() and FromChars() if you would like to manipulate strings as integer array. ziggy is correct in that it should throw a compiler error. Function Main() Local s$ = "hi" s[0] = "H" ' throws compile error End |
| ||
The example isn't attempting to manipulate a string via an array index. It's replacing a string stored at an index in an array of strings. |
| ||
edit: oops, I see what you mean muddy - it's an array of strings... muddy_shoes, please elaborate - I'm under the impression that immutable strings are arrays of integers and by indexing a string we can read the ascii value of that array. |
| ||
@Dima: ...I'm under the impression that immutable strings are arrays of integers... Strings are implemented by the host language in whatever native format it expects. They are not arrays of integers (not in Monkey-speak, anyway). |
| ||
It's appending to a string found inside an array. Oddly enough, this is basically what I (thought I) was doing: [monkeycode] Function Main() Local my:String[] =["", ""] For Local t:Int = 0 Until 5 Print t my[1 - 1] += t Next Print my[0] For Local t:Int = 0 Until 5 Print t my[1 - 0] += t Next Print my[1] End Function [/monkeycode] But that works fine (apparently)! Hmmmmm... |
| ||
As I explained here, it's fine with constant values. "1-1" and "1-0" are automatically converted to "0" and "1" respectively by the compiler, so they're technically still constants. |
| ||
Ah, OK. Thanks, Samah. |