BSL:Manual: Difference between revisions

202 bytes added ,  6 December 2015
→‎Data types: mentioning automatic initialization
m (→‎string: wording)
(→‎Data types: mentioning automatic initialization)
Line 291: Line 291:


==Data types==
==Data types==
When declaring a variable or a function (more on this under the [[#Functions|Functions]] and [[#Variables|Variables]] sections), you must specify the type of data it contains, accepts, or returns:
When declaring a variable or a function (more on this under the [[#Functions|Functions]] and [[#Variables|Variables]] sections), you must specify the type of data it contains, accepts, or returns. You can choose from "bool" (can be true/false), "int" (can be any whole number), "float" (a value with a decimal point), or "string" (some text).


  var int x;
  var '''int''' x;
  func int my_func(void)
var '''bool''' happy_bomber = true;
  func '''string''' my_func(void)
{
    ...
}


You can choose from "bool" (can be true/false), "int" (can be any whole number), "float" (a value with a decimal point), or "string" (some text).
Upon declaration, variables are automatically initialized to zero if no value is assigned explicitly, as in the above example with "x".


===void===
===void===