While

From GMWiki, the Gamemaker Wiki.

Jump to: navigation, search

The while command is a very useful tool to master in Game Maker. It continues executing the code between the brackets if the expression is true. Eg.

file=file_text_open_read("file.txt")
while(!file_text_eof(file))
{
   file_text_readln(file)
}

This code will read til it comes to the end of the file.

Be careful though! It's easy to create an infinite loop.

while(1=1)
{
   argument0+=1
}

This will result in game getting stuck and the user needs to quit it using Ctrl+Alt+Delete.

Retrieved from "http://gmwiki.org/While"
Personal tools