ThinBasic

Last updated
ThinBasic
ThinBasic Logo.PNG
Developer Eros Olmi
Stable release
v1.12 / January 28, 2024;53 days ago (2024-01-28)
OS Windows
License Freeware / Proprietary
Website www.thinbasic.com
Dialects
BASIC
Influenced by
Powerbasic

thinBasic is a BASIC-like computer programming language interpreter [1] with a central core engine architecture surrounded by many specialized modules. Although originally designed mainly for computer automation, thanks to its modular structure it can be used for wide range of tasks.

Contents

Main features

Syntax

As the name suggests, the biggest influence on the syntax of this language was the BASIC language. But, unlike traditional BASICs, as known from the 8-bit era, thinBASIC does differ in few important points.

For example, it requires the programmer to declare variables and it does not feature the infamous GOTO and GOSUB statements. Some aspects of the syntax are even inspired in non-BASIC languages, such as C/C++. [2] Thanks to this, thinBASIC optionally allows use of implicit line continuation, simplified addition, subtraction, multiplication and division operators, shortened variable declaration and initialization:

' Traditional syntax allowed in thinBASICDIMaASINTEGER' a is initialized to 0a=1' a now contains 1a=a+1' a now contains 2' C/C++ inspired syntax allowed in thinBASICINTEGERa=1' a is initialized to 1a+=1' a now contains 2' New syntax introduced in 1.9.10.0 allows defining type from string expressionSTRINGsType="INTEGER"DIMaLIKEsType

Another source of inspiration are the modern versions of BASIC, such as Visual Basic or PowerBASIC.

ThinBASIC does offer the main flow control statements, such as SELECT CASE, IF ... THEN/ELSEIF/ELSE/END IF, loops (infinite, conditional, FOR, WHILE/WEND, DO/LOOP WHILE ..., DO/LOOP UNTIL ...) and it also puts very strong effort on providing wide range of built-in functions for number crunching and especially string handling.

Variables and data types

ThinBASIC supports a wide range of numeric [3] and string [4] data types.

IntegerFloating pointStringOther
BYTESINGLESTRING VARIANT
WORDDOUBLESTRING * n GUID
DWORDCURRENCYASCIIZ * nBOOLEAN
INTEGEREXTENDED, EXTUDT (user-defined type)
LONGUNIONS
QUADiDispatch

Besides those mentioned in the table above, a programmer can define pointers, user-defined types and unions.

The special features related to user-defined types in thinBASIC are: [5]

Variables can be defined in global, local or static scope. ThinBASIC supports arrays of up to three dimensions.

Modules

The elemental functionality of the language is provided by the so-called Core module, which is loaded by default, and takes care of parsing too.

Besides the Core module, thinBASIC offers other modules, each covering a specific area of functionality, for example:

Each module is represented by single DLL, with specific structure. This allows the module to contain not just typical functions and procedures, but also for example constants and user-defined types definitions, immediately available for script without need for header file. The only thing needed is to explicitly mention the usage of module in the code – for file handling it would look like:

' This loads the module for useUses"File"' Function File_Load comes from the module, it returns the content of passed file in form of StringStringsBuffer=File_Load("C:\text.txt")

Functions and procedures

To better structure the code, thinBASIC provides the functions and procedures functionality. There is one function with special treatment, called TBMAIN, which is guaranteed to be executed first. It represents the same function as main() function in C programming language, but its use is optional.

A programmer can define custom functions and procedures (called Subs); they can have up to 32 parameters. Both functions and procedures do not need to be declared before use. Parameters can be marked as optional, and they can also be initialized to default values. Each parameter can be specified to be passed by value (default) or by reference.

Uses"Console"' Program body starts in TBMain functionFunctionTBMain()MyFunction(10)' This will print 10 20 30, because unused optional parameters #2 and #3 are initialized to 20 and 30MyFunction(10,3)' This will print 10 3 30, because unused optional parameter #3 is initialized to 30MyFunction(10,3,5)' This will print 10 3 5, because we specify all the parameters, so the defaults are discardedConsole_WaitKeyEndFunction' User defined function with optional parameters with default valuesFunctionMyFunction(aAsNumber,OptionalbAsNumber=20,cAsNumber=30)Console_PrintL(a,b,c)EndFunction

