Although out-of-the-box wwwBASIC has the BYTE data type, it does not have a handy suffix to:
- make BYTE constants and functions (impossible to create these constants and functions without the suffix)
- use shorthand notation for declaring variables, for declaring variables in composite types (i.e. STRUCT aka TYPE aka RECORD aka STRUCTURE), and for declaring arrays
I'm still working on documentation. In the meantime, here's is some of the documentation I have gotten together so far, followed by a screenshot of sample program to test the BYTE datatype, keyword, and suffix.
The BYTE Data Type:
unsigned 8-bit (1-byte) integers that range in value from 0 through 255
The BYTE Keyword
The BYTE keyword can be used to identify the following as storing and returning values of the BYTE Data Type:
- define the data type of variables declared with the DIM statement
- define the data type of variables in composite data types
- define the data types of arrays
The BYTE Data Type Suffix
The %b datatype suffix on the name of a programming entity indicates that the entity is meant to store and/or return values of the BYTE Data Type.
The datatype suffix is a "sigil" that can be used on the names of programming entities: variable, constants, and functions.
Test BYTE Data Types (screenshot further below)
screen 26
' TEST BYTE DATA TYPE
CONST RED%b = 255
CONST GREEN%b = 258
PRINT "Red (255): " + RED%b
PRINT "Green (258): " + GREEN%b
FUNCTION MakeString$(c$, c%b)
MakeString$ = c$ + " (" + c%b + "): " + c%b
END FUNCTION
DIM AS BYTE Blue%b
Blue%b = -10 : PRINT MakeString$("Blue", Blue%b)
Blue%b = 254 : PRINT MakeString$("Blue", Blue%b)
Blue%b = 258 : PRINT MakeString$("Blue", Blue%b)
DIM AS BYTE Blue
Blue = -10 : PRINT MakeString$("Blue", Blue)
Blue = 254 : PRINT MakeString$("Blue", Blue)
Blue = 258 : PRINT MakeString$("Blue", Blue)
PRINT MakeString$("???", 258)
STRUCT color_def
red as BYTE
green as BYTE
blue%b
END STRUCT
dim as color_def tiny_circle
tiny_circle.red = 150
tiny_circle.green = 50
tiny_circle.blue%b = 455
circle (100, 240), 50, _rgb(tiny_circle.red, tiny_circle.green, tiny_circle.blue%b)
circle (100, 240), 80, _rgb(150, 50, 200)