Tuesday, March 28, 2023

⛯ Making sure your program gets the "focus"

 A BASIC Anywhere Machine program cannot receive keyboard input (nor produce any audio) if it does not have the "focus".

For any program that's going to need (physical) keyboard input and/or produce audio output, it is a good idea for the program to get the focus just before the first line of code gets executed.

To have the program pause until it gets the focus, you have to turn off the "autostart this program" feature (which is set to "on" by default).

In the "Project" menu, click on the "Runtime Properties ..." menu item.

That will open the "Runtime Properties Viewer" window.

Remove the check mark on "Autostart his program".



Saturday, March 25, 2023

📚 "What is Computer Programming?" starts with "What is a Computer?"

Many old BASIC programming books define "Computer" very early as part of describing programming and the BASIC programming language.

I think it is worth thinking of programming and programming languages in a broader context.

What do you think?

Take a look at the beginning of the topic What is Computer Programming? and expand the first cut of the section "What is a computer?"

Friday, March 24, 2023

🆕 Programming Reference: feature to try your own code next to code snippets

The best kind of documentation is the kind that not only allows you to run example code, but also let's you try your own code !!!

Update: I'm in the process of changing the navigation setup in the documentation, so the previous example doesn't work right now.

This new example, although a work in progress, will work going forward with the bonus of describing the wonderfulness of running example code (and trying your own code) right "there", where your focus happens to be.  Click on the following link to see and try for yourself:


Saturday, March 11, 2023

🆕 _MAPSET and _MAPGET

 From Wikipedia:

A name–value pair, also called an attribute–value pair, key–value pair, or field–value pair, is a fundamental data representation in computing systems and applications. Designers often desire an open-ended data structure that allows for future extension without modifying existing code or data. In such situations, all or part of the data model may be expressed as a collection of 2-tuples in the form <attribute name, value> with each element being an attribute–value pair. Depending on the particular application and the implementation chosen by programmers, attribute names may or may not be unique.


BASIC Anywhere Machine provides a global "MAP" object for holding key-value pairs W. Each key is a unique string value to which is related some value (numeric or string) that can be repeated for other keys.

_MAPSET

Description:

The _MAPSET statement stores the value (a number or a string which may be the result of an expression) for the provided key (which may be the result of an expression.)

Syntax

_MAPSET( strExprKey, exprValue )

  • strExprKey
    • a string, which may be a literal value, a constant, a variable, or an expression of whatever complexity
  • exprValue
    • a number or a string, which may be a literal value, a constant, a variable, or an expression of whatever complexity


_MAPGET

Description:

The _MAPGET function retrieves the value for the provided key (which may be an expression resulting in a key.)

Syntax

_MAPGET( strExprKey )

  • returns: the value associated with the key (numeric or string)
    • however, if there is no matching key, then the return value is an empty string (i.e. "")



Friday, March 3, 2023

🆕 "?" as shorthand for PRINT

Can any BASIC implementation really be a BASIC without the ability to use "?" as an alternative to the keyword "PRINT" ?

One of my goals includes the ability too easily, with few if not zero edits, get old BASIC programs running in BASIC Anywhere Machine.

The ability to recognise "?" as meaning "PRINT" not only helps in that goal, but also feels good for anybody who did any BASIC programming during the home computer revolution.


📚 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 "pas...