FutureBASIC

FutureBASIC

Infobox programming language

name = FutureBASIC
paradigm = Procedural
developer = Staz Software, FBtoC
latest_release_version = FB4/FBtoC 1.0
2008-01-01
typing =
implementations =
dialects =
influenced_by =
operating_system = Mac OS
license = Freeware
website = http://www.stazsoftware.com/futurebasic/

FutureBASIC is a free, 32-bit BASIC compiler for Apple Inc.'s Macintosh.

It consists of a complete integrated development environment (IDE), editor, project manager, debugger, profiler and compiler for both PowerPC and Motorola 68000 microprocessors. Since 1 January 2008, the package also contains a cross compiler, FBtoC, that converts the FutureBASIC syntax to C and automatically calls Apple's GNU Compiler Collection (gcc). FutureBASIC supports access to Mac OS library calls. The integrated compiler is extremely efficient: on a Dual 1 gig G4, it will zip through 850,000 characters (850 pages) of source code per second. The resulting code is tight and also very fast, near C speeds. Unlike other BASIC language implementations there is not a p-code stage; the applications are standalone programs, "double-clickable", and do not require a separate interpreter.

History of FutureBASIC

FB began life in the mid-1980sref|BasicWar as ZBasic, which was created by Andrew Gariepy and envisioned as a cross-platform development system. Before long, the cross-platform aspects were dropped in favor of focusing on Macintosh development. ZBasic acquired a devoted following of developers who praised its ease of use and the tight, fast code produced by the compiler (a legendary labor involving extensive use of hand-built 68K assembly language code). In 1992 and as the next major step after ZBasic version 5ref|ZBasic5, Zedcor Inc., the company of the Gariepy brothers Andy, Mike, Peter and friends based in Tucson, Arizona presented FutureBASIC (later called FBI).ref|FBI In 1995 Staz Software,ref|Staz_Software led by Chris Stasny, acquired the rights to market FutureBASIC. Chris Stasny started this business with an upgraded version, namely FBII,ref|FBII and with his own development, the Program Generatorref|PG_PRO (PG PRO), a CASE tool.

The transition from 68k to PowerPC central processing unit (CPU) was a lengthy process that involved a complete rewrite of the editor by Chris Stasny and an adaptation of the compiler by Andy Gariepy. This was undertaken during [http://www.apple-history.nl/h6.html Apple's darkest days] when the further existence of the Mac and Apple itself was in the news every week. The result of their efforts, a dramatically enhanced IDE called FB^3ref|FB3, was released in September 1999ref|local, featuring among many other things a separate compiler application, various open, hence modifiable runtimes,ref|Runtime inline PPC assembly, a simplified access to the Macintosh Toolbox Application Programming Interface (API), as well as an expanded library of built-in functions. Major update releases introduced a full-featured Appearance Compliantref|Appearance_runtime runtime written by Robert Purves and the Carbon compliance of generated applications. Once completely carbonized to run natively on the Mac OS X, the FutureBASIC Integrated Development Environment (FB IDE) was called FB4 and first released in July 2004.

Based in Diamondhead, Mississippi, Staz Software was severely hit by Hurricane Katrina in August 2005 and development pace was slowed at a time when major effort was required to keep the IDE up to date with Apple's evolution towards the Intel-based Macintosh. More recently, an independent team of volunteer FB programmers developed a cross-compiler (FBtoC) that allows FB to generate applications as Universal Binaries through the use of the open source GCC compiler which is included with each copy of Apple's Mac OS X system software. On January 1 2008, Staz Software announced that FB4 would henceforth be freeware and FBtoC 1.0 was made available.ref|FBtoC

Processor and Operating System Support

FutureBASIC continues to support several versions of Mac OS

* FutureBASIC System 6 to System 7 on Motorola 68000 processors
* FutureBASIC II (FB2) System 6 to Mac OS 9 on Motorola 68000 processors
* FutureBASIC 3 (FB^3) System 7 to Mac OS X on 68000 and PPC processors
* FutureBASIC 4 (FB4) System 7 to Mac OS X Carbon on 68000 and PPC processors
* FB4 / FBtoC System 7 to Mac OS X Carbon on 68000, PPC and Intel processors.System requirements to create universal binaries with FBtoC: Mac OS X v10.4 or higher, GCC 4.0 or higher, and the Cross-development SDKs must be installed.)

yntax

FutureBASIC syntax supports procedural, modular styles of programming using function calls and local variables.

Program flow & structural blocks

