Tuesday, November 29, 2022

🆕 _AUDIODONE and 🆕 _ENDAUDIO

 Check out the latest version of the BASIC Anywhere Machine "Amazing Grace" program:

BTW: at the end of the song, or after you stop the song, you'll have the option to play the song again.  Choose "Y", and then you can alter the tempo of the song and the waveform applied to the sounds.

_AUDIODONE

Description:

The _AUDIODONE function returns -1 (TRUE) if there are no sounds left to play in the sound queue, and returns 0 (FALSE) otherwise.

Syntax

_AUDIODONE


_ENDAUDIO

Description:

The _ENDAUDIO statement flushes the sound queue in order to stop playing currently queued sounds. There may be a few sounds in the queue that have gone past the point of no return, so there may be a slight delay before all sounds stop playing.

Syntax

_ENDAUDIO

Monday, November 28, 2022

🪲 Subroutine invocation without the CALL statement : NOW IT REALLY WORKS !!!

In an earlier post,  I describe undoing a problem I introduced into wwwBASIC.  I had broken wwwBASIC's ability to handle subroutine invocation without using the CALL statement.

Just when I got it working again, I discover that wwwBASIC's code for handling subroutine invocations without the use of CALL is broken: if the subroutine has more than one parameter, none of the parameters beyond the first one actually get passed to the subroutine.

Now, BAM's embedded version of wwwBASIC can handle subroutine invocations without CALL just as well as subroutine invocations with CALL.

Sample code used to discover the issue:

sub hey(a$, d%, c$)

    print "a$: " + a$

    print "d%: " + d%

    print "c$: " + c$

end sub

 

call hey("howdy", 5, "later") ' this works no problem

hey("hello", 6, "bye-bye")    ' this, all parameters except the first are "lost"

Before today's fix, the subroutine invocation without CALL would only pass a value for the first parameter, and ignore all parameters beyond the first one.


❇ HZ# function, all notes for all octaves are now setup and 🆕 documented

You'll find a "Musical Pitch Notes and Frequencies Matrix" in both BASIC Anywhere Machine and in the Programming Reference.

In BASIC Anywhere Machine: look for the "Lookups" menu item in the "Tools" menu.

In the Programming Reference: lookup "HZ#" in the keywords reference, and you'll find the matrix in that page.

For a quick peek, click on this link to view the HZ# documentation in "Wiki" mode.

Sunday, November 27, 2022

🆕 _INITAUDIO and 🆕 _FINISHAUDIO and ❇ SOUND

The SOUND statement was previously totally synchronous (i.e the sound had to finish before the program would process any subsequent statements.)  This behaviour is now very different.  (see further below for how SOUND now behaves.)

Also, please refer to the Amazing Grace sample program (it uses all of these statements):


