Wednesday, August 30, 2023

๐Ÿ“š Saving (all of) BASIC Anywhere Machine: It doesn't have to be clunky

With a traditionally installed BASIC implementation, that BASIC implementation is software installed on your computer.  And every BASIC program you create is in a file.

BASIC Anywhere Machine is a TiddlyWiki instance (specifically, an instance of TiddlyWiki 5.2.3).

Because it is a TiddlyWiki instance, everything that makes BASIC Anywhere Machine work, and every BASIC program you create in it, are all part of the one HTML file that is TiddlyWiki.

As you work on some project in TiddlyWiki, like any project with some other BASIC, it is a good idea to save what you are doing every once in a while (and when you are done!)

But your web browser's "file save" will not work correctly.  You have to use the TiddlyWiki save mechanism, which actually triggers the browser "download" functionality.  Your "save" is a download of a new version of BASIC Anywhere Machine (the one that exists in your browser window/tab) with whatever changes you've made since you opened it in your browser (your programs are now part of your instance of BASIC Anywhere Machine.)

So you download it for the first time (say after opening my hosted version of BAM) by pressing BAM's save button in the top-left(ish) corner and you save it to a USB thumbdrive.  Next time, you open your copy of BAM from the thumbdrive.

As you work away and decide to save, you press that save button and make a decision: overwrite the already existing file on your thumbdrive, or save it with a new name (there or somewhere else.)


The TiddlyWiki saving mechanism is a little bit clunky because it is always a download with a decision to make.

There are "helper tools" to make saving more like traditional software.

TiddlyWiki has various saving options for many operating systems and web browsers.  See this page and explore the options.  (Although all of these should work with BAM, you might want to compare with the same info circa BAM's version of TiddlyWiki.)

I will discuss here just the few I've used.

TiddlyDrive (no longer exists!)

My home being a Chromebooks only household, having everything on Google Drive is a natural fit.

The TiddlyDrive "Google Drive Add-On" did this to save: pressing the save button overwrote the file on Google Drive.  Nothing else to do.  Awesome.

However, the developer of TiddlyDrive stopped maintaining it last January, and it finally stopped working about a week ago.

Bummer.

TiddlyDesktop

That is quite awesome.  It is like a file manager for all of your TiddlyWiki instances (including any number of BAM instances).  Opening a TiddlyWiki instance via TiddlyDesktop, the save button then triggers TiddlyDesktop to automate replacement of the file.  Nothing else to do.  Awesome.

However, for me, it means having to load Linux to run TiddlyDesktop (the Linux version).  Everything runs just as well as things would run on any other computer, but I am so used to the blazing speed of my Chromebook, that I cannot stand any delays.

TiddlyHost

I really like this.  The experience is exactly like the one I had with Google Drive + TiddlyDrive add-on.

I've only been using this for about a week, but it feels excellent.  So much so that I've started monthly donations to support the service.  I highly recommend it if you have a good internet provider and service.

Other Options

For all other options, you'll have to investigate them yourself.  Try the options with a download of the latest version of TiddlyWiki.  If you need help getting a "saver" working with the latest version of TiddlyWiki, the TiddlyWiki community can definitely help.

Once you've got that figured out with the latest TiddlyWiki instance, get a hold of me, show me what needs to be done, and I'll help you get that working with BASIC Anywhere Machine via a Google Meet or something like that.


๐Ÿชฒ PSET: Fixed issue with "out-of-bounds" coordinates

Described above is the issue with PSET before today's new version of BAM.


First, a little technical overview about putting text/graphics on the screen.

Any PRINT/PSET/LINE/CIRCLE/etc. does not actually do anything to the running program's screen.

Print, PSET, CIRCLE, etc.: all statements that put things on the screen, they actually put related data (the colour of affected pixels) into a one-dimensional array, each cell representing a coordinate on the screen.

The goal of doing this?  Performance.  Refreshing the screen is time-consuming.  By only updating the array, screen refresh can be delayed until it makes sense.

Description of the issue

Let's imagine a screen four pixels wide by three pixels tall:


A 4X3 Screen

The related array for storing the colour of each pixel:


For every PSET(x,y), the colour value will go into the array's cell number that results from the formula: x + y * screen_width = x + (y * 4).  So say we want to set the pixel colour at screen position (3,1) to (say) yellow, that value would go into array cell 3 + 1 * 4 = 7 (so cell 7 in the array).

Say our program involves an animation (a flying "dot"), and our program thinks that the dot ought to go from screen position (3,1) to (4,1).  Screen position 4,1 would mean array cell 4 + 1 * 4 = 8.  But when the screen is refreshed, the value in cell 8 will be applied to screen coordinate (0,2).

In the new version of BAM, if any coordinate (x, or y, or both) is outside of the boundaries of the screen, then the PSET is completely aborted.  So PSET (4,1), with the screen example above, will not happen.


Monday, August 28, 2023

๐Ÿชฒ RGBAPSET: fixed issue causing BLUE to be ignored

 All because of a typo in a variable name.  Arg!

The statement was handling the red and green components of RGB colours just fine, but was completely ignoring the BLUE component.

That is now fixed in the latest version of BASIC Anywhere Machine.

Sunday, August 27, 2023

๐Ÿชฒ CIRCLE, LINE, PAINT: "default colour" issue fixed

Update 2023-08-28: The latest version of BASIC Anywhere Machine fixes the issue described below.

When we don't specify a colour for any of those three statements, the colour used ought to be the foreground colour specified with the COLOR statement.

If a foreground colour has not been specified with the COLOR statement, then the default foreground colour for the screen mode ought to be used.

Well until today, I never noticed that, regardless of foreground colour specified with the COLOR statement, the original wwwBASIC code always chooses the default foreground colour of the screen current screen mode when no colour is specified for any of CIRCLE, LINE, and PAINT.


In the screenshot above, the rectangle and both circles should be yellow, just like the text.

If you want to experience this first hand, try out your own tests in the current version of BAM.

I've got a fix for the problem which I'm testing.  I should have that rolled out in a new version of BAM sometime within the next couple of days.  If you want to try the fixed version: the development version of BAM.

Screenshot of the same program in the development version of BAM:







๐Ÿ†• RGBAPSET and ๐Ÿงผ Consecutive Commas

 Latest version of BASIC Anywhere Machine.


๐Ÿ†• RGBAPSET

The RGBAPSET graphics statement sets a pixel at a specified coordinate to a specified alpha-blending of the already colour at the coordinate with a specified colour. The alpha value (0-255) determines the transparency of the specified colour (0 is completely transparent, as in no change to the already existing colour, and 255 is completely opaque, as in the already existing colour is entirely replaced.


  • x%
  • y%
  • rgbColour&
    • A long integer
    • A value representing an rgb colour
  • alpha%b
    • A "byte" integer (i.e. value between 0 and 255)
    • 0 indicates 100% transparent, meaning the new colour will be 100% the already existing colour
    • 255 indicates 100% opaque, meaning the new colour will be 100% rgbColour&
    • any in-between value will indicate the weight of rgbColour& (the weight of the already existing colour will be 255 - alpha%b)


๐Ÿงผ Consecutive Commas

Previously, BAM programs would fail when a program had any consecutive commas, requiring the programmer to make sure to separate commas by one or more spaces.

Now, the pre-processor handles consecutive commas by automatically inserting a space between consecutive commas.

For example, the following statement would get mangled by the pre-processor (causing a program to fail):

CIRCLE (100,100), 25, 14,,,,F

The pre-processor would convert that statement to:

CIRCLE (100,100), 25, 14F

Bad BAM. Bad.

Today's version of BAM, during pre-processing, takes a statement like:

CIRCLE (100,100), 25, 14,,,,F

And convert it to:

CIRCLE (100,100), 25, 14, , , ,F


⚗ Testing: POLYGON macro and support library

This version of BASIC Anywhere Machine inclues the POLYGON macro (see related blog entry.) 

Please note that this is just for prototyping, and will eventually be removed from BAM once the equivalent statement is developed in an include library.



Friday, August 18, 2023

⚗ Testing: POLYGON macro and support library

This makes for a really interesting way to program in BASIC !!!

The "POLYGON" macro generates BASIC code to create a polygon.

Syntax:

<<POLYGON "point coordinates string" "colors string">>

point coordinates string: a string with each point coordinate in parentheses, x comma y, and each point coordinate separated from the next point coordinate by a dash.  So each coordinate looks like "(x,y)", and a point coordinate separated from the next point coordinate looks like "(x1,y1) - (x2,y2)"

๐Ÿ”นUPDATE 2023-08-19:

    • A point coordinate can be preceded by the STEP keyword, which indicates the next point coordinate is a relative position (relative to the previous point coordinate) 
    • The macro now knows how to ignore any and all spaces in the coordinates string
    • The macro also now knows how to ignore lack of any spaces in the coordinates string 

colors string: a string with the numbers (for the currently applied screen mode) for the border color and the fill color, those two numbers separated by a comma.  The string looks like: "border-color,fill-color"

๐Ÿ”นUPDATE 2023-08-21: 

    • fill color is optional; when omitted, the colors string would look like: "border-color" 

NOTE: the two POLYGON parameters must be wrapped in double-quotes, and the two parameters must be separated from each other by one or more spaces.

To use the POLYGON macro, a program must include the Polygon Macro Support library.  Your program can make use of all things declared in the library.

Remember that a macro generates code just before passing the program to the interpreter.

Links to the sample program below, but first how the test program appears in the BAM IDE (i.e. before the macro gets replaced by the generated BASIC code):

<<include "Polygon Macro Support">>
moving_x = 6
adj_x = 5
i = 0
DO
    CLS : b = INT(RND*15) + 1 : f = INT(RND*15) + 1
    
    <<POLYGON "(moving_x,10) - (500,100) - (550, 120) - (30,170)" "b,f">>

    CIRCLE ( (LeftMostX + LeftMostBuddyX) / 2 + IFF(LeftMostY>LeftMostBuddyY,1,-1) ,  (LeftMostY + LeftMostBuddyY) / 2 + 1 ),4,12

    IF moving_x > 634 OR moving_x < 6 THEN adj_x = - adj_x
    moving_x = moving_x + adj_x
    i = i + 1
    _DELAY 0.25
LOOP







Monday, August 7, 2023

๐Ÿ†• _MOUSEZONE function

Latest version of BASIC Anywhere Machine.

Test program:


Description:

The _MOUSEZONE function checks whether or not the mouse pointer is in the defined "zone", the area specified by the top-left corner coordinates, the width, and the height parameters.

Syntax




  • return value
    • -1 if TRUE (i.e. mouse pointer is in the defined area)
    • 0 if FALSE
  • x%
    • horizontal pixel position of the area's top-left corner
  • y%
    • vertical pixel position of the area's top-left corner
  • width% (optional)
    • the pixel width of the area
    • if not specified, then assumed to be 1
  • height% (optional)
    • the pixel width of the area
    • if not specified, then assumed to be 1
  • width% and height% must
    • both be specified
    • OR: both not be specified

About me and why creating BAM is wildly interesting to me

Prologue:

From "Administrator", some guy running a forum I have no interest in (because of him and how he is), some guy who seemingly relishes every opportunity to demean/berate/bully/attack me and the things I find interesting, he writes about me:

and main question is what he made...what ?

he use two open source projects packed it and B.A.M was born !

really this is developer ?
also he never made any program by himself in BAM from the ground
and tell us ...i made this example .
and so on and on...

Ouch.  Why he's attacking me behind my back when I've done nothing to him bewilders me something silly.  Self-confidence issues?  Who knows?  Me, that just gives me an idea about something to write about.

About Me

I'm a career (since 1995) software developer and systems analyst, now a self-employed consultant.  I'm an agile programming and documentation disciple, and I've been involved in all aspects of the software development life-cycle.

Working with Gupta Team Developer (aka Gupta SQLWindows) has been my bread and butter since 1995 and to this day.  Most of my experience is with Oracle back-end, but I'm also experienced with Gupta SQLBase back-ends.

I've also got heavy-duty experience using wikis as single-source information for documentation and all things software-development life-cycle, and as context-sensitive help engines. 

I'm at my happiest enhancing/supporting complex systems for government agencies (focused on project management related to new construction and major renovations, facilities management, contract management, tender management, financial administration, etc.), doing Gupta Team Developer programming.

At home, I enjoy hobby programming.  Being a "Chromebooks" only household, I find myself much happier living in a web browser than running traditional software.  TiddlyWiki "programming" is, to me, the most enjoyable and fascinating experience at home.

Enter BASIC Anywhere Machine

All that said, BASIC has always been the one tugging at my heartstrings.  Hence BASIC Anywhere Machine: I get to do a kind of programming that is ridiculously enjoyable, with the goal of helping to keep BASIC relevant today, and supporting that BASIC with software development life-cycle things we might not normally see with any programming language's IDE, let alone BASIC.

When you really look at BASIC Anywhere Machine, you'll see a TiddlyWiki instance that looks nothing like TiddlyWiki.  Other than using a TiddlyWiki Codemirror Plugin, all you see is my programming with what I call "TW Script" (TiddlyWiki widgets, transclusion, filtering, etc.), along with HTML and CSS.

The BASIC interpreter is wwwBASIC, which I've embedded in BAM and significantly enhanced.  All of those enhancements requiring javascript programming, and I heavily dislike javascript (I appreciate the awesome work done with it, and the awesome folk talented in it, but I cannot stand looking javascript in the eyeballs.)  I will suffer javascript, though, for the mission: BAM.

Busy enhancing/debugging BAM, I have only been able to write a few of my own BASIC programs in it.  Much of my BASIC programming has been getting other folk's BASIC programs working in BAM, in order to test and improve BASIC Anywhere Machine.  You'll find mostly ported and/or modded programs in my published programs, but you'll find some in there that are original programs by me.  (For every program, the source code is displayed under the console window.)


Oops, I've got to cut it short there.  Must make my lunch before getting back to work !

Saturday, August 5, 2023

๐Ÿ†• BAM "favicon" and BAM "logo and ๐ŸชฒFixed Issue with Character Editor

BAM Favicon and BAM logo

Added a "favicon" to BASIC Anywhere Machine to help identify the browser tab for BAM when there are many browser tabs in the web browser:


That favicon sort of matches the (tentative) BAM logo I created today:



Issue with the Character Editor fixed

When I added the Character Editor (see these release notes), I somehow managed to completely bork the BASIC code generated by the editor (code meant for copying from the editor and pasting into a program.)

See the before and after screenshots below, the first screenshot showing the broken version of the editor and the next screenshot showing the fixed version.  (The broken version was missing "+" to concatenate the strings, and the strings were including a bunch of spaces that should not have been there.)


Before (buggy version):


After (fixed version):



 

๐Ÿ–ฅ Saucer Zap

This program is a port and mod of a QBJS program by James D Jarvis (shared with the QB64PE community and discussed in this thread ). That pr...