Wednesday, May 29, 2024

🖥 Twelve Trigeod Wheel

This BAM program inspired by Richard Russell's BBC BASIC program shared on Facebook with the BASIC Programming Language group (link.)

I wanted to recreate Richard Russell's image using DRAW statements as part of my long process of testing enhancements to DRAW that are still at the development level (I..e. not ready for a new BAM release.)




Sunday, May 26, 2024

🖥 Twisted Squircle

I wrote this program to test a change to the TA command in BAM's DRAW statement:

When I originally added the TA command in BAM, I had set it up so that the drawing angle was reset to zero before every DRAW command.  Every TA angle was local to the DRAW statement using TA.

That did not match GW-BASIC's TA behaviour.

In GW-BASIC, a new value for TA is retained (globally), such that when an angle is specified with a TA command in a draw statement, that angle will apply to every subsequent DRAW statement until some later DRAW statement specified a new angle via TA.

In the current development version of BAM (and in future production versions), BAM's TA command in the DRAW statement will behave as described above for GW-BASIC.

BTW, this program currently only works in the development version of BAM.  Not just for the TA behaviour described above, but also because of the following enhancement to TA still only found in the development version of BAM: TA allows floating point numbers as well as integers.






















 

Monday, May 20, 2024

🖥 Filho Curvy Graph

This is a port and mod of a BASIC program by Filho Junior.

No surprise, I've animated the drawing of the graph and put that process in an endless loop, with a 2 second-ish delay between graphs.  Although the original program was graphing with random colours, I've modified that so that the graph is limited to a random choice of five colours (duplicates allowed) from the 15 colour palette (excluding the first color, I.e. black).  The graphing itself still picks random colours, but only from the five choices.

Whatever lines I've modified, I've preceded those lines with the commented out original lines.  Whatever new code I've added, I've not numbered those lines.





Saturday, May 18, 2024

🚧 Next version of BAM in the works: improvements to DRAW

The following code sample and screenshots describe the impact of enhancements to DRAW:

SCREEN _NEWIMAGE(41,41,17)

DIM A$(1 TO 10) = {"U","E","R","F","D","G","L","H"}

FOR A% = 0 TO 360
  DRAW "B M 20,20"
  DRAW "TA" + A% + "B U18"
  PSET (POINT(0),POINT(1)),62
NEXT I%

FOR I% = 1 TO 8
  DRAW "B M 20,20"
  DRAW A$(I%) + "17"
NEXT I%

CIRCLE (20,20),20,60

(Try the code above, or your own code, in the current "production" and "development" versions of BAM.)


Results in the current "production" version of BAM:



Results in the "development" version of BAM:



🖥 McGavin GW-BASIC Flower Tessellation

Peter McGavin shared a GW-BASIC port of Richard Russell's BBC BASIC "flower tessellation" program.

The GW-BASIC program works as-is in BAM, which makes me pretty happy because I've made BAM compatibility with GW-BASIC a high-priority goal.

I appreciate finding small GW-BASIC gems like Peter's program so that I can test how well I'm doing with this wee goal of mine.

Do note, I made one change to the program (line 10).  I changed the screen mode from 9 to 12 (using custom screen dimensions), 




Friday, May 17, 2024

🖥 Flower Tesselation: Testing DRAW and recursive SUB's

This BAM program inspired by Richard Russell's "Flower-like tesselation" BBC BASIC program posted on Facebook.

Created in order to test enhancements to "DRAW" in the development version of BASIC Anywhere Machine.

I did not get fancy with this, keeping the program low resolution to better see the flaws when using DRAW with angles other than any that are a factor of 45 degrees.

As my usual practice, the program runs in an endless loop of animation, and applies randomness to colours and to the drawing angle.



























Tuesday, May 7, 2024

🖥 Auto Biaxial Symmetry Graphing Personalizer

A little over a year ago, I created a an "Auto Biaxial Summetry" graphing program:
I so enjoyed sitting back and watching the animated graphing that I thought: hmm, it would be cool to easily adjust the settings for the program via a simple GUI.

