TweetFollow Us on Twitter

FutureBASIC
Volume Number:9
Issue Number:5
Column Tag:Tools of the Trade

Z z z FutureBASIC

An industrial strength BASIC built for Macintosh

By Dave Kelly, MacTech Magazine Regular Contributing Author

Look! Up in the sky! It’s a bird, it’s a plane, no it’s FutureBASIC. Never before seen on this planet, FutureBASIC goes where no other BASIC has gone before. FutureBASIC (version 1.01) is not simply an upgrade of ZBasic. Although ZBasic programs can still be run with FutureBASIC, there are plenty of enhancements to interest any programmer, with any level of experience. I’ll refer to FutureBASIC as FB for the remainder of this article.

If you’re new to programming the Macintosh, FB now provides the easiest and quickest way to produce real Macintosh applications. Zedcor has put a lot of work into producing a set of manuals that not only provides documentation for the FB language, but also teaches structured programming methods. When getting started with FB you’ll want to start with the “Getting Started” manual. In this manual, you take a walk through three sample programs. You won’t even have to open any of the other manuals to start seeing results.

The “Getting Started” section emphasizes the importance of organizing and structuring your programs. Structure is something that doesn’t come natural to BASIC, but the FB manuals show you a consistent way to structure your programs. Programs are divided into sections split by remarks (see the example at the end of this article). A typical structured program will have a Constants section, Global variables section, Functions section and Main section. Zedcor, who has always promoted these programming practices, has done a great job in maintaining these structured practices.

After you go though the “Getting Started” manual, you’ll want to look at the FB “Handbook”. The Handbook will help you learn how to program the Macintosh. This manual isn’t just for beginners; there is information here that applies to all programmers. In particular, there are sections on writing INITs, cdevs, and Desk Accessories (yes, you can now create INIT, CDEV, DRVR and CODE resources), HyperCard XCMDs and XFCNs, how memory is organized, and Debugging (using FB’s Debugger and MacsBug). Beginners probably won’t start out writing INITs, but the manual includes everything you need to do it. The strength of the handbook is that it ties together the information that is in Inside Macintosh with the FB Reference manual. The Handbook is organized by subject (Windows, Menus, File Handling, Resources, QuickDraw, Etc.).

The “Reference” manual covers each FB command similar to the old ZBasic manual, but completely rewritten. It’s not like the Microsoft manuals that spend the first half of the manual explaining the programming environments (how the editor works, how to compile a program). Only the first 28 pages are dedicated to explaining the FB application, the remaining 375+ pages (plus appendixes) are strictly for reference. Each command is presented with a short example.

If you’re a Pascal, C, or Assembly language programmer (or any other language for that matter), FB will interest you too. First and foremost, FB is fast! It’s nearly as fast as Pascal and C. In benchmark tests that I performed, I was pleased with its performance in every test case I tried. The tests that I ran were derived from tests that I’ve run in the past. I’m not including those results here since there isn’t any close competition with FB anyway.

Experienced programmers will like the professional look and feel of the FB compiler. Some examples of this:

Resources are included in an FB program by including a one line statement such as:

RESOURCES “Resource File.rsrc”

The resource file can include any resources that you’re used to using in C or Pascal.

CALLs to assembled CODE resources - you can include any assembled code in your program.

In-line assembly language code: FB allows you to enter assembly language mnemonics directly into your program (THINK Pascal won’t let you do that!). Standard M68000 family statements and functions are fully supported.

APPL, INIT, cdev, DRVR, WDEF, CDEF, MDEF, CODE resource types can be created. This is what really makes FB a big league player. There are two different runtime packages that can get included at compile time when creating applications. You can choose the Standard-runtime package that takes up over 40K of space or the Mini-runtime version that is less than 5K. The difference is that the Mini-runtime must use Macintosh Toolbox routines for handling events. The reference manual distinguishes between the commands that are supported by the Mini vs. the Standard runtimes by putting a lower case m next to the command name. The extra memory saved may be worth it in some situations, but the expanded command set makes life much easier. Most of you will still want to compile with the Standard-runtime package. The RESOURCES statement at the beginning of the program tells the compiler which type of resource to compile.

