Welcome to tbas, a console interpreter for the BASIC
language, in a structured version (no need for line numbers even if it can
deal with them), complete with many math functions and many many features!
Documentation
Available documentation (which is contained into the
downloadable package and is linked here for your convenience):
The tbas manual for current version in pdf
format.
Installation
The tbas executable, before use, must be compiled and
installed. I suggest the following very easy procedure in 4 steps (use the
terminal):
1) Copy the package somewhere, and unpack it; it will unpack into a
directory named tbas.1.0.XXX.src;
2) Now, choose a directory in your path, where executables will be saved;
let's assume it's ~/bin (that is the
sub-directory /bin in your Home directory,
but you can choose any). Edit the Makefile to customize addresses for tbas (e.g., among the rest, change the install
directory to ~/bin, commenting the
undesired destinations and leaving un-commented ONE ONLY valid
destination) using the destination directory you chose.
3) get into tbas source directory and type the following (be sure to have
gcc installed):
$ make
$ make install
(the latter may require root privileges if you try to install tbas into
system directories, as suggested by default in the Makefile).
For Mac Users:
in case you want to install tbas into some
system directory (e.g. /user/local/bin), remember that root privileges are not required, as
long as you can access an administrative login: in this case,
after make, login as an administrator with
$ su
(being the username of the administrator) - you will
be requested of a password - and then install the software with
$ sudo make install
$ exit
4) now type the following to test the correct installation:
$ tbas –help
This shows the basic features of tbas and you're done!
Download tbas
Version 1.0.Beta (September 15, 2019)
Well, this new release requested a quite endless turn of changes, and
for all the new features and corrections I thank Bruce
Axtensand Tom Lakewho, along with my friend Ian Jones,
helped me to release this Beta version... Thanks also to Marcus Cruz,
who suggested a couple of interesting improvements
The introduction of the
interactive session (suggested by Tom) led to a number of problems
(mainly the error detection system and the
insertion/deletion/substitution of lines), problems that Bruce, Tom and
Ian signaled in great quantity during the development phase, and that I
finally manage to solve. I mean most of them. This required rewriting
part of the code to adapt it to the interactive session. In any case now
it's time to let you use it and test it.
WARNING: I removed
all differences from Unix and not-Unix systems; tbas can now be
compiled under Linux only, or under Windows with CygWin/MinGW
installed and run from there (though not every feature is guaranteed
to work). It's too onerous and overwhelming treating more than one
Operating System...
New additions:
added the interactive session (enabled by option -i) . This is the
main innovation with respect to the Alpha (build 3) version
added ON and OFF as synonyms to TRUE and FALSE
added FREE/FREE$
added functions ALN/ALN() and ELN/ELN() to return the number of the
line where an interrupt/error occurred
The introduction of the interactive session, to let the user adopt
options from there, forced me to separate the Header and Timing features
in the starting option; now -H enables the header only, and -T
enables the timing (this was asked by Tom)
added the ? command synonym of PRINT
added the command PIPE that stores in an internal buffer the output of
the execution of the bash command contained in its string argument and
coming from a pipe source, and the string function PIPE$ that returns
the content of the PIPE buffer, as a whole or as one slice of it. Bruce
was the one who proposed this
added # as the equivalent operator of <>
added the LTRIM$ and RTRIM$ string functions
added option -D, that disables the inversion of colors in debugging
(asked by Bruce)
added the EXEC statement to execute the string argument as a BASIC
statement, an ideal companion of COMMAND$
added UNTRACE as synonym of TRACE OFF; also added to TRACE the ability
to print the variable content if TRACE is followed by the variable
index, or print the variable content when it changes if TRACE is
followed by the variable name
added the numeric functions NUMBER(A$), PICT(A$) and ALPHA(A$), with
string arguments
added the PROGRAM/TITLE/_TITLE statements
added option -L to list the program indented rather than executing it
added option -N, to print eleven spaces enclosed in quotes in place of
a void string when a MAT PRINT is used to print a string array; in ALpha
(build 3) that token was printed by default, but now you can choose
whether use it or not by using option N; the default behavior is now to
print the 'real' empty string. Correspondingly, I added the OPTION NULLS
ON/OFF to change the behavior during run-time.
added the AS STRING and the AS REAL specifiers in DECLARE; they are
simply ignored (apart for some check) because the two types are the
default types in BASIC, but they help in writing clearer definitions,
and make programs compatible with other dialects.
added the SWAP statement, by a precise request by Tom
added the COPY statement, that copies one array onto another
added the REM PRAGMA statement, to pass to program some console
options; PRAGMA does not execute in the interactive sessions. This
statement (which is invisible for other BASICs) lets declare options in
the PRAGMA line and avoid the need to specify which options must be
invoked in the command line to execute the program you're deploying
added the REAL() function, which is simply ignored, because all
numbers in tbas are real (in the math sense). Again, this makes the
program clearer and maybe compatible with other dialects
added the two system variables LASTCHANNEL and FREECHANNEL that return
respectively the last successfully opened channel number and the first
available (i.e. not opened with OPEN, FILE or FILES) channel number.
This is a Bruce request. These variables, like CLK or DATE, cannot be
instantiated by the user, but their content can be assigned to normal
variables
added the statements ERRPRINT, OPTION ERRORSTREAM ON|OFF and the
system variable STREAM (requested by Bruce)
added PROGRAM$, a system string variable that returns the name of the
current file under execution; in the interactive session, reports the
file loaded/saved as last. (requested by Bruce)
added the passing of arrays to SUBs, specified by the name and the ()
token
added MONTH$ and WEEKDAY$ as synonyms of MONTH$(0) and WEEKDAY$(0)
added the new options -e and --exec that execute immediately the
loaded program (it must be used with option -i). If no program is given
as argument to be loaded, the empty program is run (i.e., the empty
lines separating the running before and after execution are printed, and
nothing more). If -i is not used, -e alone is ignored
added option --interactive as a synonym for -i
added the INCLUDE statement (from the MTS tradition), to change the
standard input to the file given as an argument string (the default is
that the input is expected from keyboard); only INPUT and MATINPUT are
influenced by this statement; INKEY$ and INPUT$ (which require a
keyboard input) continue with their standard behavior
added OPTION WARNINGS ON|OFF
added to LINEINPUT# (and LINPUT#) the ability to consider also void
lines in reading from files (required by Ian)
added the USING statement, that fixes a default format for all
subsequent prints of the same type. USING or USING OFF can be used to
disable this features also a PRINT USING disables the features. Use with
care, the format establishes the things that must be printed (if you set
USING "###.###" you cannot print strings until you disable USING!)
many other minor additions were applied. The manual is updated, so
check it for further notices.
Solved bugs:
completed the recognizing of variables names, making it
case-insensitive, and thus accepting 'a' as 'A' identifying the same
variable. SUBs were already made this way (CALC and calc already
referred to the same sub)
Revolutionized the syntax: now in the source the statements DECLARE,
SUB, HANDLER, WHILE, UNTIL, IF must be followed by a blank. Also SELECT
and DO, if followed by something. The keywords THEN (when followed by
something), TO, STEP, BY, AS, OTHERWISE, IN must be written surrounded
by blanks. The commands FOR, GOTO, GOSUB, ELSE, USE, when not used
as statements, must also be surrounded by blanks
modified ONDEBUG and OFFDEBUG to be used with ON and OFF, and thus the
command is ON DEBUG and OFF DEBUG
solved a bug in SYSTEM that, if the user hit CTRL-C during the
session, when SYSTEM/BYE is typed, the interrupt error appeared without
need
after a comment in comp.lang.basic by Marcus Cruz, I realized that the
two comments @ (stop) and & (suspend) are redundant. So, accepting
his suggestion, I chose to use @ only, both for suspend and stop (in
practice, 'stop' is a 'suspend' that is not terminated). This seems
reasonable and technically good. There shouldn't be much code around
with the & comment, but if you've used it, change & to @ and
that's done
solved a bug in the numeric functions MIN and MAX, that in some cases
didn't return the correct value. The same for VMAX and VMIN. The problem
was signaled by TOM
Modified and simplified the string printing, because there were too
much limitations that came from the DEC version (decb). These limits
were removed and now tbas prints full strings (up to the maximum string
length). Maintained the limitations to the quote mode, but in any case
the effects of the limits were detectable only with strings longer than
the screen line width limit of 72.
added to tbas the capability to work with different EOL formats (that
basically prevented the correct execution of algebra and of LIST
(indentation).
solved a bug in INPUT$ that didn't echo the typed characters, so I
enabled the typing according to the OPTION ECHO/NO ECHO, which is
enabled by default.
changed the destination directory for tbas man page to /usr/local/man
rather than /usr/share/man which was non-standard. Before installation,
type as root 'make uninstall' in the previous installation directory to
remove all previous instances of tbas.1 if you want a clean state
Fixed a bug in ON..GOSUB that didn't calculate exactly the OTHERWISE
clause address
Fixed a bug in MAT INV that sometimes conflicted with OPTION BASE 1
because of a wrong indexing in the last code lines
added to EXIT SUB the ability to exit from the sub writing the name of
the SUB rather than using the keyword SUB; the two following are
equivalent: EXIT SUB and EXIT myfunc
designed a more cute exiting message from the interactive environment
fixed a bug in the recognition of the user string, that in Windows
caused a SIGSEGV error, due to a void string generation (signaled by
Bruce)
solved a bug in MAT INV ... ELSE (the ELSE part) that was not working
as expected
increased in tbas.h some constants for the execution of the recursion,
to avoid (possibly) the segmentation error
solved the nth bug discovered by Ian (they must be one thousand now!):
at times when a tick comment was used, the program got confused by the
possible spaces between the last character of the statement and the tick
comment. Now the execution removes both the tick comment and the spaces
before it.
removed the ability for LEFT$ and RIGHT$ to work without arguments but
the first. Now the second argument is due. Also, removed the ability for
MID$ and SEG$ to work without the second argument, but maintained the
third optional (as Tom suggested, comparing the QBASIC output)
enabled error condition for LEFT$ and RIGHT$ when the second argument
is negative
enabled error condition for MID$ and SEG$ when the second optional
argument is negative or null
enabled error condition for MID$ and SEG$ when the third optional
argument is negative.
solved another bug discovered by Ian (no, really?): the CASE .. TO ..
was 'strangely' messed up
solved a bug in the color system: at the end of execution, default
colors weren't correctly restored
renamed EVAL to EXEC
renamed VAL to EVAL
added EVAL to execute more string arguments, separated by comma or
semicolon
solved a bug signaled by Bruce, that caused the algebraic parser to
read the current declaring variable, fact that prevented the correct
assignment of variables with SUB or DEF having arguments with the same
name of variables passed as arguments
enabled CALL to be used to call user SUBs (requested by Bruce),
independently of their being functions or procedures. Calling a
procedure is available but mainly useless (because the procedure is
directly callable); calling a function can be used to obtain the
side-effects that the function may produce, without the need to assign
some result value to dummy variables
now the line number of a Library SUB/DEF in the error string is not
referring to the total source but is local to the SUB
solved a bug signaled by Bruce, for errors in string/numeric error
functions ESM, ESL, ERR$ etc; actually, an error in the number parser
was generated in case those functions were used with an empty argument,
and that caused an infinite loop
solved a bug in INKEY$ that didn't reset the inner string if overtime
(signaled by Bruce)
solved a bug in OPEN (a bug revealed by Ian) that in case of multiple
(really big) file open/close processes, could generate an error (in
practice the highly frequent processes of open/close caused at some
point that the file couldn't be really opened). This was a bug I
couldn't spot in a million years if Ian didn't force me to look at the
code!
solved a bug in ERASE that didn't retain the variable order
many other minor changes were applied. The manual is updated, so check
it for further notices.
Version 1.0.alpha (build 3) (January 14, 2018)
Infinite thanks to Bruce Axtens, who, for this
version, discovered many bugs (oh my!) and push me to add new features!.
He also put tbas code to the Rosetta code site. Well done!
Bruce, Ian and I are the tbas team!
You can download tbas Alpha 3 sources here.
You can download tbas Alpha 3 executable for Windows, compiled by Bruce
Axtens, here.
changelog for version Alpha 3
solved a bug in SUB and
multi-lines DEF that
prevented the recursion (this bug was signaled by Bruce).
solved a bug in DEFFN
which didn't work in case the DEFFN
had no variables like in DEFFNA=... Probably
this bug is due to later patches to the code, not restored before
uploading....(signaled by BA). This required the removing of error
200.
added to DEF FN functions
the possibility to accept strings and string variables as arguments;
this, though, doesn't change the numerical nature of DEFFN,
so that the FNX is always a
number, but in all, if strings are necessary in the body, they can now
be used (suggested by Bruce).
solved a bug in LIBRARY
that reset the DATA
indices during library loading (signaled by Bruce).
added the COMMAND$
system string to return the console arguments
after file name (suggested by Bruce).
added the statements COLOR
(to change the output text color and or invert), LOCATE
(to position the cursor anywhere in the screen) and CLS
(to clear the screen using monitor codes); the last is a synonym of CLEAR,
but CLEAR uses shell commands
to reset the screen and does not reset the colors, while CLS
uses monitor codes and resets the colors to
default.
added to MAT READ
and MAT INPUT the ability to
redimension matrices (suggested by BA)
increased the memory space for
variables and SUBs nesting.
modified some error messages
Updated the make manual and the make
pdfmanual processes in the makefile, and updated the man page. Also
corrected some formatting errors in the manual.
modified makefile to make tbas
compilable under different systems.
Version 1.0.alpha (September 22, 2017)
Infinite thanks to Ian Jones
, a friend and a great tester, who compiled and ran tbas an incredibly
high number of times, finding all sort of errors in the listings. Ian
and I are the tbas team!
I wait for your impressions and bugs. Send me
your suggestions, your considerations, your corrections; even send me
your working BASIC programs for tbas,
all commented and completed with your own name and data: they will be
part of the next package, of course.