The functions can be called directly, as in the listing above, or by composing their name at run-time.

Binding to third-party APIs

ThinBASIC supports calling functions from third-party DLLs; programmer needs to declare them first to be able to access the functionality.

Thanks to this mechanism, thinBASIC allows using technologies such as OpenGL, OpenCL, [6] XML, ODE and many others.

Code organization

ThinBASIC does not support any form of project files at the moment, but it encourages splitting code to units by providing multiple file extensions for different use:

The main code can reference these files using #include directive, which can use wildcards:

#include"MyDLLWrapper.tBasicI"#include"MyRoutines.tBasicU"#include"dialog_*.tBasicU"' This would include all files matching the wildcard dialog_*.tBasicU, when presentFunctionTBMain()' -- Main code goes here, and can use functionality from #included filesEndFunction

Customization

The language can be enhanced by module development using SDK for many languages (PowerBASIC, FreeBASIC, C, MASM).

Documentation

The development team puts strong focus on documentation of the language and on the learning resources. The language itself is documented in extensive help file [7] and the default installation contains tutorial and much example code too.

Various articles on use of thinBASIC have been published in form of ThinBasic Journal and on the homepage of the programming language as well (please see external links).

Integrated development environment (IDE)

thinAir, thinBasic IDE ThinBasic ThinAir IDE.png
thinAir, thinBasic IDE

ThinBASIC comes with own IDE, called thinAir, in the default installation. [8] It offers:


thinAir allows using the debugger as well.
This component is called thinDebug [10] and can be watched on the image linked below.

Code samples

Console program, which asks user about name and then greets him:

' Specifies program will use functions from console moduleuses"Console"' TBMain represents main body of the programfunctionTBMain()' Creates variable to hold user namelocalUserNameasstring' Asks user for the nameConsole_Print("What is your name?: ")' Stores it to variableUserName=Console_ReadLine' If length of username is 0 then no name is specified, else program will say helloiflen(UserName)=0thenConsole_PrintLine("No user name specified...")elseConsole_PrintLine("Hello "+UserName+"!")endif' Waits for any key from user before program endsConsole_WaitKeyendfunction

Pros and cons

ThinBASIC was designed for the Windows platform and this is why it makes a good use of resources provided by this system, such as registry, user interface, work with processes, COM, DLLs. Although interpreted, thinBASIC is considered to have usually fast execution. [11] When the interpreter nature of the language hits the limits, it is possible to perform optimizations using partial JIT compilation. Another strength of the language is a wide range of commands covering various areas of interest and for BASIC traditionally - strong focus on string handling. The language is under continuous development and maintenance. [12]

The fact that thinBASIC is designed for Windows only can be seen as disadvantage as well, for those who seek cross-platform tools. The speed of execution without the use of optimizations is lower compared to output of compilers, thanks to language interpreter nature.

Compatibility

thinBASIC has been developed under Microsoft Windows XP Professional using PowerBASIC, [13] and requires Internet Explorer version 5.50 or above.

Related Research Articles

<span class="mw-page-title-main">Dylan (programming language)</span> Multi-paradigm programming language

Dylan is a multi-paradigm programming language that includes support for functional and object-oriented programming (OOP), and is dynamic and reflective while providing a programming model designed to support generating efficient machine code, including fine-grained control over dynamic and static behaviors. It was created in the early 1990s by a group led by Apple Computer.

VBScript is a deprecated Active Scripting language developed by Microsoft that is modeled on Visual Basic. It allows Microsoft Windows system administrators to generate powerful tools for managing computers without error handling and with subroutines and other advanced programming constructs. It can give the user complete control over many aspects of their computing environment.

<span class="mw-page-title-main">Liberty BASIC</span>

