Page 1 of 1

Strings

Posted: Mon Oct 22, 2012 10:10 am
by enric
We can make a call to a function like:

myFunction (4, "Sherman", 23);

So the function receives a string as the second parameter.

Function myFunction (x, type, y)

So type contain a string and:
if( IsUnitType(id, type) == 1)
seems to work.

BUT, we can not define

Type = "Sherman";

Is there a way to deal with strings?

Re: Strings

Posted: Mon Oct 22, 2012 3:14 pm
by pipfromslitherine
If you want strings to use in that way you need to build them using the work string functions. There is no intinsic string type in the scripting - it's on my list as it would be very useful, but not done.

So for now, it's via StartWorkString etc.

Cheers

Pip

Re: Strings

Posted: Mon Oct 22, 2012 4:27 pm
by enric
Can you, please, put an example of
StartWorkString([index]);

This don't work

Width = GetMapWidth();
StartWorkString();
PrintWorkStringInt(Width);
ShowTextMarker(1, 43, 16, GetWorkString();, 6, "FFFFFF", 1);

Re: Strings

Posted: Mon Oct 22, 2012 6:07 pm
by pipfromslitherine
ShowTextMarker also requires an IDS_ type defined string, not a generic string. Also, the Work string is a char string (that is, non-unicode) which is what is used for the function string parameters, whereas the StartString() type strings are unicode strings which are actually used for showing things (so for the DrawScenarioUI function RenderString you use StartString not StartWorkString functions).

To put it another way, use StartString for something you are going to show, and StartWorkString for something the system is going to use (like a filename, a unit type, etc).

Cheers

Pip