FutureBASIC

FutureBasic
Paradigm Procedural
Developer Staz Software, FBtoC team
Stable release FBtoC v5.4.4
February 14, 2010 (2010-02-14)
OS Mac OS
License Freeware
Website 4toc.com/fb/index.htm

FutureBasic is a free BASIC compiler for Apple Inc.'s Macintosh.

It consists of an integrated development environment (IDE), editor, project manager, etc. for both PowerPC and Intel microprocessors. Since 1 January 2008, the package contains a translator, FBtoC, that converts the FutureBasic syntax to C and automatically calls Apple's GNU Compiler Collection (gcc). No knowledge of C is required. FutureBasic supports access to Mac OS library calls.

History

FB began life in the mid-1980s 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 5, Zedcor Inc., the company of the Gariepy brothers Andy, Mike, Peter and friends based in Tucson, Arizona presented FutureBASIC (later called FBI). In 1995 Staz Software, led by Chris Stasny, acquired the rights to market FutureBASIC. Chris Stasny started this business with an upgraded version, namely FBII, and with his own development, the Program Generator (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. The result of their efforts, a dramatically enhanced IDE called FB^3, was released in September 1999, featuring among many other things a separate compiler application, various open, hence modifiable runtimes, 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 Compliant 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 translator (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 FB would henceforth be freeware and FB4 with FBtoC 1.0 was made available.

Processor and operating system support

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.

Syntax

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.

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:

Legacy BASIC language commands such as: GOTO and GOSUB/RETURN with line numbers and labels - while discouraged - are 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 window
input "Number of loops "; a$    //BASIC input from user
num=val(a$)                     //convert text to number
long 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 entered
end if

do                              //Wait until Apple-Q
  HandleEvents
until ( 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. 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.

Bridges to other languages

route _toAppleScript 
print "return the path to me as string" 
route _toScreen  

long if usr ApplescriptRun( message$ ) = _noErr 
  print message$ 
end if
// print a calendar for 2009  
open "UNIX", 1, "cal 2009" 
dim a$

  do
   line input #1, a$
   print a$
 until eof(1)
  close 1
BeginCFunction
// Simple C function to add two integers
long simple_add( long a, long b )
  {
    long sum;
      sum = a + b;
    return (sum);
  }
endC

// Define C function so FB can see it
toolbox fn simple_add ( long a, long b ) = long

// Create little program to add 2 + 2 with the C function

window 1

print fn simple_add ( 2, 2 )

do
HandleEvents
until ( gFBQuit )

Limitations

FutureBasic supports Macintosh PPC and Intel architectures but does not compile on or for any version of Microsoft Windows.

As of January 2010, FBtoC v5.4.4 compiles 64bit commandline binaries, but supports only 32bit Carbon UI APIs).

References

Wikibooks has a book on the topic of: Futurebasic
  1. ^ An history of Basic wars on the Mac platform by Jonathan Hoyle for MacCompanion, Part I MacCompanion, Part II
  2. ^ ZBasic 5 reviewed by Dave Kelly for MacTech magazine
  3. ^ 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.
  4. ^ Home of Staz Software,inc.
  5. ^ FBII was 32bit-clean and could run from Mac 128 to G5-based Macintosh in emulated mode.
  6. ^ 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.
  7. ^ pronounced FB cubed.
  8. ^ A week later the European edition was released which included English, Italian, German (now discontinued) and French language versions. There is also a Japanese language edition.
  9. ^ 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.
  10. ^ The Appearance Compliant runtime allows access to most of the features of Apple's Appearance Manager.
  11. ^ Welcome to the FBtoC Project and FutureBasic Freeware
This article is issued from Wikipedia - version of the Wednesday, March 23, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.