Liberty BASIC (LB) is a commercial computer programming language and integrated development environment (IDE). It has an interpreter, developed in Smalltalk, which recognizes its own dialect of the BASIC programming language. It runs on 16- and 32-bit Windows and OS/2.

<span class="mw-page-title-main">PureBasic</span>

PureBasic is a commercially distributed procedural computer programming language and integrated development environment based on BASIC and developed by Fantaisie Software for Windows, Linux, and macOS. An Amiga version is available, although it has been discontinued and some parts of it are released as open-source. The first public release of PureBasic for Windows was on 17 December 2000. It has been continually updated ever since.

<span class="mw-page-title-main">PowerBASIC</span> Software compiler

PowerBASIC, formerly Turbo Basic, is the brand of several commercial compilers by PowerBASIC Inc. that compile a dialect of the BASIC programming language. There are both MS-DOS and Windows versions, and two kinds of the latter: Console and Windows. The MS-DOS version has a syntax similar to that of QBasic and QuickBASIC. The Windows versions use a BASIC syntax expanded to include many Windows functions, and the statements can be combined with calls to the Windows API.

<span class="mw-page-title-main">Visual Basic (.NET)</span> Object-oriented computer programming language

Visual Basic (VB), originally called Visual Basic .NET (VB.NET), is a multi-paradigm, object-oriented programming language, implemented on .NET, Mono, and the .NET Framework. Microsoft launched VB.NET in 2002 as the successor to its original Visual Basic language, the last version of which was Visual Basic 6.0. Although the ".NET" portion of the name was dropped in 2005, this article uses "Visual Basic [.NET]" to refer to all Visual Basic languages released since 2002, in order to distinguish between them and the classic Visual Basic. Along with C# and F#, it is one of the three main languages targeting the .NET ecosystem. Microsoft updated its VB language strategy on 6 February 2023, stating that VB is a stable language now and Microsoft will keep maintaining it.

The C preprocessor is the macro preprocessor for several computer programming languages, such as C, Objective-C, C++, and a variety of Fortran languages. The preprocessor provides inclusion of header files, macro expansions, conditional compilation, and line control.

<span class="mw-page-title-main">Comparison of command shells</span>

A command shell is a command-line interface to interact with and manipulate a computer's operating system.

<span class="mw-page-title-main">AutoIt</span>

AutoIt is a freeware programming language for Microsoft Windows. In its earliest release, it was primarily intended to create automation scripts for Microsoft Windows programs but has since grown to include enhancements in both programming language design and overall functionality.

Exception handling syntax is the set of keywords and/or structures provided by a computer programming language to allow exception handling, which separates the handling of errors that arise during a program's operation from its ordinary processes. Syntax for exception handling varies between programming languages, partly to cover semantic differences but largely to fit into each language's overall syntactic structure. Some languages do not call the relevant concept "exception handling"; others may not have direct facilities for it, but can still provide means to implement it.

Platform Invocation Services, commonly referred to as P/Invoke, is a feature of Common Language Infrastructure implementations, like Microsoft's Common Language Runtime, that enables managed code to call native code.

TypeScript is a free and open-source high-level programming language developed by Microsoft that adds static typing with optional type annotations to JavaScript. It is designed for the development of large applications and transpiles to JavaScript. Because TypeScript is a superset of JavaScript, all JavaScript programs are syntactically valid TypeScript, but they can fail to type-check for safety reasons.

<span class="mw-page-title-main">Vala (programming language)</span> Programming language

Vala is an object-oriented programming language with a self-hosting compiler that generates C code and uses the GObject system.

<span class="mw-page-title-main">Cosmos (operating system)</span> Toolkit for building GUI and command-line based operating systems

C# Open Source Managed Operating System (Cosmos) is a toolkit for building GUI and command-line based operating systems, written mostly in the programming language C# and small amounts of a high-level assembly language named X#. Cosmos is a backronym, in that the acronym was chosen before the meaning. It is open-source software released under a BSD license.

