thinBasic

From Wikipedia, the free encyclopedia


ThinBasic
ThinBasic_Logo
Developer Eros Olmi & Roberto Bianchi
Latest release v1.6.0.9/ June 09 - 2008
Dialects BASIC
OS Windows
License Freeware
Website http://www.thinbasic.com

thinBasic is a BASIC-like computer programming language interpreter, specifically written for computer automation. As the project continues, it can be used for a wide range of tasks.

Contents

[edit] Features

  • Rich set of about 1300 predefined keywords, provided by modules
  • User-defined functions with local, static or global variable declaration can take up to 32 parameters
  • Wide range of data types:
    • Dynamic ( STRING ) and fixed length ( STRING * n, ASCIIZ * n) strings
    • Integer datatypes: BOOLEAN, BYTE, WORD, INTEGER, DWORD, LONG, QUAD
    • Floating point datatypes: SINGLE, DOUBLE, EXT, CURRENCY
    • Other: VARIANT, GUID
  • User defined types
  • All main flow control statements: SELECT CASE, IF ... THEN/ELSEIF/ELSE/END IF, loops (DO/LOOP, WHILE/WEND, FOR/NEXT, ...), ...
  • Comes with IDE: thinAir
  • Optional script obfuscation
  • Creation of independent executable from script, directly from IDE
  • Modules for extending keywords and functionality
    • User interface
    • Console
    • File handling
    • Formula evaluation
    • 3D graphics
    • Game devices input
    • Script self-compilation
    • Internet communications
    • Statistics
    • Tokenizer
    • Printing
    • Machine code and assembler
    • ...
  • Module development using SDK for many languages ( PowerBASIC, FreeBASIC, IBASIC, C, MASM, ... )

[edit] Code samples

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

' Specifies program will use functions from console module
USES "Console"
 
' Creates global variable to hold user name
GLOBAL 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

Comparison of traditional and special technique to call functions:

' Use File module for handling files
USES "FILE"
 
' Assign file name to variable, notice assignment can be done at time of declaring variable
GLOBAL MyFile AS STRING = "c:\File.txt"
GLOBAL ReturnValue AS LONG
 
' Determine file extension, convert to upper case
' and according to the type call appropriate function
SELECT CASE UCASE$(FILE_PATHSPLIT(MyFile, %Path_Ext))
  CASE "TXT"
    ReturnValue = Load_Txt(MyFile)
 
  CASE "BMP"
    ReturnValue = Load_BMP(MyFile)
 
END SELECT
 
FUNCTION Load_TXT( fName as string ) AS LONG
 
  ' Code to load TXT file here
 
END FUNCTION
 
FUNCTION Load_BMP( fName as string ) AS LONG
 
  ' Code to load BMP file here
 
END FUNCTION
' Use File module for handling files
USES "FILE"
 
' Assign file name to variable, notice assignment can be done at time of declaring variable
GLOBAL MyFile AS STRING = "c:\File.txt"
GLOBAL ReturnValue AS LONG
 
' Functions are named Load_<fileExtension>, so we can determine
' the function name we need at run time and save some lines of code
CALL "Load_"+FILE_PATHSPLIT(MyFile, %Path_Ext) ( MyFile ) To ReturnValue
 
FUNCTION Load_TXT( fName as string ) AS LONG
 
  ' Code to load TXT file here
 
END FUNCTION
 
FUNCTION Load_BMP( fName as string ) AS LONG
 
  ' Code to load BMP file here
 
END FUNCTION

[edit] Compatibility

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

[edit] External links

[edit] See also