? Cool Coding 101: OPTION STRICT ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Cool Coding 101: OPTION STRICT

What does OPTION STRICT do?

It sets a flag in the SB compiler that requires all variables to be declared (VAR A) before use. Many that use this also choose to use type suffixes, because those masochists just can't get enough of this stuff.

What does this even MEAN?

Well, this means that your awesome code should to go from this: 'Despacito Dating Sim, BETA!!! do not steal 'copyright me 2019-30239 X=100 Y=200 VEL=10.2 SPSET 0,4 WHILE DEAD==0 SPOFS 0,X,Y INC Y,VEL VEL=VEL*0.97 IF VEL<0.01 THEN DEAD=1 VSYNC WEND to this: 'Despacito Dating Sim, RELEASE!!! do not steal 'copyright me 2019-30239 OPTION STRICT VAR X%=100 VAR Y%=200 VAR VEL#=10.2 VAR DEAD% SPSET 0,4 WHILE DEAD%==0 SPOFS 0,X%,Y% INC Y%,VEL# VEL#=VEL#*0.97 IF VEL#<0.01 THEN DEAD%=1 VSYNC WEND

Wait, slow down. What's up with the #s and %s?

Geez, I told you this already. They're type suffixes. You've probably used one before, though you might not know it.
  1. $ is String, which is the one you've probably used a bunch of times already.
  2. % is Integer, which lets you store whole numbers like 0, 73948, -22, and -1.
  3. # is Float, or Real. This means you can have numbers with decimal points like 10.2, 3.333335, and -238.44, as well as any values that an Integer can hold!
  4. For more on types, visit Variable Types (Resource) by 12Me21

What happens when VEL# is added to Y%? Aren't they different types? What happens to the decimal part?

When you add a Float to an Integer (or do any operation between the two), the result becomes a Float. When you try to assign this Float value to an Integer variable (A%=4.2), the decimal part is completely removed (4).

Thanks.

You're welcome. :)
Author
auceps
Updated
Rating
2 votes
Categories
Keywords
  • option
  • strict
  • type
  • suffix
  • types
  • suffixes
  • float
  • floats
  • integer
  • integers
  • declaration
  • %
  • #
  • $
  • variable
  • variables
  • symbol
  • symbols
5 Comment(s) 12Me21 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself OPTION STRICT doesn't make type suffixes required... Also anyone who uses type suffixes on all their variables (and/or doesn't use OPTION DEFINT) is not a REAL PROGRAMMER auceps auceps feelsbad Yttria Yttria Head Admin >and have a type identifier symbol appended to the end of every variable name. wrong. also, "identifier" is a bad term for type suffixes (even though the manual might use it) because it has another meaning in syntax of 'any non-reserved word.' When referring to the character itself, use "suffix," when referring to the type... use "type" (looking at "$ is String, the identifier") auceps auceps nooooo not like this EDIT: im upset i thought i had it all together (edit2, thanks, i was trying to figure out words in my head and couldn't find antonym of prefix again) 12Me21 12Me21 Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself antiprefix