Wednesday, January 12, 2022

New feature: Export BASIC programs (three options)

 Today's new version of BASIC Anywhere Machine adds the "Export" button to the File menu.



This export button is the standard TiddlyWiki export button.  Upon clicking it, the button presents a pop-up menu which will offer you options to export the tiddler in multiple formats.

To the standard formats, BASIC Anywhere Machine adds these three new options:
  • ".bas" file
  • ".bas.html" file
  • ".bas.json" file


".bas" file

This will take the tiddler for the BASIC program, resolve all transclusions (via "wikification") and export the program to a plain text file.

The usefulness of this: take a program that you've created and tested, and use the source code with other BASIC implementations (QB64, Qbasic, FREEBasic, PureBASIC, Gambas, etc. etc.)  So BASIC Anywhere Machine as portable and run anywhere generic BASIC programming (and testing, and source code manager), feeding projects using other BASIC implementations.  Cool.

".bas.html" file

This will do the same as export to ".bas" file, but wrap the basic program with all of the html and javascript needed to have a legit single-file web page (fully self-contained) for running the BASIC program.  

  • BASIC Anywhere Machine uses a custom version of wwwBASIC.js and embeds the javascript directly in the HTML file (i.e. does not use "include" of any external files).  The resulting file will otherwise be very similar to the file described on the wwwBASIC github page.

The usefulness of this: deploy/share a BASIC program as a self-contained HTML file.  (i.e. just the necessaries for the BASIC program to run.   Anybody can run the BASIC program anywhere: the only thing needed is a web browser.

".bas.json" file

Partially complete !!!  Currently only works for BASIC programs that do not have any TiddlyWiki  transclusions of source code.  For information about the source code transclusion feature in BASIC Anywhere Machine, please read about that further below.

This is an enhanced version of the native TiddlyWiki single-tiddler JSON file export option, but adds to the export the bare minimum number of tiddlers needed to run the BASIC program in another TiddlyWiki.

The usefulness of this: take a program created and tested in BASIC Anywhere Machine, and export just what is needed for the BASIC program to run in any other TiddlyWiki instance.  The tiddlers in the JSON file created by BASIC Anywhere Machine can be imported into another TiddlyWiki instance.


Man, all of this gets my geek mojo going.

Cheers !


BASIC Anywhere Machine's "Code Transclusion" Feature

BASIC Anywhere Machine enhances BASIC programming by taking advantage of TiddlyWiki's "Transclusion in Wikitext" feature.

Upon start (aka RUN) of a BASIC program in BASIC Anywhere Machine, the program is pre-processed before getting handed over to the interpreter.  Pre-processing resolves all transclusion instances.

In the following program,  the "{{Conversion Functions}}" transclusion reference will get replaced during pre-processing by the content of the tiddler called "Conversion Functions".


' 📚 libraries
{{Conversion Functions}}
'
' 🏁 start
'
print "The number of kilometers in 2 miles = "; MilesToKms!(2)
print "The number of miles in 2 kilometers = "; KmsToMiles!(2)
'
end
' 🏁

The "Conversion Functions" program:

function MilesToKms!(Miles!)
MilesToKms! = Miles! * 1.609345
end function
function KmsToMiles!(Kms!)
KmsToMiles! = Kms! / 1.609345
end function

The result of pre-processing, the code that will be passed to the interpreter:

' 📚 libraries
function MilesToKms!(Miles!)
MilesToKms! = Miles! * 1.609345
end function
function KmsToMiles!(Kms!)
KmsToMiles! = Kms! / 1.609345
end function
'
' 🏁 start
'
print "The number of kilometers in 2 miles = "; MilesToKms!(2)
print "The number of miles in 2 kilometers = "; KmsToMiles!(2)
'
end
' 🏁

Aside: in the sample programming code above, single-quotes are alternatives to the "REM" statements (used for comments in BASIC programs.)  Also, for a bit of experimentation with code readability, I've added emoji's.  I think it is something which should be used sparingly.  


Tuesday, December 21, 2021

One of the Project Missions: Enhancing wwwBasic

I've added three new string functions to the version of wwwBasic embedded in BASIC Anywhere Machine: NOW$, TIME$, and DATE$.  (See the screenshot below.) 

Try it out:  BASIC Anywhere Machine

Keep track of progress and get information at the project website.

Make sure to keep an eye on the evolving BASIC Anywhere Machine Programmer's Reference.






Sunday, December 19, 2021

The "File" Menu and the "Tools" Menu

File Menu

The following menu items are now functional: New, Open, Save, Save As.


Tools Menu

The menu provides the following working tools: "Wikify Viewer", "Diff Viewer", and "Start Previous Version"


Related videos:






Wednesday, December 8, 2021

"Program Launcher(?) tiddlers?

 In video below, I demonstrate a "program launcher" tiddler with a simple GUI for configuring the settings for the BASIC program before running that program via the RUN button that is right there in the "program launcher" tiddler.

We can use this approach to create however intricate a program launcher that provides a GUI for adjusting a BASIC program however necessary for the current needs.



Monday, December 6, 2021

Added "Diff" and "RUN" buttons to ".BAS" tiddler toolbars

 This is functionality I eventually want to build-into the IDE.

The ability to simultaneously see consoles of both before and after changes to a program, this easily, is pretty sweet.






🖥 Circular Sinusoidal Waves with DRAW and SIN

Run the program View the source code