in reply to A BASIC interpreter to run StarTrek

Cool!

A few things: Seems you developed this on Windows. Other OS are case sensitive regarding the filesystem, so the correct filename to save the BASIC program would is StarTrek.bas (note the uppercase letters).

Another thing: Perl uses "native" line endings by default. I had to convert the bas file to Unix line endings for the interpreter to work for the first test.

Here's a simple patch that should make this work on Linux and possibly also on Mac:

diff -u basicinterpreter.pl basicinterpreter_fixed.pl --- basicinterpreter.pl 2021-08-11 15:51:20.359658237 +0200 +++ basicinterpreter_fixed.pl 2021-08-11 16:01:08.724748447 +0200 @@ -28,6 +28,8 @@ while (<$fIn>) { chomp; + s/\r//g; + s/\n//g; next if /^#/; my ($lineNum, $line) = /^(\d+)\s+(.*)/;

perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'

Replies are listed 'Best First'.
Re^2: A BASIC interpreter to run StarTrek
by GrandFather (Saint) on Aug 11, 2021 at 21:28 UTC
    Seems you developed this on Windows

    Guilty as charged. Usually I'd at least have gotten the file name case consistent, but it was a few minutes past bed time and I created the node in a bit of a rush. Sorry about that. Fixed now along with the line ending issue.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond