Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: maze on August 11, 2008, 10:48:48 AM

Title: character limitation
Post by: maze on August 11, 2008, 10:48:48 AM
Hi Guy's,

I have a static in a window. In this static I load different text from variables. Some of the text is too long, so I want to limit the number of characters that's been shown in the static.
I know that variable.Length show me the number of characters, but I don't know how to limit the number of characters.
Is there anyone out, who could give me the right idea?

It would be a nice feature in WindowEdit to limit the number of characters for statics and buttons, just like MaxLength attribute for editors, wouldn't it?

Thanks
Title: Re: character limitation
Post by: metamorphium on August 11, 2008, 11:22:34 AM
how about something like (untested) this?

Code: WME Script
  1. var MaxLength = 50;
  2. var q = new String(YourVariable);
  3. var q2 = q.Substr(0,MaxLength);
  4. YourStatic.Text = q2;
  5.  
Title: Re: character limitation
Post by: maze on August 11, 2008, 11:33:05 AM
Thanks for the quick reply, I'm going to check it out.
I think it brings me back on the way  ::rock
Title: Re: character limitation
Post by: maze on August 11, 2008, 11:40:22 AM
Thanks again, it's working pretty well