Skip to main content
gamedev.net
🔒 Locked

array of strings

Started by except134 Mar 24, 2009 at 4:26 AM 9 replies 2.1k views
Original Post
except134
except134
Hello. How to make array of string in 2.15.2? In early versions it worked. string[] strarr={ "str1", "str2" }; dosen't work. file.script (1, 20) : Error : Initialization lists cannot be used with 'string'
WitchLord
WitchLord
That is strange, it should still be working. I'll investigate this.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
except134
except134
Also I try this:

string[] Vars;

void initvars()
{
Vars[0]="aaaa";
Vars[1]="bbbb";
}

and get this:

saveload.script (3, 1) : Info : Compiling void initvars()
saveload.script (5, 10) : Error : Can't implicitly convert from 'string@&' to 'uint8&'.
saveload.script (6, 10) : Error : Can't implicitly convert from 'string@&' to 'uint8&'.
Build failed
WitchLord
WitchLord
How have you registered the string type? Have you overloaded the string array type?



Array of strings initialized with initialization lists are part of the regression tests: tests/test_feature/source/test_array.cpp. So this should be still be working.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
except134
except134
After creating script engine and MessageCallback

RegisterScriptString(m_Engine);
RegisterScriptStringUtils(m_Engine);

also try

RegisterStdString(m_Engine);

and get some error.
WitchLord
WitchLord
Something is very strange here.

Could you give the test_feature a try, to see if that works? If it works then it must be something specific condition of your application that causes this problem in AngelScript.

Hmm, are you perhaps using the CScriptBuilder add-on? If so, the bug may be in that code, as it could be mistaking the [] for metadata strings.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
except134
except134
Many thanks. All has earned. The problem was just in ScriptBuilder. I have set AS_PROCESS_METADATA to 0 and all has earned. Once again thanks. :) Also excuse for my English, I use the translator. And many thanks for angelscript.
WitchLord
WitchLord
Thanks for confirming the location of the bug. I'll have the CScriptBuilder fixed for the next release.

However, if you do not use metadata I suggest you keep it turned off to avoid the extra overhead it causes during script building.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
except134
except134
I use ScriptBuilder for parsing #include only. May be better take ScriptLoader from sample "include" in version 2.9.1? I used this version for my scripts till today.
WitchLord
WitchLord
Either one will work for you. If the one from the 'include' sample does all that you need, then you may safely continue using that.

I plan on improving the CScriptBuilder for future releases, to make it more flexible while processing the #include directives. One thing that I have planned for it is to implement callbacks, so that the application can supply the included files in the way that is most appropriate to the application. It should also have an improved file path resolution, for when the application doesn't handle this itself.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
WitchLord
WitchLord
Fix is now available in the SVN.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.