Project Manager tool: FB’s Project Manager automatically keeps track of source code files used in a project. A project consists of all the files in a particular folder. The Project Manager makes it easy to open source code files and mark the files that need to be compiled. You can compile and run all related files in a project. So, if you have separated your various routines into separate files, then you can run the main program by selecting it in the Project Manager window and any files that are included (using the INCLUDE statement).

Cross Reference tool: The Cross Reference tool displays an alphabetical list of functions, labels, variables, or constants that are used in the current Editor window. You can search for an item by clicking on it.

Editing is completely new for this version of FB. The ZBasic editor was never as stable as this one. Most notable is that keywords are recognized and indentation is applied to the source code automatically. You can adjust the spacing for indented lines using the preferences dialog. Full Search and Replace capability can search in both directions. When an error occurs in your program, the cursor points to the line where the error occurred.

The Help system provides a ready reference to all FB commands. An additional bonus is that sample source code is included with the information in the Help file that you can paste into your program. You can even add your own stuff to the Help file.

Page Layout can be customized to print source code with header, footer, date, Program Name, page numbers, boldface keywords, and automatic indentation.

LOCAL FN is a new statement that lets you pass a list of parameters to a subroutine that will only be used locally. That means that variables used in LOCAL FN routines are only defined within the subroutine. You can now use libraries of LOCAL FN routines and not have to worry if there is a conflict between your program’s variables and the subroutine’s variables. LOCAL FN is a very powerful statement that can also be used recursively. LOCAL FN virtually makes using GOSUB and LONG FN obsolete (GOTO was obsolete along time ago). FB still supports GOSUB, GOTO, and LONG FN, but you are strongly advised against their use because of the great benefits of LOCAL FN.

Constants are now presented in a consistent manner. In older versions of BASIC only numbers could be used for constants. In FB you can assign integer and long integer constants a name to make them easier to remember and more understandable. You can tell a constant because it always starts with an underline character. Besides the fact that you can define your own constants, FB comes with hundreds of predefined named constants. Many of them correspond to constants in Inside Macintosh.

Record types are defined using the DIM RECORD statement. Any record type in Inside Macintosh can be defined with this statement. Records can be passed between functions by passing the record’s address.

QuickTime™ movie calls are included for playing QuickTime movies.

Balloon and Apple Event calls are part of the extensive Macintosh Toolbox support. However, the manuals show you how to create your own calls just in case Apple adds a new one.

Word Solution Engine™ functions are build in to FB as USR functions. Word Solution Engine is NOT included with FB. You can use these routines to access Word Solution Engine (if you have it) to create a professional looking word processor.

Debugger: FB’s own debugger is great. If you like the debugger in THINK Pascal, you’ll like this one too. You can set break points and step through a program. You can follow variable changes as they happen.

There are simply thousands of features packed into FB. I’d love to be able to show you a sample of each, but Zedcor has done a great job of that on the example files included with FB. I will include one here that can give you a sense of what FB can do. In particular, the ability to create cdevs is one of FB’s new features. The following code is an example of a cdev (from Zedcor).

‘CDEV example     7/07/92
RESOURCES “FB CDEV.rsrc”,”cdevhack”,”cdev”,-4064,”FutureBasic™ CDEV”,_resPurgeable%
OUTPUT FILE “myCDEV”

‘--------------- Globals ------------------
BYEBYE = _false
END GLOBALS

‘--------------- Functions -----------------
LOCAL FN doKeys (theEvent&)
  ‘first, get the character
  message&   = [theEvent&+_evtMessage]  
  ‘then see if the command key was down
  modifiers% = {theEvent&+_evtMeta}     
  tempChar$  = CHR$(message& AND &FF)  ‘mask for character
  LONG IF modifiers% AND 256           ‘test for command key
    %theEvent&,_nullEvt
    SELECT tempChar$         ‘set appropriate message
      CASE “X”,”x”             ‘cut?
        message% = _cutDev     ‘pass menu event back to cdev
      CASE “C”,”c”             ‘copy?
        message% = _copyDev    ‘pass menu event back to cdev
      CASE “V”,”v”             ‘paste?
        message% = _pasteDev   ‘pass menu event back to cdev
      CASE “Z”,”z”             ‘undo?
        message% = _undoDev    ‘pass menu event back to cdev
      CASE “W”,”w”             ‘close window?
        BYEBYE = _true         ‘pass menu event back to cdev
    END SELECT                  
  END IF
END FN

‘is it time to go bye bye?
LOCAL FN checkBYEBYE(cdevStorage&)
  LONG IF BYEBYE                       
    LONG IF cdevStorage&             ‘valid handle?
      mErr= FN DISPOSHANDLE (cdevStorage&) ’dump it
      IF mErr THEN BEEP:BEEP:BEEP
    END IF
    END
  END IF   
END FN          

LOCAL
DIM rect;0, T,L,B,R
LOCAL FN showMsg (msg$)
  CALL SETRECT (rect,110,110,220,160)
  CALL ERASERECT(rect)              ‘erase last message
  PRINT%(L+(R-L)/2-24,T+(B-T)/2+4);
  PRINT msg$;                       
END FN                    

‘---------------- Main ------------------
ENTERPROC%(message%,item%,numItems%,CPanelID%,
  theEvent&,cdevStorage&,CPDialog&)
  ‘softmask =&0000 and hardmask = &FFFF
  LONG IF message% = _macDev  
    returnVal& = 1               ‘works on every machine
    lastPass& = cdevStorage&
  XELSE
    LONG IF cdevStorage& <> lastPass&   ‘
      SELECT cdevStorage&  ‘check for errors when the 
        CASE _cdevGenErr   ‘Control Panel sends them to you.
        CASE _cdevMemErr
          ‘do an error message
        CASE _cdevResErr
          ‘do an error message
        CASE _cdevUnset
          ‘ignore this
      END SELECT
    END IF
    LONG IF cdevStorage&       ‘inialize storage for cdev
      lastPass& = cdevStorage&
      SELECT message%
        CASE _initDev          ‘initialize cdev
          ’create private storage
          cdevStorage& = FN NEWHANDLE(2)
          ‘we work on every machine
          returnVal& = cdevStorage&  
        CASE _hitDev          ‘button or text field clicked
          ’subtract Control Pan items
          msg$= “_hitDev item=”+STR$(item%-numItems%) 
          FN showMsg (msg$)
        CASE _closeDev        ‘close down the cdev now
          BYEBYE = _true                  
          FN showMsg (“BYE!”)
          BEEP :DELAY 1000
        CASE _nulDev                 ‘do null events here
        CASE _updateDev              ‘update your stuff
          FN showMsg (“_updateDev”)
        CASE _activDev               ‘activate controls 
                                     ‘deactivated below
          FN showMsg (“_activDev”)
        CASE _deActivDev             ‘deactivate controls
          FN showMsg (“_deActivDev”)
        CASE _keyEvtDev              ‘respond to key down
          FN doKeys (theEvent&)
          FN showMsg (“_keyEvtDev”)
        CASE _undoDev,_cutDev,_copyDev,_pasteDev,_clearDev
          FN showMsg (“__someEditDev??”)
        CASE _cursorDev              ‘cursor over cdev area
      END SELECT
    END IF
  END IF
EXITPROC% = returnVal&
FN checkBYEBYE(cdevStorage&)
RETURN

For More information

