Android: Resize for array of strings not working
Monkey Forums/Monkey Bug Reports/Android: Resize for array of strings not working
| ||
Hi If you create array of strings like that: Field str:String[5] and then try to resize it like that: str.Resize(10) It gives you errors during compiling like below. Doesn't work in my game nor in Angelfont example (str.Resize(10) put in oncreate) compile: [javac] C:\Program Files\Android\android-sdk\tools\ant\main_rules.xml:384: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 2 source files to C:\anawiki\MonkeyPro42b\bananas\beaker\angelfont_example\angelfont_example.build\android\bin\classes [javac] C:\anawiki\MonkeyPro42b\bananas\beaker\angelfont_example\angelfont_example.build\android\src\com\monkey\MonkeyGame.java:1453: not a statement [javac] ((String[])bb_std_lang.resizeArray(bb_str,10)); |
| ||
Hi, You're meant to use resize like this: str=str.Resize(10) ...but yes, the above shouldn't happen and will be fixed. |
| ||
Mark - when you close a bug that is a duplicate could you please post a link with the original post... I know I should have search in the first place ;) |
| ||
Mark Sibly: Hi, You're meant to use resize like this: str=str.Resize(10) ...but yes, the above shouldn't happen and will be fixed. Bye! Mark Hasn't been fixed in v71c |
| ||
This bug is still current in Monkey Pro 77f and I have no idea how to get around it :-(...If Bacterias.Length() > 4 Then Bacterias.Resize(4) Throws this: monkeygame\MonkeyGame.java:2826: error: not a statement [javac] (c_Bacteria[])bb_std_lang.resize(m_Bacterias,4,c_Bacteria.class); BUILD FAILED C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:720: The following error occurred while executing this line: C:\Program Files (x86)\Android\android-sdk\tools\ant\build.xml:734: Compile failed; see the compiler error output for details. PS: I found the solution to this in another topic from Samah (kudos). Correct way to resize the array: If Bacterias.Length() > 4 Then Bacterias = Bacterias.Resize(4) Way to bypass the compiling error in older versions of monkey: If Bacterias.Length() > 4 Then Self.Bacterias = Self.Bacterias.Resize(4) So I guess this has been fixed because Array = Array.Resize(x) seems to work. Sorry for opening this again. |
| ||
Bacterias = Bacterias.Resize(4) Resize does not resize the array, it makes a copy that is a new size. Admittedly, the method name is misleading. |