TweetFollow Us on Twitter

ZBasic 5.0
Volume Number:5
Issue Number:2
Column Tag:Basic School

Zedcor Compiler 5.0

By Dave Kelly, Editorial Board

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

It seems that a month doesn’t go by that we don’t see an update to BASIC. This month we will talk about what’s new with ZBasic Compiler version 5.0. After a couple of years with ZBasic in our midst, Zedcor now has a solid product and it‘s still the fastest Basic available for the Macintosh.

New Price

The worst news is that Zedcor has raised the price to $199.95. The interesting thing about the increase in price is that both Microsoft and True Basic, Inc. have adjusted their prices to be competitive with Zedcor’s ZBasic. What do you get for the price? You get the ZBasic compiler with built in editor (which now works without crashing), a new Macintosh only manual, ZConvert.BAS program for converting MSBASIC to ZBasic, “The Program Generator” used for creating program shells, ZMover Toolbox editor which is used to add or delete toolbox routines or USR routines, and dozens of usable examples and utility routines. The Program Generator program is a new rewritten product, not the old program generator which has been sold separately by Zedcor.

The Compiler

The ZBasic Compiler version 5.0 now appears to be a very solid product. It’s refreshing to be debugging my own programming errors instead of those of ZBasic. Of course, it is not possible to check every single command and toolbox call to report to you if a bomb occurred, but with those that I have tried I have had 100% success!

Zedcor’s built in editor now works, although it is not as fancy as Microsoft’s “pretty-printing” editor. The important thing is to be able to edit a program without going through the load-edit-save-compile-debug...etc. cycle. For search and replace you will have to rely on other text editors; ZBasic only has a Find command.

The Hypertext Help system is excellent if you want to look up something while using ZBasic. Clicking on keywords moves you through the Help system to find just what you are looking for. It’s like having the manual on line all the time.

The configuration options have changed only slightly from previous versions. You may now set the bundle bit of your application as it is compiled. In “Expert Programmer Mode” you can turn off the “Are you sure?” dialog boxes (Are you sure you want to turn this off?). One missing feature is the ability to automatically include a resource file in the compiled application or use the resource file when running under the ZBasic environment. Instead, Zedcor includes a copy of ResEdit (not the latest version) which you can use to move your resources to your new application.

NOTE: be sure to save any tokenized ZBasic files from previous versions as text files before throwing out the old version when you upgrade. The tokenization is different in 5.0, I’ll explain why in a few more paragraphs.

Improved Toolbox Support

The toolbox support in ZBasic is better than any Basic has ever provided before. Inside Macintosh will still be needed at your side to make sense of things. The new routines presented in Inside Macintosh vol. V are now supported. The best part of this is the examples which Bob Andrus submitted to Zedcor to demonstrate the use of Color Palette Animation, and Hierarchical and Pop up menus. Thanks Bob!

The manual which includes the toolbox calls in Appendix D, is organized much the same way as in the last version with families of toolbox commands and functions grouped together. The new toolbox commands provided in volume V of IM are grouped together on three pages in a category named ‘Color Quickdraw for Mac II and Beyond’. This list could have been sorted by functional groups to be easier to use. Also, this is the only group that does not include a brief description of what each routine does. Since you need Inside Macintosh anyway, the description is not that critical.

ZMover Toolbox Editor

ZMover is a toolbox statement editor written by Chris Stasny which will let you move statements in and out of ZBasic. The statements are manipulated in much the same way as Font/DA Mover manipulates DAs and Fonts. Any modification of ZBasic will prevent tokenized files from being properly loaded. I recommend that you always save your source code files as text, NEVER as tokenized, just in case the next version of ZBasic won’t have the same tokenization. The next version probably won’t be the same, especially if new toolbox commands are added.

The best part of ZMover is the ability to create new toolbox functions and commands and add them to your compiler. The manual gives full documentation on the code resource which stores the toolbox statements. (Andrew Gariepy promised to release this information over a year ago). The manual implies that the editor could be used to change the toolbox statements (for example change “FRAMERECT” to “MTBOX”.) I don’t recommend that anyone ever change the names of statements or functions which are documented in Inside Macintosh.

New Manual

The new ZBasic manual is exclusively for the Macintosh (no more MSDOS!!). The reference section of the manual now includes all the Mac commands; you don’t have to go to the appendix for anything except real toolbox statements.