So I put my RAD (Rapid Application Development) hat on, grabbed an empty TiddlyWiki instance, and quickly put together the "Auto Biaxial Symmetry Graphing Personalizer".

This TiddlyWiki lets you run the program, see how it looks, and adjust various settings to get various results from what is really a fairly simple drawing algorithm.

If and when you like what you see, you can export the personalized program to a small HTML file that has everything needed to run your version of the program without ever needing to write/edit any of the BASIC code.  Store that HTML file wherever you like for access via your online web browser, or wherever you like for your offline web browser.


A few sample images:























Monday, May 6, 2024

🖥 Animated Recursion Demo

A little program to demonstrate a recursive subroutine.

It also demonstrated the use of DRAW with the TA (angle) command to help draw the outline "dotted" circles by positioning the pen to draw those points (using CIRCLE to create some thick points, because PSET pixels aren't quite visible enough for these aging eyeballs.

To make things interesting, the drawing is animated and uses a new random colour for each recursion (in the hopes "seeing" what the code is doing.

The program runs in an endless loop, retracing the previous drawing with new random colours..




Friday, May 3, 2024

📚 FUNCTION (and SUB): variable arguments, by default, are "passed by reference"

  • Preamble
  • A primer on "call-by-reference" vs "call-by-value"
  • BAM HOWTO
(BTW:  "call-by-reference" aka "pass-by-reference", and "call-by-value" aka "pass-by-value".)

Preamble

I started working on BASIC Anywhere Machine back in December 2020 with the version of wwwBASIC I found back then.

Although I've been modifying the copy of wwwBASIC embedded in BAM right from the start, I've never noticed the following until just a few days ago:

In function and subroutine calls,  
a variable as an argument
is always "called by reference"
and never "called by value".

Being a career Gupta Team Developer (aka Gupta SQL windows) programmer, I am accustomed to variables always being "called by value" unless explicitly flagged as being "called by reference".  So I immediately thought that the wwwBASIC code was misbehaving, and I started digging into the code to "fix" things.

Well, come to find out: wwwBASIC's behaviour matches QB64's behaviour (the same for, I imagine, QBASIC), and I'm thinking wwwBASIC contributors did that by design.

Personally, I'd like for BAM to behave (regarding function/sub arguments) in the same way as Gupta Team Developer.  However, compatibility with QB64 / QBASIC is much to important to me (pretty much as important as GW-BASIC compatibility.

A primer on "pass-by-reference" vs "pass-by-value"

(From Wikipedia)

Call by reference (or pass by reference) is an evaluation strategy where a parameter is bound to an implicit reference to the variable used as argument, rather than a copy of its value. This typically means that the function can modify (i.e., assign to) the variable used as argument—something that will be seen by its caller.

In call by value (or pass by value), the evaluated value of the argument expression is bound to the corresponding variable in the function (frequently by copying the value into a new memory region). If the function or procedure is able to assign values to its parameters, only its local variable is assigned—that is, anything passed into a function call is unchanged in the caller's scope when the function returns.

 

BAM HOWTO

Call by reference

Copy, paste, and run the following program in BASIC Anywhere Machine:

DIM a$ = "Howdy"

FUNCTION hello$( p$ )
  p$ = p$ + " there"
  hello$ = p$
END FUNCTION

PRINT "a$: " + a$
PRINT "result of hello$( a$ ): " + hello$( a$ )
PRINT "a$: " + a$

When run, you'll find that the value of a$ has been altered by the function:






Call by value

In BAM, the same as in QB64 Phoenix Edition:  To pass parameter variables by value (in order to protect the value in the variable used in the call), wrap the parameter variable in parentheses to turn the parameter into an expression.

Copy, paste, and run the following program in BASIC Anywhere Machine:

DIM a$ = "Howdy"

FUNCTION hello$( p$ )
  p$ = p$ + " there"
  hello$ = p$
END FUNCTION

PRINT "a$: " + a$
PRINT "result of hello$( a$ ): " + hello$( ( a$ ) )
PRINT "a$: " + a$

When run, you'll find that the value of a$ has NOT been altered by the function:














🖥 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...