Basic4ppc is a programming language originally for Pocket PC handheld computers running Windows Mobile operating system, by Anywhere Software. Since 2014, B4x was renamed, and currently, 2023, supports multiple devices and their OS, including desktop and mobile solutions with development adaptions for these environments. The language is based on a BASIC-like syntax, taking advantage of Microsoft's .NET technology, to allow additional libraries, graphical user interface design of windows forms, rapid application development (RAD), and .NET framework compatible compilation. The language implements a unique way of adding objects to a program without being object-oriented. Its advantages are simplicity, development pace and the integration with .NET framework. A special version of the integrated development environment (IDE) allows developing straight onto the Windows Mobile device or. With the demise of Windows Mobile operating system and the devices running it Basic4PPC came to the end of its life in about 2012. For owners of Basic4PPC it remains a useful Windows-desktop BASIC compiler as it runs code directly in the Windows environment and it can compile a project to a Windows 'exe' file for use as a Windows program.

<span class="mw-page-title-main">Command-line interface</span> Computer interface that uses text

A command-line interface (CLI) is a means of interacting with a computer program by inputting lines of text called command-lines. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user-friendly alternative to the non-interactive interface available with punched cards.

Nemerle is a general-purpose, high-level, statically typed programming language designed for platforms using the Common Language Infrastructure (.NET/Mono). It offers functional, object-oriented, aspect-oriented, reflective and imperative features. It has a simple C#-like syntax and a powerful metaprogramming system.

Proteus is a fully functional, procedural programming language created in 1998 by Simone Zanella. Proteus incorporates many functions derived from several other languages: C, BASIC, Assembly, Clipper/dBase; it is especially versatile in dealing with strings, having hundreds of dedicated functions; this makes it one of the richest languages for text manipulation.

Swift is a high-level general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. and the open-source community. Swift compiles to machine code, as it is an LLVM-based compiler. Swift was first released in June 2014, and the Swift toolchain has shipped in Xcode since version 6, released in 2014.

<span class="mw-page-title-main">Nim (programming language)</span> Programming language

Nim is a general-purpose, multi-paradigm, statically typed, compiled high-level systems programming language, designed and developed by a team around Andreas Rumpf. Nim is designed to be "efficient, expressive, and elegant", supporting metaprogramming, functional, message passing, procedural, and object-oriented programming styles by providing several features such as compile time code generation, algebraic data types, a foreign function interface (FFI) with C, C++, Objective-C, and JavaScript, and supporting compiling to those same languages as intermediate representations.

References

  1. Olmi, E. ThinBASIC Help Manual. Introducing thinBASIC. Retrieved 2011-09-21
  2. basic.mindteq.com. THINBASIC. Retrieved 2013-02-15
  3. Olmi, E. ThinBASIC Help Manual. Numeric variables. Retrieved 2011-09-21
  4. Olmi, E. ThinBASIC Help Manual. String variables. Retrieved 2011-09-21
  5. Olmi, E. ThinBASIC Help Manual. Type. Retrieved 2011-09-21
  6. SCHREIBER, P.; ONDROUŠEK, V.; VĚCHET, S.; KREJSA, J.. Parallelizing the Precomputed Scan Matching Method for Graphics Card processing. Proceedings of the 1st international conference Robotics in Education, RiE2010. 2010. p. 202
  7. Olmi, E. ThinBASIC Help Manual. How to use. Retrieved 2011-09-21
  8. Olmi, E. ThinBASIC Help Manual. How to use. Retrieved 2011-09-21
  9. basic.mindteq.com. THINBASIC. Retrieved 2013-02-15
  10. Olmi, E. ThinBASIC Help Manual. thinTools/thinDebug. Retrieved 2011-09-21
  11. basic.mindteq.com. THINBASIC. Retrieved 2013-02-15
  12. Olmi, E. ThinBASIC Help Manual. What's new. Retrieved 2017-07-29
  13. http://www.powerbasic.com. Built with PowerBASIC!. Retrieved 2011-09-21