User-defined functions (a.k.a. LOCAL FNs in FutureBASIC) are much like C or Pascal functions.
* They can also be totally insulated from the main program (LOCAL MODE statement);
* they allow recursion;
* they can be called dynamically at runtime (DEF FN USING statement);
* called automatically by FutureBASIC built-in event vectors (ON EVENT FN statement);
* used as cooperative threaded functions (THREADBEGIN statement).

Specific structures (ENTERPROC/EXITPROC) are used for callback procedures when calling the Macintosh Toolbox.

The language provides the programmer with a complete set of vectors for event-driven applications, such as ON MENU, ON MOUSE, ON DIALOG, ON APPLEEVENT, ON EDIT, ON TIMER, etc.

Other structured keywords include conditional blocks such as:
* LONG IF .... XELSE ... END IF
* DO .... UNTIL
* WHILE ... WEND
* SELECT ... CASE... CASE ELSE ... END SELECT
* FOR ... NEXT

Old style BASIC language with GOTO, GOSUB/RETURN, line numbers and labels is also supported for educational purposes.

An example of a simple program to input a number and display "Hello World" is given below

//Example FutureBASIC program

dim i,num,a$ //These are our variables

window 1 //open standard windowinput "Number of loops "; a$ //BASIC input from usernum=val(a$) //convert text to numberlong if num>0 //Structured IF for i = 1 to num //BASIC loop print "hello world" //output text next i //end of loop xelse //Otherwise print "Not today" //no number enteredend if

do //Wait until Apple-Q HandleEventsuntil ( gFBQuit ) //so that we can see results

Data Types

FutureBASIC supports complex data types include single and double precision floating points, double length integers, arrays, strings and records (similar to struct in C). Of note is the DYNAMIC array structures (size of memory footprint grows only when used) including DYNAMIC string arrays called INDEX$ and "container" variables which can perform string-like operations on data streams up to 2Gb in size.

C and Pascal borrowed coding styles

Commenting in the code is substantial allowing REMark statements, and C style /* remark */ statements, and images within the source code. Sections of code can be bookmarked for easy reference.

Other alternate syntax borrowed from C allows the use of operators such as ++ -- = != += -= || &&

Characters in Pascal strings are accessible much like items of an array: a$ [0] (length byte); a$ [1] (first character in string a$).

While the FutureBASIC language still supports old style variable typing with suffix identifiers, it provides a modern alternative with the as clause:dim b as byte; dim s as short, dim l as long; etc.

Runtimes

Due to the open nature of its runtime files, the FutureBASIC language can be enhanced with user routines, altered with the OVERRIDE directive or even fixed in case of bugs that went undetected before release. The main runtimes are:
* "Appearance Compliant" runtime: recommended runtime for modern full-featured applications.
* "Console" runtime: mostly used for testing snippets of code or performing calculation. It provides a minimal user interface.
* "Standard BASIC" runtime: present for the support of legacy code, mainly inherited from the 68K era of the Macintosh.
* "Toolbox" runtime: almost free of BASIC keywords; the programmer must rely exclusively upon Toolbox functions and procedures to create applications.

Bridges to other languages

* The compiler allows inline 68K and PPC assembly. Examples (from a runtime file)Calling 68K assembly (unavailable in FBtoC):


#if cpu68Kruntime "_MovePascalStr"beginassem move.l (SP)+,D1;Return Address move.l (SP)+,A1 ;Dest Address move.l (SP)+,A0;Src Address moveq #0,D0 move.b (A0),D0;Byte Countmlp1 move.b (A0)+,(A1)+ dbra D0,mlp1 move.l D1,A0 jmp (a0)endassemreturn'MacsBug Labelend fn
#endif
Calling PPC assembly (unavailable in FBtoC):

#if cpuPPClocal fn SysMoveString( Src&, Dst& )beginassem lhz r5,0(r3); len<<8 + 1st str byte srawi. r0,r5,9; len/2 sth r5,(r4) mtspr ctr,r0 beq sysMoveString ; skip loop if len/2 = 0sysMoveStringLoop lhzu r0,2(r3) sthu r0,2(r4) bc 16,0,sysMoveStringLoop ; bdnzsysMoveStringendassemend fn
#endif

* AppleScript scripts can be assembled with FutureBASIC statements then executed on the fly by a running application. Example:
route _toAppleScript
print "return the path to me as string"
route _toScreen



long if usr ApplescriptRun( message$ ) = _noErr
 print message$
end if


* On Mac OS X, FutureBASIC allows to trigger UNIX commands. Example:
// print a calendar for 2008

open "UNIX",1,"cal 2008"
dim a$



do
 line input #1,a$
 print a$
until eof(1)

close 1


* FBtoC only allows inline C code for the Intel-Mac compilation. Example:
missing example

Limitation