The version 5.0 manual is organized in much the same way as the previous version with the addition of new toolbox calls and documentation for the Toolbox statement mover and ZConvert Utility. There is also documentation for Ztree, for fast operation of large data files in ZBasic. Ztree is a complete tree indexing subroutine which can be used to index up to 65,535 records (or it can be modified using long integers to index up to 2,147,483,647 records). This is an excellent utility which some ZBasic users have been asking for.

Toolbox documentation is good when used with Inside Macintosh. However, the documentation for Appletalk commands needs more examples or explanation. The structure of the AppleTalk commands deviates from Inside Macintosh. Since there are two versions of AppleTalk released (the preferred and the original AppleTalk) more clarification is needed.

The Program Generator

This program written by Chris Stasny is included on the ZBasic master disk. It will let you create a simple shell, or skeleton, of your program in just a few minutes. It can take a lot of tedious work to line up windows, buttons, edit fields and other controls in order to make a window ‘look good.’ The program generator will let you use draw type tools to place objects on your window. In addition, you may add up to 48 subroutines to your program. A few subroutines are included such as screen size, alerts, frame button, and reading the clipboard. You may add your own favorites as needed. This is a nice touch, but you could always append your own routines to the end via traditional cut/paste methods with about the same effort.

The documentation explains the generator’s use and limitations. A program like this is not meant to do all the work for you, only simplify the work so you can spend your time doing programming instead of illustrating your windows. The generator could be a big help to you depending on what kind of program you are writing. Any program that will need to have windows formatted can be off to a good start with the generator.

There are a few limitations which can be easily overcome with some programming, but at least it’s a start. The four basic types of Edit Fields are supported, but you will have to add the code to retrieve the contents of the fields. Buttons are fully supported in the event loop. A menu editor is provided in the generator which will let you set up simple non-heirarchical menus. Font, Style, and Size menus will be automatically created by simply typing in the menu title. Using and setting up menus is usually not too difficult anyway, so there isn’t too much savings here. Window types are selected from a dialog which displays the window types available. Only one window can be edited at a time. In order to do more windows, you must save the program source code (i.e. generate the new program) and open the source code for append (an option in the File menu). This is somewhat tedious, but still better than illustrating windows by brute force. You will need to plan out what you want the window to be like since the generator doesn’t let you resize anything. If you make a mistake, you have to delete the object and start over. Be sure to give your text enough width or it will wrap to the next line when you don’t want it to. It would be nice to have the text edit fields and buttons as part of the palette since they are just objects like everything else.

There are mixed thoughts about the usefulness of a program generator. For quick and dirty programs it is ideal to have the event loop already in place and an easy way to create windows, etc. It would be ideal in some cases to have the generator automatically create resource files for menus and windows created. You may just want to use ResEdit or Prototyper™ to create the resource files. I highly recommend Prototyper™ especially if you do any Pascal or C programming too. You will have to decide how useful the generator is for your own uses. I ask, is it worth the extra price of ZBasic? Probably not. The dozens of example programs included with ZBasic are worth much more than the program generator.

Z Best Basic?

At the moment, there are three major Basic products on the market which each have their own niche. True Basic has the most structured, strongest scientific language. QuickBASIC comes from the largest company which has supported MSBasic for many years and a nice programming environment. ZBasic is the fastest compiler and generates the smallest application code. It includes the most examples and utilities with the compiler. The price is a killer, but Zedcor has shown that they intend to continue supporting ZBasic for years to come. I’ll have to say that each time a new version of Basic is released, the newest released has been the best product at the time for various reasons. That being the case, ZBasic is best until one of the competition comes out with their next new version.

The following program is a variation of one printed in MacTutor vol. 4 No. 4 (April, 1988) in which you can see by comparison that the addition of just a few toolbox calls to ZBasic’s set of toolbox calls can simplify the programming effort considerably:

‘Color Picking with ZBasic 5.0
‘©MacTutor 1989
‘By Dave Kelly

WINDOW OFF
COORDINATE WINDOW
DIM Colorbox%(3),inColor%(3),outColor%(3),Point%(2),AlertText$(4)
DIM RGB1%(3),PaletteRect%(3)
red&=65535
green&=0
blue&=0

DEF MOUSE=-1
false%=0:true%=NOT(false)

