FutureBASIC
Encyclopedia
FutureBasic is a free
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

 BASIC
BASIC
BASIC is a family of general-purpose, high-level programming languages whose design philosophy emphasizes ease of use - the name is an acronym from Beginner's All-purpose Symbolic Instruction Code....

 compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

 for Apple Inc.'s Macintosh
Macintosh
The Macintosh , or Mac, is a series of several lines of personal computers designed, developed, and marketed by Apple Inc. The first Macintosh was introduced by Apple's then-chairman Steve Jobs on January 24, 1984; it was the first commercially successful personal computer to feature a mouse and a...

.

It consists of an integrated development environment
Integrated development environment
An integrated development environment is a software application that provides comprehensive facilities to computer programmers for software development...

 (IDE), editor, project manager, etc. for both PowerPC
PowerPC
PowerPC is a RISC architecture created by the 1991 Apple–IBM–Motorola alliance, known as AIM...

 and Intel microprocessor
Microprocessor
A microprocessor incorporates the functions of a computer's central processing unit on a single integrated circuit, or at most a few integrated circuits. It is a multipurpose, programmable device that accepts digital data as input, processes it according to instructions stored in its memory, and...

s. Since 1 January 2008, the package contains a translator, FBtoC, that converts the FutureBasic syntax to C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 and automatically calls Apple's GNU Compiler Collection
GNU Compiler Collection
The GNU Compiler Collection is a compiler system produced by the GNU Project supporting various programming languages. GCC is a key component of the GNU toolchain...

 (gcc). No knowledge of C is required. FutureBasic supports access to Mac OS
Mac OS
Mac OS is a series of graphical user interface-based operating systems developed by Apple Inc. for their Macintosh line of computer systems. The Macintosh user experience is credited with popularizing the graphical user interface...

 library calls.

History

FB began life in the mid-1980s as ZBasic
ZBasic
ZBasic was a compiler first released by Simutek in 1980. The combined efforts of Andrew Gariepy, Scott Terry, David Overton, Greg Branche, and Halbert Laing lead to versions for MS-DOS, Apple II, Macintosh, CP/M and TRS-80 computers. ZBasic was a very fast, efficient and quite advanced BASIC...

, which was created by Andrew Gariepy and envisioned as a cross-platform
Cross-platform
In computing, cross-platform, or multi-platform, is an attribute conferred to computer software or computing methods and concepts that are implemented and inter-operate on multiple computer platforms...

 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
Tucson, Arizona
Tucson is a city in and the county seat of Pima County, Arizona, United States. The city is located 118 miles southeast of Phoenix and 60 miles north of the U.S.-Mexico border. The 2010 United States Census puts the city's population at 520,116 with a metropolitan area population at 1,020,200...

, Arizona
Arizona
Arizona ; is a state located in the southwestern region of the United States. It is also part of the western United States and the mountain west. The capital and largest city is Phoenix...

 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
Central processing unit
The central processing unit is the portion of a computer system that carries out the instructions of a computer program, to perform the basic arithmetical, logical, and input/output operations of the system. The CPU plays a role somewhat analogous to the brain in the computer. The term has been in...

 (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 Apple's darkest days when the further existence of the Mac and Apple itself was questioned in the news every week. 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
Computer programming
Computer programming is the process of designing, writing, testing, debugging, and maintaining the source code of computer programs. This source code is written in one or more programming languages. The purpose of programming is to create a program that performs specific operations or exhibits a...

 (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
Carbon (API)
Carbon is one of Apple Inc.'s procedural application programming interfaces for the Macintosh operating system. It provides C programming language access to Macintosh system services...

 compliance of generated applications. Once completely carbonized to run natively on the Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

, the FutureBASIC Integrated Development Environment (FB IDE) was called FB4 and first released in July 2004.

Based in Diamondhead
Diamondhead, Mississippi
-Demographics:As of the census of 2010, there were 8,425 people, 3,586 households, and 2,507 families residing in the CDP. The population density was 745.6 people per square mile . There were 4,308 housing units at an average density of 381.2/sq mi...

, Mississippi
Mississippi
Mississippi is a U.S. state located in the Southern United States. Jackson is the state capital and largest city. The name of the state derives from the Mississippi River, which flows along its western boundary, whose name comes from the Ojibwe word misi-ziibi...

, Staz Software was severely hit by Hurricane Katrina
Hurricane Katrina
Hurricane Katrina of the 2005 Atlantic hurricane season was a powerful Atlantic hurricane. It is the costliest natural disaster, as well as one of the five deadliest hurricanes, in the history of the United States. Among recorded Atlantic hurricanes, it was the sixth strongest overall...

 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
Universal binary
A universal binary is, in Apple parlance, an executable file or application bundle that runs natively on either PowerPC or Intel-manufactured IA-32 or Intel 64-based Macintosh computers; it is an implementation of the concept more generally known as a fat binary.With the release of Mac OS X Snow...

 through the use of the open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 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
Procedural programming
Procedural programming can sometimes be used as a synonym for imperative programming , but can also refer to a programming paradigm, derived from structured programming, based upon the concept of the procedure call...

, modular styles of programming using function calls
Subroutine
In computer science, a subroutine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code....

 and local variable
Local variable
In computer science, a local variable is a variable that is given local scope. Such a variable is accessible only from the function or block in which it is declared. In programming languages with only two levels of visibility, local variables are contrasted with global variables...

s.

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
    Recursion (computer science)
    Recursion in computer science is a method where the solution to a problem depends on solutions to smaller instances of the same problem. The approach can be applied to many types of problems, and is one of the central ideas of computer science....

    ;
  • 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
Macintosh Toolbox
The Macintosh Toolbox is a set of application programming interfaces with a particular access mechanism. They implement many of the high-level features of the Mac OS. The Toolbox consists of a number of "managers," software components such as QuickDraw, responsible for drawing onscreen graphics,...

.

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


Legacy BASIC language commands such as: GOTO
Goto
goto is a statement found in many computer programming languages. It is a combination of the English words go and to. It performs a one-way transfer of control to another line of code; in contrast a function call normally returns control...

 and GOSUB
GOSUB
GOSUB is a command in many versions of the BASIC computer programming language. A GOSUB statement jumps to a line elsewhere in the program. That line and the following lines up to a RETURN are used as a simple kind of a subroutine without parameters or local variables.The GOSUB command may be used...

/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 point
Floating point
In computing, floating point describes a method of representing real numbers in a way that can support a wide range of values. Numbers are, in general, represented approximately to a fixed number of significant digits and scaled using an exponent. The base for the scaling is normally 2, 10 or 16...

s, 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

  • AppleScript
    AppleScript
    AppleScript is a scripting language created by Apple Inc. and built into Macintosh operating systems since System 7. The term "AppleScript" may refer to the scripting system itself, or to particular scripts that are written in the AppleScript language....

    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
  • FutureBasic allows the triggering of UNIX commands. Example:


// print a calendar for 2009
open "UNIX", 1, "cal 2009"
dim a$

do
line input #1, a$
print a$
until eof(1)
close 1
  • FB allows inline C code. Example:


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
  • No cross-platform development. This is a Macintosh-only compiler.

FutureBasic supports Macintosh PPC and Intel architectures but does not compile on or for any version of Microsoft Windows.
  • No 64bit UI support

As of January 2010, FBtoC v5.4.4 compiles 64bit commandline binaries, but supports only 32bit Carbon UI APIs).
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK