thinBasic is a
BASIC
BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College ...
-like
computer programming
Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programming involves tasks such as anal ...
language
Language is a structured system of communication. The structure of a language is its grammar and the free components are its vocabulary. Languages are the primary means by which humans communicate, and may be conveyed through a variety of ...
interpreter 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.
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++. 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 thinBASIC
DIM a AS INTEGER ' a is initialized to 0
a = 1 ' a now contains 1
a = a + 1 ' a now contains 2
' C/C++ inspired syntax allowed in thinBASIC
INTEGER a = 1 ' a is initialized to 1
a += 1 ' a now contains 2
' New syntax introduced in 1.9.10.0 allows defining type from string expression
STRING sType = "INTEGER"
DIM a LIKE sType
Another source of inspiration are the modern versions of BASIC, such as
Visual Basic Visual Basic is a name for a family of programming languages from Microsoft. It may refer to:
* Visual Basic .NET (now simply referred to as "Visual Basic"), the current version of Visual Basic launched in 2002 which runs on .NET
* Visual Basic (c ...
or
PowerBASIC
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 Wind ...
.
ThinBASIC does offer the main flow control statements, such as SELECT CASE, IF ... THEN/ELSEIF/ELSE/END IF, loops (
infinite
Infinite may refer to:
Mathematics
*Infinite set, a set that is not a finite set
*Infinity, an abstract concept describing something without any limit
Music
*Infinite (group)
Infinite ( ko, 인피니트; stylized as INFINITE) is a South Ko ...
,
conditional
Conditional (if then) may refer to:
* Causal conditional, if X then Y, where X is a cause of Y
* Conditional probability, the probability of an event A given that another event B has occurred
*Conditional proof, in logic: a proof that asserts a ...
,
FOR
For or FOR may refer to:
English language
*For, a preposition
*For, a complementizer
*For, a grammatical conjunction
Science and technology
* Fornax, a constellation
* for loop, a programming language statement
* Frame of reference, in physics ...
, 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 and string data types.
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:
* the possibility to inherit members from one or more other user-defined types
* static members (members whose value is shared among all variables of given UDT)
* dynamic strings
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:
* GUI creation
* console handling
* file handling
* 3D graphics
* networking
* ...
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 use
Uses "File"
' Function File_Load comes from the module, it returns the content of passed file in form of String
String sBuffer = 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 function
Function TBMain()
MyFunction(10) ' This will print 10 20 30, because unused optional parameters #2 and #3 are initialized to 20 and 30
MyFunction(10, 3) ' This will print 10 3 30, because unused optional parameter #3 is initialized to 30
MyFunction(10, 3, 5) ' This will print 10 3 5, because we specify all the parameters, so the defaults are discarded
Console_WaitKey
End Function
' User defined function with optional parameters with default values
Function MyFunction( a As Number, Optional b As Number = 20, c As Number = 30)
Console_PrintL(a, b, c)
End Function
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
OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve ha ...
,
OpenCL
OpenCL (Open Computing Language) is a framework for writing programs that execute across heterogeneous platforms consisting of central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), field-prog ...
,
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. ...
,
ODE
An ode (from grc, ᾠδή, ōdḗ) is a type of lyric poetry. Odes are elaborately structured poems praising or glorifying an event or individual, describing nature intellectually as well as emotionally. A classic ode is structured in three majo ...
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:
* .tBasic - main code
* .tBasicI - include file, containing declaration of functions from 3rd party DLLs for example
* .tBasicU - code unit containing auxiliary routines
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 present
Function TBMain()
' -- Main code goes here, and can use functionality from #included files
End Function
Customization
The language can be enhanced by module development using
SDK for many languages (
PowerBASIC
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 Wind ...
,
FreeBASIC
FreeBASIC is a free and open source multiplatform compiler and programming language based on BASIC licensed under the GNU GPL for Microsoft Windows, protected-mode MS-DOS ( DOS extender), Linux, FreeBSD and Xbox. The Xbox version is no lon ...
,
C,
MASM
The Microsoft Macro Assembler (MASM) is an x86 assembler that uses the Intel syntax for MS-DOS and Microsoft Windows. Beginning with MASM 8.0, there are two versions of the assembler: One for 16-bit & 32-bit assembly sources, and another (ML64 ...
).
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 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)
ThinBASIC comes with own IDE, called thinAir, in the default installation.
It offers:
* Customizable
syntax highlighting
Syntax highlighting is a feature of text editors that are used for programming, scripting, or markup languages, such as HTML. The feature displays text, especially source code, in different colours and fonts according to the category of terms. ...
* Code templates
* Multiple source files opened at once in tabs
* Ability to view one source using multiple views
* Optional script obfuscation
* Creation of independent executable from the script
* Access to the help file
thinAir allows using the debugger as well.
This component is called thinDebug and can be watched on the image linked below.
thinDebug, thinBasic Debugger
Code samples
Console program, which asks user about name and then greets him:
' Specifies program will use functions from console module
uses "Console"
' TBMain represents main body of the program
function TBMain()
' Creates variable to hold user name
local UserName as string
' Asks user for the name
Console_Print("What is your name?: ")
' Stores it to variable
UserName = Console_ReadLine
' If length of username is 0 then no name is specified, else program will say hello
if len(UserName) = 0 then
Console_PrintLine("No user name specified...")
else
Console_PrintLine("Hello " + UserName + "!")
end if
' Waits for any key from user before program ends
Console_WaitKey
end function
Pros and cons
ThinBASIC was designed for the
Windows
Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for ...
platform and this is why it makes a good use of resources provided by this system, such as
registry Registry may refer to:
Computing
* Container registry, an operating-system-level virtualization registry
* Domain name registry, a database of top-level internet domain names
* Local Internet registry
* Metadata registry, information system for re ...
, user interface, work with processes,
COM
Com or COM may refer to:
Computing
* COM (hardware interface), a serial port interface on IBM PC-compatible computers
* COM file, or .com file, short for "command", a file extension for an executable file in MS-DOS
* .com, an Internet top-level d ...
,
DLLs. Although interpreted, thinBASIC is considered to have usually fast execution. 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.
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
In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
, thanks to language
interpreter nature.
Compatibility
thinBASIC has been developed under
Microsoft Windows XP Professional using
PowerBASIC
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 Wind ...
,
[http://www.powerbasic.com]
Built with PowerBASIC!
Retrieved 2011-09-21 and requires
Internet Explorer
Internet Explorer (formerly Microsoft Internet Explorer and Windows Internet Explorer, commonly abbreviated IE or MSIE) is a series of graphical user interface, graphical web browsers developed by Microsoft which was used in the Microsoft Wind ...
version 5.50 or above.
* Extensively tested: Windows
2000 and Server,
XP,
Vista
Vista usually refers to a distant view.
Vista may also refer to:
Software
*Windows Vista, the line of Microsoft Windows client operating systems released in 2006 and 2007
* VistA, (Veterans Health Information Systems and Technology Architecture) ...
,
Windows 7
Windows 7 is a major release of the Windows NT operating system developed by Microsoft. It was released to manufacturing on July 22, 2009, and became generally available on October 22, 2009. It is the successor to Windows Vista, released nearl ...
,
Server 2003
Server may refer to:
Computing
*Server (computing), a computer program or a device that provides functionality for other programs or devices, called clients
Role
* Waiting staff, those who work at a restaurant or a bar attending customers and su ...
,
Windows 8
Windows 8 is a major release of the Windows NT operating system developed by Microsoft. It was released to manufacturing on August 1, 2012; it was subsequently made available for download via MSDN and TechNet on August 15, 2012, and later to ...
,
Windows 10
Windows 10 is a major release of Microsoft's Windows NT operating system. It is the direct successor to Windows 8.1, which was released nearly two years earlier. It was released to manufacturing on July 15, 2015, and later to retail on ...
* Partly supported: Windows
98 SE,
Me
* Unsupported:
Windows 95
Windows 95 is a consumer-oriented operating system developed by Microsoft as part of its Windows 9x family of operating systems. The first operating system in the 9x family, it is the successor to Windows 3.1x, and was released to manufactu ...
References
External links
Official web siteCommunity forumDownload pagethinAir, thinBasic official IDEthinDebug, thinBasic DebuggerGraphics tutorialsthinBASIC Adventure BuilderPCOPY! Issue #40 November 16, 2007, About ThinBasic, Eros Olmi.
PCOPY! Issue #50 March 15, 2007, 3D graphics in ThinBASIC, Petr Schreiber.
ThinBasic Journal #1 July 5, 2008, PDF
ThinBasic Journal #2 November 26, 2008, PDF
MovieFX: Combining photo with 3D object September 1, 2010
MovieFX: Blending based bokeh January 1, 2011
ThinBasic review at basics.mindteq.com
{{BASIC
Programming languages
BASIC programming language family