Pages: 1
  Print  
Author Topic: So much for variable type declarations  (Read 2192 times)
Offline (Unknown gender) Darkstar2
Posted on: June 26, 2014, 11:46:43 pm
Member
Joined: Jan 2014
Posts: 1238

View Profile Email
string a;
in create event
1 Objects:
 obj_0: 12 events:
  Event[0]:   Parsing 1 sub-events:
Check `obj_0::create...Syntax error in object `obj_0', Create event:0:
Line 1, position 1 (absolute 0): Unterminated brace at this point

How the hell am I supposed to declare string variables in ENIGMA ?

I can only do int, double, long, float ,char,
but no string !?!?!?!?

« Last Edit: June 26, 2014, 11:56:21 pm by Darkstar2 » Logged
Offline (Male) Goombert
Reply #1 Posted on: June 27, 2014, 12:25:16 am

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2993

View Profile
String is part of the standard template library, ENIGMA's current compiler can not parse that or templates, thus why we need our new compiler, codename JDI aka JustDefineIt. Which will complete the EDL spec.
https://github.com/JoshDreamland/JustDefineIt
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) Darkstar2
Reply #2 Posted on: June 27, 2014, 01:02:08 am
Member
Joined: Jan 2014
Posts: 1238

View Profile Email
So how do I define a string in my enigma project then?
Logged
Offline (Unknown gender) egofree
Reply #3 Posted on: June 27, 2014, 01:40:05 am
Contributor
Joined: Jun 2013
Posts: 601

View Profile Email
So how do I define a string in my enigma project then?

What about using 'var' variables ?
Logged
Offline (Unknown gender) Darkstar2
Reply #4 Posted on: June 27, 2014, 02:01:59 am
Member
Joined: Jan 2014
Posts: 1238

View Profile Email
I remember reading that it is bad practice to use var inside ENIGMA.

Logged
Offline (Unknown gender) egofree
Reply #5 Posted on: June 27, 2014, 02:30:00 am
Contributor
Joined: Jun 2013
Posts: 601

View Profile Email
I remember reading that it is bad practice to use var inside ENIGMA.

Where ? :D In this case, forget also using arrays in Enigma !  ;D
Logged
Offline (Male) Goombert
Reply #6 Posted on: June 27, 2014, 04:17:19 am

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2993

View Profile
var is bad anyway because it just overloads types, Studio probably does the same shit, and no matter which engine or programming language you use a variant data type is horrible, it's for people who don't know data types

With that in mind, var overloads std::string, but the problem you are having is that string(); is a function in GM, thus why it is telling you about the missing brackets. You can't use std::string either because our compiler blocks you from using that namespace until JDI can handle parsing all of STL.

Quote from: JDI
Line 1, position 5 (absolute 4): Cannot handle :: with current parser configuration. Oops.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #7 Posted on: June 27, 2014, 05:04:24 am

Developer
Joined: Apr 2008
Posts: 1860

View Profile
Yeah, you can use "var" just fine. It's just that it is slower, because it's Jack Of All Trades kind of type.

Also, the error is because "string" is a function in GM and in turn ENIGMA - 'draw_text(10,10,"Lives = "+string(lives)")'. So it probably never will work, because I don't know if you can use function name as a type name. Especially when using a type as a function, like int(5.4)==5, is already defined in C++ spec. So it's possible you will never be able to use "string" as a type name. Or we will have to rename the function, because in most languages it is called something like "toString" instead of "string". But that will break GM compatibility once more.
Logged
Pages: 1
  Print