SOLVED what does ";" means in GML?

anima

Member
ok so ive been seeing some ";" in codes but never got interessed enough to ask what does it mean.
uh help?
 

jobjorgos

Member
GML:
var name1 = "John";
var name2 = "Joyce";
OR you can do
GML:
var name1 = "John",
name2 = "Joyce";

but 99% of the time ; does nothing in GML
 

kburkhart84

Firehammer Games
It signals the end of a code statement. It isn't technically required in GML but best practice is to include it for readability.

It can also signal things like the parts of for() statements, where the first part is the variable to use, 2nd part is the condition, 3rd part is the change. In this case, the semi-colon is NOT optional.

There may be another usage but I can't remember off the top of my head.
 

Mert

Member
Nothing! (In almost all cases)

Explaining in easy terms
Almost all languages want you to end your line with semicolon( ; )
Here's an example Java code
Java:
doThisFunction(); //Works
doThisFunction() //Gives error becuase I didn't finish the function with semicolon
This tradition was then carried to Game Maker. Eventually, GM got rid of the semicolon , but they couldn't remove this from the engine due to backwards compability. (Looks like GM never required semicolons). Now, it's just there for cosmetic reasons. You can use semicolon or not, doesn't really matter. The only exception would be "for" statements where you must divide the conditions.

GML:
for (var i = 0; i < condition; ++i) {
    // code here
}
 
Last edited:
This tradition was then carried to Game Maker. Eventually, GM got rid of the semicolon, but they couldn't remove this from the engine due to backwards compability. Now, it's just there for cosmetic reasons. You can use semicolon or not, doesn't really matter. The only exception would be "for" statements where you must divide the conditions.
A slight correction in that GM never required semicolons. If anything, recent versions are even more strict with semicolon usage; downright mandatory if you plan on using YYC.
 

FoxyOfJungle

Kazan Games
An important tip too: If you are going to use shaders someday, the Open GL language requires you to obligatorily put the ";" (semicolon) in the proper places mentioned above, if not, it will cause a compile error.
 
Top