Contact Zedcor, 4500 E. Speedway, Suite 22, Tucson, AZ 85712. Voice: 602/881-8101, Fax: 602/881-1841, Applelink: ZEDCOR.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Fresh From the Land Down Under – The Tou...
After a two week hiatus, we are back with another episode of The TouchArcade Show. Eli is fresh off his trip to Australia, which according to him is very similar to America but more upside down. Also kangaroos all over. Other topics this week... | Read more »
TouchArcade Game of the Week: ‘Dungeon T...
I’m a little conflicted on this week’s pick. Pretty much everyone knows the legend of Dungeon Raid, the match-3 RPG hybrid that took the world by storm way back in 2011. Everyone at the time was obsessed with it, but for whatever reason the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for July 19th, 2024. In today’s article, we finish up the week with the unusual appearance of a review. I’ve spent my time with Hot Lap Racing, and I’m ready to give my verdict. After... | Read more »
Draknek Interview: Alan Hazelden on Thin...
Ever since I played my first release from Draknek & Friends years ago, I knew I wanted to sit down with Alan Hazelden and chat about the team, puzzle games, and much more. | Read more »
The Latest ‘Marvel Snap’ OTA Update Buff...
I don’t know about all of you, my fellow Marvel Snap (Free) players, but these days when I see a balance update I find myself clenching my… teeth and bracing for the impact to my decks. They’ve been pretty spicy of late, after all. How will the... | Read more »
‘Honkai Star Rail’ Version 2.4 “Finest D...
HoYoverse just announced the Honkai Star Rail (Free) version 2.4 “Finest Duel Under the Pristine Blue" update alongside a surprising collaboration. Honkai Star Rail 2.4 follows the 2.3 “Farewell, Penacony" update. Read about that here. | Read more »
‘Vampire Survivors+’ on Apple Arcade Wil...
Earlier this month, Apple revealed that poncle’s excellent Vampire Survivors+ () would be heading to Apple Arcade as a new App Store Great. I reached out to poncle to check in on the DLC for Vampire Survivors+ because only the first two DLCs were... | Read more »
Homerun Clash 2: Legends Derby opens for...
Since launching in 2018, Homerun Clash has performed admirably for HAEGIN, racking up 12 million players all eager to prove they could be the next baseball champions. Well, the title will soon be up for grabs again, as Homerun Clash 2: Legends... | Read more »
‘Neverness to Everness’ Is a Free To Pla...
Perfect World Games and Hotta Studio (Tower of Fantasy) announced a new free to play open world RPG in the form of Neverness to Everness a few days ago (via Gematsu). Neverness to Everness has an urban setting, and the two reveal trailers for it... | Read more »
Meditative Puzzler ‘Ouros’ Coming to iOS...
Ouros is a mediative puzzle game from developer Michael Kamm that launched on PC just a couple of months back, and today it has been revealed that the title is now heading to iOS and Android devices next month. Which is good news I say because this... | Read more »

Price Scanner via MacPrices.net

Amazon is still selling 16-inch MacBook Pros...
Prime Day in July is over, but Amazon is still selling 16-inch Apple MacBook Pros for $500-$600 off MSRP. Shipping is free. These are the lowest prices available this weekend for new 16″ Apple... Read more
Walmart continues to sell clearance 13-inch M...
Walmart continues to offer clearance, but new, Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBooks... Read more
Apple is offering steep discounts, up to $600...
Apple has standard-configuration 16″ M3 Max MacBook Pros available, Certified Refurbished, starting at $2969 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free,... Read more
Save up to $480 with these 14-inch M3 Pro/M3...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
Amazon has clearance 9th-generation WiFi iPad...
Amazon has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80-$100 off MSRP, starting only $249. Their prices are the lowest available for new iPads anywhere: – 10″ 64GB WiFi iPad (Space Gray or... Read more
Apple is offering a $50 discount on 2nd-gener...
Apple has Certified Refurbished White and Midnight HomePods available for $249, Certified Refurbished. That’s $50 off MSRP and the lowest price currently available for a full-size Apple HomePod today... Read more
The latest MacBook Pro sale at Amazon: 16-inc...
Amazon is offering instant discounts on 16″ M3 Pro and 16″ M3 Max MacBook Pros ranging up to $400 off MSRP as part of their early July 4th sale. Shipping is free. These are the lowest prices... Read more
14-inch M3 Pro MacBook Pros with 36GB of RAM...
B&H Photo has 14″ M3 Pro MacBook Pros with 36GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 Pro MacBook Pro (... Read more
14-inch M3 MacBook Pros with 16GB of RAM on s...
B&H Photo has 14″ M3 MacBook Pros with 16GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $150-$200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 MacBook Pro (... Read more
Amazon is offering $170-$200 discounts on new...
Amazon is offering a $170-$200 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1129 for models with 8GB of RAM and 256GB of storage: – 15″ M3... Read more

Jobs Board

*Apple* Systems Engineer - Chenega Corporati...
…LLC,** a **Chenega Professional Services** ' company, is looking for a ** Apple Systems Engineer** to support the Information Technology Operations and Maintenance Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
*Apple* / Mac Administrator - JAMF Pro - Ame...
Amentum is seeking an ** Apple / Mac Administrator - JAMF Pro** to provide support with the Apple Ecosystem to include hardware and software to join our team and Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.