Tuesday, January 31, 2023

📚 Working on documentation related to "Data"

Documentation.

Rarely something that folk get excited about creating/maintaining.

Although I'm not particularly good at it, I really enjoy creating/maintaining documentation.  There's just something about the challenge of the task (and is it ever a challenge!) that reels me in.

If it is something you enjoy and you are up to "testing" and/or giving feedback of any kind...

Still very early-going, I'm on an iterative and incremental journey of cycling through these topics:

Sunday, January 29, 2023

🆕 %b Data Type Suffix for BYTE Data Type

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)



Saturday, January 28, 2023

🆕 STRUCT, STRUCTURE, and RECORD (alternative keywords for TYPE)

"Out of the box" wwwBASIC implements the "TYPE" keyword as found in QBasic and QB64/QB64pe.

This is really handy for creating complex "composite" data types, which gather any number of variables (with whatever data types) all under one data type name.

For example:

TYPE player

   name as string

   batting_avg as double

end TYPE


dim as player pitcher


pitcher.name = "Johnny"

pitcher.batting_avg = 97.8


print pitcher.name, pitcher.batting_avg


But the keyword "TYPE" semantically annoys me.

After juggling the synonyms that  we find in various programming languages (TYPE, RECORD, STRUCTURE, STRUCT), not entirely satisfied with any of them, I decided: the heck with it, I'm setting them all up.

You decide which you prefer, based on your pros/cons/preferences:

  • TYPE - END TYPE (like QBasic, QB64, QB64pe, ...)
  • RECORD - END RECORD (like Pascal, ...)
  • STRUCTURE - END STRUCTURE (like PureBasic ...)
  • STRUCT - END STRUCT (like C, C++ ...)





Friday, January 27, 2023

🆕 New Release of BASIC Anywhere Machine

View release notes for details.

Added the PALETTE statement and added supporting functions _BGR() and _RGB2BGR

Significant changes to screen modes, and breaking the limits of the WIDTH statement.

Enabled "negative" index numbers for colour attributes.


Because this release involved substantial changes to the interpreter, I archived the previous version of BASIC Anywhere Machine:  Version 5.2.3_2023.01.14

Tuesday, January 17, 2023

A few things I'm working on.

The PALETTE statement.

The "PALETTE [attribute,color]" syntax as per https://hwiegman.home.xs4all.nl/gw-man/PALETTE.html.


A _RGB2BGR function.

The palette expects a colour specified as Blue Green Red.  Because I like to specify colours in Red Green Blue, I want a function that will take my RGB colour and convert it to BGR for me when I use the PALETTE statement.


Change to screen mode 13.

At the moment and as per "out of the box" wwwBASIC, screen mode 13 has the "undefined" colour scheme (it has no colours 0,1,2,3 ...), so rgb colours must be specified whenever some colour is needed.

I'd like to change screen mode 13 to use a "P256" colour scheme.  The scheme will allow defining via PALETTE any RGB colour to each of the 256 attributes (i.e. colors 0 - 255).

The default palette for P256 will only have the first 64 colours defined, matching EGA colours as per this EGA Colour Table


What do you think ?




Saturday, January 14, 2023

❇ _ALERT

When clicking the "OK" button in an alert box, this would leave the BASIC program thinking the mouse button was still pressed.

In today's new version of BASIC Anywhere Machine, the "mouse button is pressed" tracker gets reset to "nah, the button is not pressed" after the close of an alert box.


Monday, January 2, 2023

🪲 GET (graphics)

 GET seemed to be really confused when processing the color black, half of the time thinking black is blue.

That was pretty funky, but is now fixed.


To test, I created the program Funky-Textured Turning Cylinder.

Sunday, January 1, 2023

🆕 PLOT and UNPLOT

PLOT is an alternative keyword for PSET, and UNPLOT is an alternative keyword for PRESET.

The syntax for PLOT is the same as the syntax for PSET, and the syntax for UNPLOT is the same as the syntax for PRESET.

🆕 _SNDFADE

Latest versions of BASIC Anywhere Machine and the Programming Reference.

Hear the impact, and see the use of, _SNDFADE in the Amazing Grace sample program (scroll down to see the source code below the program's console window).

🖥 Oriental Paintbrush Sim

This is a port and mod of a QBJS program ("Calligraphy Pro 128 Studio:  Oriental paintbrush mode") by Vince. Click/touch the canva...