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

Ride into the zombie apocalypse in style...
Back in the good old days of Flash games, there were a few staples; Happy Wheels, Stick RPG, and of course the apocalyptic driver Earn to Die. Fans of the running over zombies simulator can rejoice, as the sequel to the legendary game, Earn to Die... | 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 »
Netflix Games expands its catalogue with...
It is a good time to be a Netflix subscriber this month. I presume there's a good show or two, but we are, of course, talking about their gaming service that seems to be picking up steam lately. May is adding five new titles, and there are some... | Read more »
Pokemon Go takes a step closer to real P...
When Pokemon Go was first announced, one of the best concepts of the whole thing was having your favourite Pokemon follow you in the real world and be able to interact with them. To be frank, the AR Snapshot tool could have done a lot more to help... | Read more »
Seven Knights Idle Adventure drafts in a...
Seven Knights Idle Adventure is opening up more stages, passing the 15k mark, and players may find themselves in need of more help to clear these higher stages. Well, the cavalry has arrived with the introduction of the Legendary Hero Iris, as... | Read more »
AFK Arena celebrates five years of 100 m...
Lilith Games is quite the behemoth when it comes to mobile games, with Rise of Kingdom and Dislyte firmly planting them as a bit name. Also up there is AFK Arena, which is celebrating a double whammy of its 5th anniversary, as well as blazing past... | Read more »
Fallout Shelter pulls in ten times its u...
When the Fallout TV series was announced I, like I assume many others, assumed it was going to be an utter pile of garbage. Well, as we now know that couldn't be further from the truth. It was a smash hit, and this success has of course given the... | Read more »
Recruit two powerful-sounding students t...
I am a fan of anime, and I hear about a lot that comes through, but one that escaped my attention until now is A Certain Scientific Railgun T, and that name is very enticing. If it's new to you too, then players of Blue Archive can get a hands-on... | Read more »
Top Hat Studios unveils a new gameplay t...
There are a lot of big games coming that you might be excited about, but one of those I am most interested in is Athenian Rhapsody because it looks delightfully silly. The developers behind this project, the rather fancy-sounding Top Hat Studios,... | Read more »
Bound through time on the hunt for sneak...
Have you ever sat down and wondered what would happen if Dr Who and Sherlock Holmes went on an adventure? Well, besides probably being the best mash-up of English fiction, you'd get the Hidden Through Time series, and now Rogueside has announced... | Read more »

Price Scanner via MacPrices.net

Apple Studio Display with Standard Glass on s...
Best Buy has the standard-glass Apple Studio Display on sale for $300 off MSRP for a limited time. Their price is the lowest available for a Studio Display among Apple’s retailers. Shipping is free... Read more
AirPods Max headphones back on sale for $449,...
Amazon has Apple AirPods Max headphones in stock and on sale for $100 off MSRP, only $449. The sale price is valid for all colors at the time of this post. Shipping is free: – AirPods Max: $449.99 $... Read more
Deal Alert! 13-inch M2 MacBook Airs on record...
Amazon has 13″ MacBook Airs with M2 CPUs in stock and on sale this week for only $829 in Space Gray, Silver, Starlight, and Midnight colors. Their price is $170 off Apple’s MSRP, and it’s the lowest... Read more
Apple Watch Ultra 2 on sale for $50 off MSRP
Best Buy is offering Apple Watch Ultra 2 models for $50 off MSRP on their online store this week. Sale prices available for online orders only, in-store prices may vary. Order online, and choose free... Read more
Apple introduces the new M4-powered 11-inch a...
Today, Apple revealed the new 2024 M4 iPad Pro series, boasting a surprisingly thin and light design that pushes the boundaries of portability and performance. Offered in silver and space black... Read more
Apple introduces the new 2024 11-inch and 13-...
Apple has unveiled the revamped 11-inch and brand-new 13-inch iPad Air models, upgraded with the M2 chip. Marking the first time it’s offered in two sizes, the 11-inch iPad Air retains its super-... Read more
Apple discontinues 9th-gen iPad, drops prices...
With today’s introduction of the new 2024 iPad Airs and iPad Pros, Apple has (finally) discontinued the older 9th-generation iPad with a home button. In response, they also dropped prices on 10th-... Read more
Apple AirPods on sale for record-low prices t...
Best Buy has Apple AirPods on sale for record-low prices today starting at only $79. Buy online and choose free shipping or free local store pickup (if available). Sale price for online orders only,... Read more
13-inch M3 MacBook Airs on sale for $100 off...
Best Buy has Apple 13″ MacBook Airs with M3 CPUs in stock and on sale today for $100 off MSRP. Prices start at $999. Their prices, along with Amazon’s, are the lowest currently available for new 13″... Read more
Amazon is offering a $100 discount on every 1...
Amazon has every configuration and color of Apple’s 13″ M3 MacBook Air on sale for $100 off MSRP, now starting at $999 shipped. Shipping is free: – 13″ MacBook Air (8GB RAM/256GB SSD): $999 $100 off... Read more

Jobs Board

*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
Relationship Banker *Apple* Valley Main - W...
…Alcohol Policy to learn more. **Company:** WELLS FARGO BANK **Req Number:** R-367184 **Updated:** Wed May 08 00:00:00 UTC 2024 **Location:** APPLE VALLEY,California Read more
Rehabilitation Technician - *Apple* Hill (O...
Rehabilitation Technician - Apple Hill (Outpatient Clinic) - PRN Location: York Hospital, York, PA Schedule: PRN/Per Diem Sign-On Bonus Eligible Remote/Hybrid Read more
LPN-Physician Office Nurse - Orthopedics- *Ap...
LPN-Physician Office Nurse - Orthopedics- Apple Hill Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Read more
Medical Assistant Lead - Orthopedics *Apple*...
Medical Assistant Lead - Orthopedics Apple Hill Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.