* Missing CASE/RAD toolThe development of PG PRO was stopped on the road to Mac OS X. While it is still possible to create applications that run on 68K and PPC including Carbon with that CASE tool, its use is highly discouraged. Programmers should use instead Apple's Interface Builder to handle the user interface of their applications.
* Missing runtime for object oriented programmingIn the early 2000s, the CD that was delivered with the FB releases used to contain an experimental Object Oriented runtime; an interesting new paradigm for the FB programmers. However this runtime was withdrawn without explanation.
* No 64bit supportFutureBASIC doesn't support natively 64bit variable types. There are programming techniques to mimic this feature.
* Compilation for the Macintosh platform onlyFutureBASIC supports Macintosh Motorola 68000, PPC and Intel architectures but does not compile for or upon any Microsoft Windows operating systems.

References

#An history of Basic wars on the Mac platform by Jonathan Hoyle for [http://www.maccompanion.com/archives/May2006/Columns/AccordingtoHoyle.htm MacCompanion]
#ZBasic 5 reviewed by Dave Kelly for [http://www.mactech.com/articles/mactech/Vol.05/05.02/ZBASIC5.0/index.html MacTech magazine]
#FBI introduced major enhancements to the BASIC language, encouraging the developers to use named constants and local functions instead of subroutines for better structured programs and re-usable code.
#Home of [http://stazsoftware.com Staz Software,inc.]
#FBII was 32bit-clean and could run from Mac 128 to G5-based Macintosh in emulated mode.
#Program Generator is a Rapid application development tool that is flexible enough to build sophisticated applications quickly for the Macintosh pre-Mac OS X environments. For Mac OS X, Appearance compliant programs onwards, FutureBASIC uses Apple's Interface Builder.
# pronounced FB cubed.
# A week later the European edition was released which included English, [http://www.tevac.com/futurebasic/ Italian] , German (now discontinued) and [http://pixmix.com/euro/fr/ French] language versions. There is also a [http://kappalab.com/futurebasic/index.html Japanese] language edition.
#Starting with FB^3, a runtime consists of include files written in FutureBASIC that are compiled along with the source code written by the programmer. It contains various declarations for structures, constants, global variables, resources, functions and procedures that constitute the FutureBASIC language. The main runtimes are: "Standard BASIC", "Appearance Compliant" and "Mac Toolbox".
#The "Appearance Compliant" runtime allows access to most of the features of Apple's "Appearance Manager".
# [http://www.4toc.com/fb4/ Welcome to the FBtoC Project and FutureBASIC Freeware]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • FutureBASIC — est un environnement de développement gratuit en BASIC dédié au Macintosh d Apple, Inc. FutureBASIC Auteur Staz Software, FBtoC Dernière ver …   Wikipédia en Français

  • List of BASIC dialects — This article gives an alphabetical list of BASIC dialects mdash;a flat list of interpreted and compiled variants of the BASIC programming language. The dialects platform(s) (that is, the computer models and operating systems) are given in… …   Wikipedia

  • BASIC — This article is about the programming language. For the think tank, see British American Security Information Council. For the group of countries, see BASIC countries. For other uses, see Basic (disambiguation). BASIC Screenshot of Atari BASIC,… …   Wikipedia

  • GW-BASIC — Appeared in 1983 Developer Microsoft (for Compaq) Stable release 3.23 (1988) …   Wikipedia

  • QuickBASIC — Not to be confused with QBASIC. QuickBASIC The opening screen of QuickBasic Developer(s) Microsoft Corporation Initial release 1985 …   Wikipedia

  • XBasic — is a variant of the BASIC programming language that was developed in the late 1980s for the Motorola 88000 CPU and Unix by Max Reason. In the early 1990s it was ported to Windows and Linux, and since 1999 it has been available as open source… …   Wikipedia

  • Microsoft BASIC — Appeared in 1975 (cf. Altair BASIC) Designed by Microsoft Developer Microsoft Stable release cf. Visual Basic .NET (2010) Microsoft BASIC was the foundation product of the Microsoft …   Wikipedia

  • Visual Basic .NET — Paradigm(s) Structured, imperative, object oriented and declarative Appeared in 2001 Designed by Micro …   Wikipedia

  • StarOffice Basic — (also known as StarBasic and OOoBasic) is a dialect of BASIC that is included with the OpenOffice.org and StarOffice office suites. Contents 1 Example 2 See also 3 External links …   Wikipedia

  • Commodore BASIC — Commodore BASIC, also known as PET BASIC, is the dialect of the BASIC programming language used in Commodore International s 8 bit home computer line, stretching from the PET of 1977 to the C128 of 1985. The core was based on 6502 Microsoft BASIC …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”