5,391
edits
m (added some stuff; more, later) |
m (added introduction) |
||
Line 1: | Line 1: | ||
'''Variables''' in BSL are very similar to variables in other programming languages. Here's a brief explanation of what a variable is: | |||
When writing logical programs, one often needs the program to remember some information (a number, a piece of text, the ON/OFF state of a switch, etc) so that the information can be used at a later time. | |||
The usual thing to do in this situation is to store the needed data in a '''variable''': an elementary data container. | |||
==Type and value== | |||
A variable has two important attributes: the ''type'' and the ''value''. The value or the variable is just the contents it currently stores. It can be read and written. | |||
Also, a given variable can store only a specific type of data (floating-point number or integer or text string or boolean), and that is what we call the variable's type. | |||
An easy way to get the type and value of an existing BSL variable is to enter its name at the console in [[Developer Mode]]: you typically get console output like "bool: 1" or "int32: 42" or "float: 3.14" or "string: hello" | |||
==Declaration== | ==Declaration== | ||
Put usage of '''var''' here. Link to [[OSL:data|OSL data types]] | Put usage of '''var''' here. Link to [[OSL:data|OSL data types]] |