Wednesday, July 2, 2025

🖥 Digital Clock

This program is a port and mod of Antoni Gual Via's program shared with the "BASIC, QBasic, GWBasic computer programming"' Facebook group.

Below:
  • About the program
  • How to set an LED colour preference
  • How to embed the clock in a Web page
  • How to download the clock to run locally or host it on your own website

About the program

Antoni Gual Via created with QBasic a "digital 7 segment clock using only DRAW."  I've made some  changes to placate my fussy nature and a little addition:

  • I've filled in the segments (using PAINT, because BAM's DRAW statement does not support the "p" (paint) command
  • I'm using screen mode 17 instead of screen mode 12 (for the LED: access to 63 predefined colors, instead of only 15 colors; black is reserved for the clock background colour)
    • I'm also using a custom screen resolution
  • I've also modified the program to check the URL for a "color" query string which can be used to customize the colour of the clock LED lights.


How to set an LED colour preference

This program has been exported from BASIC Anywhere Machine as a "Stand-Alone" program.  It is a small HTML file that contains the source code "bound" to the BASIC-to-javascript transpiler (BAM's built-in fork of wwwBASIC.)  That HTML file can then exist anywhere: on a local storage device for running offline, on a static web server for running as a stand-alone Web Page, or on a Web server for inclusion (as a "gadget?") into any other Web page or Web site.

To use a colour other than the default, add a "color" parameter to the URL.

For example, using the program I have hosted on my Neocities site:
  • The URL for the program without specifying a colour preference
    • https://basicanywheremachine.neocities.org/sample_programs/DRAW%20DIGITAL%20CLOCK.prod.run
  • The URL for the program with a colour preference specified
    • https://basicanywheremachine.neocities.org/sample_programs/DRAW%20DIGITAL%20CLOCK.prod.run?color=15
See this documentation page to find the color codes for the pre-defined available colors for screen mode 17 (the "p256" colour mode found in the "colour modes" section after the list of screen modes.)

How to embed the clock in a Web page

(Creating BAM programs that can be embedded in Web pages, it is a fun way to give good old BASIC a useful purpose!)

To embed this BAM program in another Web Page or Web site, here's how to do that with an HTML iframe:

<iframe src="https://basicanywheremachine.neocities.org/sample_programs/DRAW%20DIGITAL%20CLOCK.prod.run" style="width:300px;height:100px;">
</iframe>

Here is a screenshot of the result in TiddlyWiki :

How to download the clock to run locally or host it on your own website

Somewhere in your browser's menus, find something like "Save Page as".



For my Web browser, I then choose to save the file as a "Webpage, HTML only".

Wherever you save that file locally, double-clicking on it should open the file in your Web browser, and the clock program should start running immediately.

Aside:  The Chrome web browser on my Chromebook allows setting up an HTML page as an "app", so that the HTML page appears as a stand-alone application, instead of a Web browser tab.  The Chromebook remembers the location and size of the clock program.  Neat !











Monday, June 16, 2025

🖥 Swirl of Orbs

This program is a port and mod of a Turbo Basic program shared by Shahid Altaf Qureshi with the BASIC Programming Language group on Facebook (🔗 link to post).






















Saturday, June 7, 2025

🖥 "Schrafic" Fractals Generator

This program is a port and mod of a QB64 program created by Eric Schraf (and shared with the BASIC Programming Language group on Facebook: đŸ”— link to post ). 

NOTE: Although the program sleeps for about 3 seconds before drawing a new layer (either on top of existing layers or after, randomly, clearing the screen), you can pause the action by clicking/touching the screen.  Release the click/touch to resume the graphing process.








Saturday, April 26, 2025

🚧 In the Works: "Code Insertion" buttons

Try this in the 🔗 development version of BASIC Anywhere Machine.

Who likes looking up statement/function statements (or code blocks) to whenever does not remember the precise syntax?  These buttons (very much a work in progress) will insert template code.












Sunday, April 20, 2025

📚 TIP: Exporting a BAM Program for Embedding as an App in Web Pages

Say we have written an analog clock program, and we want to show that clock on a Web Page.

Here is a QB64 program by b+ ported to BAM:

Although you might want to embed a "development" version of your BASIC program (as a preview of your app, and/or for testing purposes), let's assume that your BASIC program has been promoted to the "production" level, and it is the "production" version of the program that we want to embed in some Web Page.

In BAM, click on the "Project" menu.  In the "Project" pop-up menu, click on the "Export" menu item (the last item in the menu).



In the "Export Options" dialog, click on "Stand-Alone (PROD):



You will then be prompted with a dialog in which you give the export file a name, and you provide the location where to save that file (the dialog's appearance will vary by Web browser):



The HTML file that has been exported and saved contains everything needed for the BASIC program to run as an independent Web Page: the BASIC program, the transpiler (which at Web Page rendering converts the BASIC program to JavaScript, and whatever else is needed for any proper Web Page.)

To be accessed on the web (either directly as a Web Page, or embedded in an "iframe" HTML element in some other web Page), the HTML file needs to be copied to some Web server that can host "static" Web pages.  (The "Run the program" link at the top of this blog article is a link to the HTML file uploaded to my Neocities website.)

To include the exported BASIC program as an app in some webpage, add code like the following to that web page:

<iframe
src="https://basicanywheremachine.neocities.org/sample_programs/Analog%20Clock%20by%20b+.prod.run"
style="width:100%;"/>

Note: for the clock to be embedded in another Web Page, the website hosting the clock's HTML file must be on a Web server that allows pages on that web server to be displayed in pages from other websites.

How's that for a pretty convenient way, if you are a BASIC programmer, to add your own custom apps to any Web Page ???

For example, here's the clock program running in a TiddlyWiki instance (a TiddlyWiki instance, whether stored locally or on the web, behaves a little bit like a single-file Web site):










Friday, April 18, 2025

🖥 Dony Grapher

This program is a port and mod of a program shared by Antoni Gual Via with the "BASIC, QBasic, GWBasic computer programming" Facebook group.

From Antoni's post:

Some graphics from Mr Dony's book. It uses the "bugs in love" algorithm. The circle is divided into triangular sectors. At each vertex of one sector there is a bug that's attracted by tha bug in the vertex in front of him so it moves to reach it. At intervals a picture of the new triangle defined by the moving bugs is plotted. The order of the initial vertices is inverted in even and odd sectors to increase symmetry.




































Saturday, March 15, 2025

📚 Simulating OOP Methods in BAM Using GOSUB

BASIC Anywhere Machine's GOSUB implementation allows using numeric expressions for dynamic line numbers or using string expressions for dynamic line labels.

  • As of this blog entry's publishing,  the "production" version of BAM requires such an expression to be within parentheses and preceded by the "EVAL" keyword
    • example:  GOSUB EVAL( some_expression )
  • The current "development" version of BAM drops the "EVAL" keyword, because the parentheses are enough for indicating an expression for GOSUB
    • example:  GOSUB ( some_expression )
    • note: this syntax will appear in some yet-to-be-determined "production" release of BAM, replacing the syntax using "EVAL"
The use of expressions as GOSUB arguments allows BAM programs to simulate OOP methods, as demonstrated in the following program:
The program fills the screen with 570 random shapes (circles or squares) with random ( x, y ) center coordinates, random colours, and random sizes.

Each type of shape has a dedicated shape-drawing GOSUB routine.

The program is written in a way that assumes a future enhancement that involves movement of the shapes and bouncing away from the edges of the screen.

🖥 Digital Clock

This program is a port and mod of Antoni Gual Via's program shared with the "BASIC, QBasic, GWBasic computer programming"'...