Skip to content

BBScript: BBScript 1: Variables & Logic

monopoisoner edited this page Jun 11, 2024 · 4 revisions

Variables & Logic

Variables can be created and assigned in BBScript, with their scope being limited to the post the script is defined in. Variables are expected to only contain alphabets (a-z or A-Z) or underscore (_) in their name, and are case-sensitive. BBScript has no dynamic variable naming, and expect all variables to be a literal without any starting/ending quotes. This means foo is the variable foo.

BBScript 1 has a unique resolution for undeclared variables, where if a literal being referenced is not an existing variable, it will be treated as string. For example, if foo is not yet defined, it will be treated as the string "foo".

To create a variable set operator is used. In the following snippet, the variable foo is assigned the value "bar".

set foo "bar"
print foo

At print, it will log the string "bar" into the console.


set Set

Sets a value to the variable name.

set varName value

varName : The name of the variable to set the value to or create. This should be single string or literal conforming to the restrictions of only alphabets or underscores (a-zA-Z_). : This can be a string or resolve to a string, but it is better for clarity to make this a literal.

value : The value to be assigned to the variable. This can be anything.


print

Prints the value of the arguments in the console. The console can be accessed by right clicking on the page, and clicking on the console tab.

print arg ...

arguments unlimited : The list of values to print to the console.


inc Increment

Increment the value of a variable. Operation is done inplace.

inc varName increment

varName : The variable to increment the value of. The variable must refer to a number value.

increment : Value at which varName is incremented. : If left empty, the variable will increment by 1.


dec Decrement

Decrement the value of a variable. Operation is done inplace.

dec varName decrement

varName : The variable to increment the value of. The variable must refer to a number value.

increment : Value at which varName is decremented. : If left empty, the variable will decrement by 1.

Clone this wiki locally