Thursday, July 6, 2023

💡 Making the case for GOTO use cases

It didn't take long for me to be a "never GOTO, never ever" guy once we started to see structured BASIC implementations displace unstructured BASIC implementations.

Since I started working on BASIC Anywhere Machine back in December 2020, I've really come to appreciate the use of GOTO with line labels (instead of line numbers) in a couple of scenarios.

BASIC Anywhere Machine (aka "BAM") links:

 

Always being weary, of course, of not creating spaghetti code, here are two scenarios in which I find GOTO really practical.  When do you find GOTO useful and acceptable ?

Loops involving a lot of code

For the following blocks of code:

  • WHILE ... WEND 
  • WHILE ... LOOP
  • DO ... LOOP
  • DO WHILE ... LOOP
  • DO WHILE ... WEND
  • DO LOOP ... WHILE
  • DO LOOP ... UNTIL
If the bookends of the code block are so far apart that screen scrolling becomes necessary to see all of the code in the block, or if the code block had nested loops, matching the right bookends can become challenging.

I often prefer GOTO in these circumstances (expecially an infinite DO ... LOOP) because line labels make it easy to match the bookends of a code block.

For example:

StartLoop1: ...
...
...
GOTO StartLoop1

I find this approach concise and descriptive.


Skip over a block of code

In some circumstances, it makes more sense to me to have an IF that skips a block of code, rather than have an IF condition be satisfied to execute that block of code (and exclude the block otherwise).

Step1:
IF condition GOTO Step2
...
...
Step2:




Tuesday, July 4, 2023

📚 IF syntax documentation in progress

IF single-line conditional branch:


IF multi-statement single line


IF single-line single-statement alternatives


IF multi-line multi-alternatives code blocks


codeBlockForCondition







🆕 Tags (to describe and find programs) and ✏ New program defaults

Program Tags

Go to the File menu and click on Properties.


The "Tags" section is new.  For a selected program, click on any available check boxes to associate the program with that tag.


  Enter a new tag in the field, then press the "Create" button.  The tag will be added to the list and automatically selected.


Once any one program is tagged with some value, that tag becomes available to select for all other programs.


New feature on the "File Open" dialog: tags can be used to find programs that have all of the selected tags.


New Program Defaults now allows setting a "comprehensive" list of defaults that will be applied to new programs.


Note that this edits the program execution properties of the "New.BAS" program.  Every new program created in BAM starts off as a copy of "New.BAS".


For example, after creating a new program, here are the Program Execution Properties:



Sunday, July 2, 2023

🪲 Keyboard Input Issues Fixed

I just deployed a new version of BASIC Anywhere Machine which fixes a bad bug introduced in the previous version.  (You might need to CTRL-refresh the browser page if your browser cached the previous buggy version.)

In setting up the SLEEP statement to work with no parameter and work with a parameter of zero (both of which suspend a program until a keyboard key, or screen click/touch, is done), I went and completely broke INKEY$ and INPUT with a complete face-palm mistake.  That's going to leave a mark ...

When retronick reported the error ( ⭐ much appreciated!), I knew right away what I messed up and where the mistake was hiding, so fifteen minutes later: voilà !

Wednesday, June 28, 2023

🎉 New version of BASIC Anywhere Machine

Latest version of BASIC Anywhere Machine:  try it now !

The list of enhancements in this new version of BASIC Anywhere Machine is faithful to those mentioned earlier (see the 🚧 In the works post.)

Some things may have changed a wee touch, so I'll mention any deviations in this post and also provide links to relevant documentation in the BASIC Anywhere Machine Programming Reference and User Guide.

Before getting into any details, here's the list:

  • New "View Code Issues" functionality
  • Documentation: Adding Syntax (aka Railroad) Diagrams

  • New UrlQueryString$ function
  • New UrlKey$ function
  • New PUTSTRING statement
  • New SCROLL statement
  • New IFF function
  • New BETWEEN function
  • New CHOOSE function
  • New MIN and MAX functions
  • New DAY$ function
  • New FRAC function
  • Added DIV keyword as an alternative to the "\" operator
  • Improved INSTR function
  • Improved SLEEP statement
  • Improved conversion from base 10 numbers to binary/hexadecimal/octal number systems
  • Added BIN$ as alternative keyword for _BIN$
  • Improved WIDTH statement
  • New HEIGHT statement
  • Improved RANDOMIZE statement
  • Improved DEFtype statements
  • Changed INTEGER data type

Saturday, June 10, 2023

🚧 In the works: Code Issues Notification and Viewing

New "View Code Issues" functionality

BAM's interpreter does not know how to handle a declared sub or function that does not have a matching sub or function definition.  Instead of giving the interpreter the smarts to gracefully report the error (currently, BAM can get entirely locked up as it heads to never-never land), the preprocessor will eventually prevent running and exporting a program when it has the problem.

For now, BAM will let you know about the problem via the Project menu.  Just above the Run menu item, BAM will display a "View Code Issues" menu item as a visual cue to let you know that there's a problem.

Click on the menu "View Code Issues" menu item for details.

The development version and the production version of an application have independent instances of the menu item.


Problems identified in both the development
and production versions of the program



Viewing the details to pinpoint the problems



After the problem is fixed in the development version


After the fixed development version of the program is promoted to production









Wednesday, June 7, 2023

☢ Single-line IF THEN: a statement must immediately follow the THEN keyword !

 Here's an interesting syntax issue which does not result in a very useful error message:


Currently (and for the foreseeable future), BASIC Anywhere Machine does not know how to provide an informative error message for this problem, a syntax problem that has the interpreter completely confused.

When creating a single-line IF-THEN statement, the BASIC Anywhere Machine program will fail if a THEN statement is immediately followed by a colon without any statement between "THEN" and the colon.

So should you run into an error message that does not make any sense at all, take a look at your code in the near vicinity to rule out this kind of syntax problem in any single-line IF-THEN statements.


🖥 Circular Sinusoidal Waves with DRAW and SIN

Run the program View the source code