FAQ  •  Register  •  Login

DIM x as String = ?

<<

LTee

Posts: 153

Joined: Tue Jul 07, 2009 2:54 pm

Post Thu Apr 07, 2011 12:36 pm

DIM x as String = ?

Hi everyone!

Should this work?

  Code:
DIM x as String = "test"


I get the following error when I try to compile:
  Code:
Initializer expression is not constant.


Doing this instead is fine:
  Code:
DIM x as String: x = "test"


I'm using the latest 1.2.8s696, by the way.
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Thu Apr 07, 2011 2:29 pm

Re: DIM x as String = ?

LTee wrote:Hi everyone!

Should this work?

  Code:
DIM x as String = "test"


I get the following error when I try to compile:
  Code:
Initializer expression is not constant.


Doing this instead is fine:
  Code:
DIM x as String: x = "test"


I'm using the latest 1.2.8s696, by the way.

This has already been answered. Strings are a different data type (Dynamic) and cannot be statically initialized (yet). But since many (ahem :roll:) users are asking for it, I will include this syntax in future releases (if it can be done; it's completely different to initialize a string than an scalar variable).
<<

LTee

Posts: 153

Joined: Tue Jul 07, 2009 2:54 pm

Post Thu Apr 07, 2011 8:51 pm

Re: DIM x as String = ?

Whoops, sorry! :-)

It would be a nice shortcut, but I don't think it's serious enough to spend too much time on if it turns out to be difficult to achieve. No doubt the list of things to add is pretty long already!

This latest beta is working very nicely for me, by the way - I've done quite a lot of work on my game in the last week or so with no problems whatsoever. Just thought you might like to know that, a little positive encouragement rather than my usual questions. ;-)
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Fri Apr 08, 2011 6:31 am

Re: DIM x as String = ?

Well, I'll move this thread to whislist.

Return to Wishlist

Who is online

Users browsing this forum: No registered users and 0 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO