LoginLogin
Might make SBS readonly: thread

OPTION commands

Root / Submissions / [.]

TheV360Created:
OPTIONs are small commands that change how SmileBASIC reads your code. There are two options in SmileBASIC 3.3.2: STRICT and DEFINT.

Syntax

OPTION [option type]
really complex, i know

Option types

STRICT

OPTION STRICT is an option that forces you to define variables before using them. This helps prevent bugs that come from typos in your code. To define the variables, either use the DIM or VAR command. They both do the same thing. Here's an example of OPTION STRICT's use:
'Without OPTION STRICT
COINS=5
X=0:Y=0
VAR MAP[5,5]
PRINT "Coins: ";COIN 'Prints 0 because of typo
'With OPTION STRICT
OPTION STRICT
VAR COINS=5
VAR X,Y
VAR MAP[5,5]
PRINT "Coins: ";COIN 'Error! Undefined variable

DEFINT

OPTION DEFINT, meaning DEFault INTeger, is an option that sets the default variable type to integer. Normally, the default variable type is real, which allows variables to be set to numbers like 1.5, 3.141592, and NaN as well as whole numbers. However, integers can only store whole numbers. If, while using this, you want to use real numbers, put # on to the end of your variable name, like so:
REAL#=1.5
If you want to use integers without using DEFINT, just do the same thing I said in the code box, but replace the # with %.

Legacy option type

There used to be a rule in SmileBASIC that said only programs with OPTION TOOL could be used as tool programs. However, that restriction has been removed, making the option type useless. It still can be put in programs without any errors, however.

Sources

About halfway through writing this, I realized I was sorta subconsciously plagiarizing a few forum posts about OPTIONs. FAQs - OPTIONs FAQs - OPTION TOOL?

No posts yet (will you be the first?)