GOSUB “GetColorMode”
IF ColorMode%>256 THEN ColorMode%=256 
LONG IF ColorMode%<16
AlertText$(1)=””
AlertText$(2)=”This Demo must be run on a”
AlertText$(3)=” Mac ][ in 16 or 256 colors”
AlertText$(4)=””
CALL PARAMTEXT(AlertText$(1), AlertText$(2), AlertText$(3), AlertText$(4))
AlertAns%=FN NOTEALERT(1,0)
GOTO “Quit”
END IF

MENU 1,0,1,”File”
MENU 1,1,1,”Select Color”
MENU 1,2,1,”Quit”
EDIT MENU 2

‘Find out screen size.
CALL GETWMGRPORT(WMgrPort&)
PortTop=PEEK WORD(WMgrPort&+8)
PortLeft=PEEK WORD(WMgrPort&+10)
PortBottom=PEEK WORD(WMgrPort&+12)
PortRight=PEEK WORD(WMgrPort&+14)

WINDOW 1,”Main Window”,(10,44)-(PortRight-4,PortBottom-4),5
GET WINDOW #1, WindowPtr&
TEXT ,,,0
BUTTON #6,1,”Quit”,(20,WINDOW(3)-50)-(85,WINDOW(3)-30),1
BUTTON #7,1,”Pick Color”,(120,WINDOW(3)-50)-(195,WINDOW(3)-30),1
CALL SETRECT(Colorbox%(0), 10,10,WINDOW(2)-10,
 WINDOW(3)-215)
PICTURE ON
LONG COLOR blue&,green&,red&
CALL PAINTRECT(Colorbox%(0))
COLOR=7
CALL FRAMERECT(Colorbox%(0))
CALL MOVETO(20,WINDOW(3)-100)
PRINT “Red:”;red&;” Green:”;green&;” Blue:”;blue&;SPACE$(10)
PICTURE OFF,Pic1&
PICTURE, Pic1&
WINDOW PICTURE #1,Pic1&

ON DIALOG GOSUB “Event”
ON MENU GOSUB “MenuEvent”
DIALOG ON:MENU ON
“Loop”
GOTO “Loop”
DIALOG STOP:MENU STOP

“MenuEvent”
Menunumber=MENU(0)
Menuitem=MENU(1)
MENU
IF Menunumber<>1 THEN RETURN
SELECT Menuitem
 CASE 1
 GOSUB “ColorPick”
 CASE 2
 GOSUB “Quit”
END SELECT
RETURN

“Quit”
WINDOW PICTURE #1,0
KILL PICTURE Pic1&
END

“ColorPick”:’A Color Selection routine
inColor%(0)=red&
inColor%(1)=green&
inColor%(2)=blue&
Result=FN GETCOLOR(Point%(0),”Choose the best
 color!”,inColor%(0),outColor%(0))
LONG IF Result<>0
 red&=outColor%(0)
 green&=outColor%(1)
 blue&=outColor%(2)
 IF red&<0 THEN red&=65536+red&
 IF green&<0 THEN green&=65536+green&
 IF blue&<0 THEN blue&=65536+blue&
 PICTURE ON
 LONG COLOR blue&,green&,red&
 CALL SETRECT(Colorbox%(0), 10,10,WINDOW(2)-10,
 WINDOW(3)-215)
 CALL PAINTRECT(Colorbox%(0))
 COLOR=7
 CALL FRAMERECT(Colorbox%(0))
 CALL MOVETO(20,WINDOW(3)-100)
 PRINT “Red:”;red&;” Green:”;green&;” Blue:”;blue&;SPACE$(10)
 PICTURE OFF,Pic1&
 PICTURE, Pic1&
 WINDOW PICTURE #1,Pic1&
END IF
RETURN

“Event”
 D=DIALOG(0)
SELECT D
 CASE 1
 GOSUB “ButtonEvent”
 CASE 4
 GOSUB “Quit”:’if close box selected
END SELECT
RETURN

“ButtonEvent”
Buttonpressed=DIALOG(1)
IF Buttonpressed=6 THEN “Quit”
IF Buttonpressed=7 THEN “ColorPick”
RETURN

REM * * * * * * * * * * * * * * * * * * * * * * * * * * * * **
REM
“GetColorMode” ‘With thanks to Zedcor and Bob Andrus
REM
REM  SUBROUTINE TO GET THE B&W/COLOR MODE
REM
REM  ROM85=&H028E
REM
REM  RomTypeW& = -1    FOR 128K OR 512K
REM  RomTypeW& = 32767 FOR PLUS OR SE
REM  RomTypeW& = 16383 FOR ][
REM
 ROM85&=&H028E
 RomTypeW&=PEEK WORD(ROM85&)
REM
REM  TheGDevice=&H0CC8
REM
REM  gdMode& = 128 FOR   2 B&W OR COLORS
REM  gdMode& = 129 FOR   4 B&W OR COLORS
REM  gdMode& = 130 FOR  16 B&W OR COLORS
REM  gdMode& = 131 FOR 256 B&W OR COLORS
REM
 TheGDevice&=&H0CC8
 GDHandle&=PEEK LONG(TheGDevice&)
 GDPtr&=PEEK LONG(GDHandle&)
 gdMode&=PEEK LONG(GDPtr&+42)
REM
REM  GET THE B&W/COLOR MODE
REM
 IF RomTypeW&<>16383 THEN ColorMode%=2
 IF RomTypeW&<>16383 THEN RETURN
 IF gdMode&=128 THEN ColorMode%=2
 IF gdMode&=129 THEN ColorMode%=4
 IF gdMode&=130 THEN ColorMode%=16
 IF gdMode&=131 THEN ColorMode%=256
 RETURN

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »
Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links below... | Read more »
Marvel Future Fight celebrates nine year...
Announced alongside an advertising image I can only assume was aimed squarely at myself with the prominent Deadpool and Odin featured on it, Netmarble has revealed their celebrations for the 9th anniversary of Marvel Future Fight. The Countdown... | Read more »
HoYoFair 2024 prepares to showcase over...
To say Genshin Impact took the world by storm when it was released would be an understatement. However, I think the most surprising part of the launch was just how much further it went than gaming. There have been concerts, art shows, massive... | Read more »

Price Scanner via MacPrices.net

You can save $300-$480 on a 14-inch M3 Pro/Ma...
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
24-inch M1 iMacs available at Apple starting...
Apple has clearance M1 iMacs available in their Certified Refurbished store starting at $1049 and ranging up to $300 off original MSRP. Each iMac is in like-new condition and comes with Apple’s... Read more
Walmart continues to offer $699 13-inch M1 Ma...
Walmart continues to offer 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 MacBook for sale by... Read more
B&H has 13-inch M2 MacBook Airs with 16GB...
B&H Photo has 13″ MacBook Airs with M2 CPUs, 16GB of memory, and 256GB of storage in stock and on sale for $1099, $100 off Apple’s MSRP for this configuration. Free 1-2 day delivery is available... Read more
14-inch M3 MacBook Pro with 16GB of RAM avail...
Apple has the 14″ M3 MacBook Pro with 16GB of RAM and 1TB of storage, Certified Refurbished, available for $300 off MSRP. Each MacBook Pro features a new outer case, shipping is free, and an Apple 1-... Read more
Apple M2 Mac minis on sale for up to $150 off...
Amazon has Apple’s M2-powered Mac minis in stock and on sale for $100-$150 off MSRP, each including free delivery: – Mac mini M2/256GB SSD: $499, save $100 – Mac mini M2/512GB SSD: $699, save $100 –... Read more
Amazon is offering a $200 discount on 14-inch...
Amazon has 14-inch M3 MacBook Pros in stock and on sale for $200 off MSRP. Shipping is free. Note that Amazon’s stock tends to come and go: – 14″ M3 MacBook Pro (8GB RAM/512GB SSD): $1399.99, $200... Read more
Sunday Sale: 13-inch M3 MacBook Air for $999,...
Several Apple retailers have the new 13″ MacBook Air with an M3 CPU in stock and on sale today for only $999 in Midnight. These are the lowest prices currently available for new 13″ M3 MacBook Airs... Read more
Multiple Apple retailers are offering 13-inch...
Several Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices... Read more
Roundup of Verizon’s April Apple iPhone Promo...
Verizon is offering a number of iPhone deals for the month of April. Switch, and open a new of service, and you can qualify for a free iPhone 15 or heavy monthly discounts on other models: – 128GB... Read more

Jobs Board

Relationship Banker - *Apple* Valley Financ...
Relationship Banker - Apple Valley Financial Center APPLE VALLEY, Minnesota **Job Description:** At Bank of America, we are guided by a common purpose to help Read more
IN6728 Optometrist- *Apple* Valley, CA- Tar...
Date: Apr 9, 2024 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 824398 At Target Optical, we help people see and look great - and Read more
Medical Assistant - Orthopedics *Apple* Hil...
Medical Assistant - Orthopedics Apple Hill York Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of Read more
Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.