Documentation about _INITAUDIO, _FINISHAUDIO, and SOUND (it kind of ties everything together:

_INITAUDIO

Description:

The _INITAUDIO statement initialises the web audio api for subsequent calls to  and  statements.

Syntax

_INITAUDIO


_FINISHAUDIO

Description:

The _FINISHAUDIO statement delays further execution of the program (including end of the program) until all queued sounds have played. See the  statement for more info.

Syntax

_FINISHAUDIO


SOUND

Description:

SOUND plays a sound of a specified frequency for the specified duration (measured in "ticks").

  • NOTES
    • Sounds in a BASIC Anywhere Machine program will not happen unless the program console window has the "focus"
      • Program Execution Properties: Remove the checkbox on "Autostart this program?"
        • The program will not commence until the user clicks on the program console window
      • Recommended: consider calling the  statement at the beginning of your program
        • This will initialize (a one second delay) the web audio api such that the first instance of SOUND will sound correctly
    • Synchronous and asynchronous behaviour of the SOUND statement
      • A SOUND statement, vis-à-vis other statements in the program flow, is asynchronous: after a program executes a SOUND statement, the program does not wait for completion of the SOUND statement before executing the statements after the SOUND statement
      • A SOUND statement, vis-à-vis other SOUND statements in the program flow, is synchronous: if a previous SOUND statement is still being played, the current SOUND statement will wait for the previous SOUND statement to finish; all SOUND statements go into a queue, and each sound will only happen after the previous sound is done playing
      • Because sounds are asynchronous vis-à-vis the rest of a program, it is very possible for a program to end before all of the sounds in a sound queue are processed. If we want the sound queue to finish playing before program end (or before further program execution), call the  statement
    • To alter the waveform of sound, call the _SNDWAVE statement.

SOUND 0,0 will end any on-going sound.

Syntax

SOUND frequency!, ticks!







Saturday, November 26, 2022

🪲 Subroutine invocation without the CALL statement

I added some code to wwwBASIC very early this year to overcome a problem in wwwBASIC, and wound up unwittingly breaking wwwBASIC's code that allows a subroutine to be invoked without using the CALL statement.

It took some digging to figure out that wwwBASIC does some token readjustments when a subroutine is invoked without the CALL statement.

Without getting into the weeds, here are the (now working again) options for invoking a subroutine:

Branch to Subroutine Syntax

With CALL

With parameters:

CALL subroutine_name( expr , expr🔁 )

Without parameters:

CALL subroutine_name

Without CALL

With parameters:

subroutine_name( expr , expr🔁 )

Without parameters:

subroutine_name


Friday, November 25, 2022

❇ PSET and ❇ PRESET

 Added the STEP keyword as an option for both statements.

The PSET graphics SCREEN statement sets a pixel at a specified coordinate to a specified color attribute, or the current foreground color if a color attribute is not specified. When the STEP keyword is included, then PSET sets a pixel at a coordinate that is relative to the most recently referenced point.

PSET (column%, row%)[, colorAttribute]

PSET STEP (column%, row%)[, colorAttribute]


The PRESET graphics SCREEN statement sets a pixel at a specified coordinate to a specified color attribute, or the current background color if a color attribute is not specified. When the STEP keyword is included, then PRESET sets a pixel at a coordinate that is relative to the most recently referenced point.

PRESET (column%, row%)[, colorAttribute]

PRESET STEP (column%, row%)[, colorAttribute]



❇ READ

The READ statement did not give any error message when trying to read beyond the available DATA values.

Now, a program will report an error when a program tries to read beyond the available values.

Wednesday, November 23, 2022

🆕 _CONSOLELOG statement

The _CONSOLELOG function sends the string resulting from some string expression to the browser's web console.

Syntax

_CONSOLELOG (strExpression)

  • strExpression can be a simple literal string or a string expression of any complexity


Useful for debugging programs by strategically placing instances in a program to let you know what part of your program executed and what values certain values may have.

To have an opportunity to open your browser's web console, make sure to setup some kind of delay to your program which gives you time to right click on the program's console window, and tell your web browser to open the web console.

The _ALERT statement is perfect for pausing the program and diving you the time to open the web console.  You might also want to consider an _ALERT statement right after a _CONSOLELOG statement to give you time to review the web console before continuing the program.

Code sample:

<<debug """

    _alert("open your browser Developer Tools to access your browser console.")

""">>

greet$ = "good day ladies and gentlement, this is the production version of the program"

<<debug """

    _consolelog("greet$ = " + greet$)

    _alert("paused for web console review")

""">>

print greet$





Tuesday, November 22, 2022

❓How To: Moving BASIC programs between BASIC Anywhere Machines

In the first video:

  • Download BASIC Anywhere Machine
  • Powerwash to make a "pristine" version of BASIC Anywhere Machine (i.e. remove all programs and other content from the hosted version of BASIC Anywhere Machine)
  • Use the "Export Your Stuff" feature
As soon as I finished the first video, it dawned on me: that third part will be totally useless for anybody with an older version of BASIC Anywhere Machine.

So in the second video:
  • Use TiddyWiki to get the list of programs, and drag them individually from one BASIC Anywhere Machine to another
    • this works will all versions of BASIC Anywhere Machine, past/current/future.






Monday, November 21, 2022

🆕 dev and prod metacommands

 Sample code:

<<dev """
  greet$ = "howdy buds, this is the development version of the program"
""">>

<<prod """
  greet$ = "good day ladies and gentlement, this is the production version of the program"
""">>

print greet$


dev

Description:

The dev directive tells the BAM preprocessor to only include the contained BASIC statements IF the development version of the program is being run or exported.

This is useful when you want the program to look/behave differently depending on the promotion context.

Syntax

<<dev """BASIC-statement(s)""">>


prod

Description:

The prod directive tells the BAM preprocessor to only include the contained BASIC statements IF the production version of the program is being run or exported.

This is useful when you want the program to look/behave differently depending on the promotion context.

Syntax

<<prod """BASIC-statement(s)""">>

Wednesday, November 16, 2022

🆕 _BIN$ and &O

 _BIN$

_BIN$ converts a decimal number resulting from the specified numerical expression into the binary equivalent.

Syntax

_BIN$ (numExpr)

return value: string that is the binary representation of the number.


&O

&O is a "numerical base prefix" for octal numbers.  This new prefix expands the already existing two other prefixes: &H for hexadecimal numbers and &B for binary numbers.  (All of these prefixes can be in either lowercase or uppercase.)

Examples for all of these numerical base prefixes:

  • Binary numbers: prefix with &b or &B
    • print &1010 prints the decimal number 10
    • print &b11111010prints the decimal number 250
  • Hex numbers: prefix with &h or &H
    • print &ha prints the decimal number 10
    • print &hfaprints the decimal number 250
  • Octal numbers: prefix with &o or &O
    • print &o12 prints the decimal number 10
    • print &o372prints the decimal number 250







Tuesday, November 15, 2022

🚧 In the works: Software Development Life cycle Tools

You will find under BAM's Tools Menu a group of menu items in the category "SDLC tools."

These are prototype tools, subject to significant change at any time, to showcase functionality in the works.

The intent is to eventually have a suite of tools that support all of the artefacts and workflows related to the full spectrum of activities and roles one would expect to find in a software development life-cycle (aka "software development process.")

Pay attention to the Tools Menu and incremental changes going forward.

🆕 _TITLE

The _TITLE statement sets the program name in the title bar of the program window (for BAM, the title showing in the browser window tab) for a program exported as a "Program Deployment" (either DEV or PROD) file.

(If a program does not specify a title via the _TITLE statement, the title bar will by default have the name of the program, the promotion level of that program, and the date/time the program was exported to the file.)


Syntax

_TITLE stringExpression$

🆕 Title shown for in browser windows for deployed programs

As of today's new version of BAM, programs exported to deployment files (either dev or prod) will show titles in browser tabs that look like this:


program_name (promotion_level export_date_time)

  • program_name is the name you've given to the program via BAM's File + Save As  menu item
  • promotion_level is "dev" for development or "prod" for production as per the version of the program you are exporting
  • export_date_time is the UTC date and time when the program is exported to a deployment file, with the format YYYY-MM-DD "hh-mm"

A mesmerising animation (an MMBASIC to QB64 port by Gadgetjack, ported to BAM by Charlie)

Friday, November 11, 2022

🆕 _INPUTBOX$ and _KEYCLEAR and ❇_PROMPT

Added the _INPUTBOX$ function and the _KEYCLEAR statement.

Modified the _PROMPT function. (The second parameter is now optional.)


The _INPUTBOX$ function displays a prompt in a dialog box, waits for the user to input text or click a button, and returns a string containing the contents of the text box. The returned string is an empty string ("") if the user cancelled.

Syntax

_INPUTBOX$ (title$, message$)
_INPUTBOX$ (title$, message$, defaultValue)

Return value: a string


_KEYCLEAR clears the keyboard input buffer.

Syntax

_KEYCLEAR


The _PROMPT "Popup Box" function is used in a program to receive 1 string of characters via the web browser's standard prompt dialog for user input of some text. The running program will wait until the user either submits the text or cancels the dialog (returning no text.)

Syntax

_PROMPT (message)
_PROMPT (message, defaultValue)

Return value: a string

  • message is a simple literal string or a string expression of any complexity
  • defaultValue is a simple literal string or a string expression of any complexity


Tuesday, November 8, 2022

What is BASIC Anywhere Machine?

 I've had a hard time explaining it ever since I first started thinking about it.  This is my latest attempt.

BASIC Anywhere Machine is becoming:

Imagine Wikipedia (as in the software behind it and everything that makes it work), all existing in one self-editing and self-saving HTML file.

Imagine that one file containing:

  • everything needed for BASIC programming
    • an interpreter
    • an IDE
    • all of the programming tools
    • all of the programs
    • and all of the data for those programs
  • and everything to support all processes and artefacts for
    • project management
    • requirements management and traceability
    • source code management
    • all things from end to end in a software development process

And all you need along with that file is a web browser:

  • offline. online. all fine.
  • the device doesn't matter.
  • the operating system doesn't matter.

Now, forget about Wikipedia.

BASIC Anywhere Machine is a TiddlyWiki instance.  Because TiddlyWiki has the goods (goodies) to create just about anything.  Don't let the cutesy name fool you.  The thing is a powerhouse.

Friday, November 4, 2022

🪲 PRESET when no color is specified

In wwwBASIC, PRESET does the exact same as PSET when no color is specified: they both set the pixel color to the foreground color.

In BAM, PRESET now sets the pixel color, when a color is not specified, to the background color.




Thursday, November 3, 2022

Mouse Input functions: 🆕 _MOUSEX, _MOUSEY, _MOUSEBUTTON, _MOUSEWHEEL ❇ GETMOUSE

The _MOUSEX function returns the current Y coordinate of the mouse pointer.

The _MOUSEY function returns the current Y coordinate of the mouse pointer.

The _MOUSEBUTTON function returns a 1 if the mouse button is currently pressed, and returns a 0 if the mouse button is currently not pressed.

The _MOUSEWHEEL function returns the accumulation of wheel decrements and increments that have been done with the mouse wheel since the last call to the function. (i.e a call to the function resets the number of wheel increments to zero.)

Pushing the wheel forward will decrement the number. Pulling the wheel backward will increment the number.


GETMOUSE

Although the syntax was setup in wwwBASIC to accommodate a mouse wheel parameter, there was never any code setup in the interpreter to get values for the mouse wheel.

The version of wwwBASIC in BASIC Anywhere Machine now gets the mousewheel value.

NOTE that GETMOUSE's retrieval of mousewheel value differs a bit with the _MOUSEWHEEL function.

Syntax

GETMOUSE x%, y%
GETMOUSE x%, y%, w%
GETMOUSE x%, y%, w%, b%

    • x% = horizontal position
    • y% = vertical position
    • w% = accumulation of wheel increments and decrements since the last call to the function  🐟
    • b% = button


❇ Documentation redesign: Enhancements to wwwBASIC page

Check out the page, changed from a long list to a table.

🖥 Pongy game

This program is a port (and slight mod) of the QB64pe program by SierraKen.  (SierraKen's program shared with the QB64pe community in th...