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

The secrets of Penacony might soon come...
Version 2.2 of Honkai: Star Rail is on the horizon and brings the culmination of the Penacony adventure after quite the escalation in the latest story quests. To help you through this new expansion is the introduction of two powerful new... | Read more »
The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »
Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »
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 »

Price Scanner via MacPrices.net

Apple Magic Keyboards for iPads are on sale f...
Amazon has Apple Magic Keyboards for iPads on sale today for up to $70 off MSRP, shipping included: – Magic Keyboard for 10th-generation Apple iPad: $199, save $50 – Magic Keyboard for 11″ iPad Pro/... Read more
Apple’s 13-inch M2 MacBook Airs return to rec...
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 currently... Read more
Best Buy is clearing out iPad Airs for up to...
In advance of next week’s probably release of new and updated iPad Airs, Best Buy has 10.9″ M1 WiFi iPad Airs on record-low sale prices for up to $200 off Apple’s MSRP, starting at $399. Sale prices... Read more
Every version of Apple Pencil is on sale toda...
Best Buy has all Apple Pencils on sale today for $79, ranging up to 39% off MSRP for some models. Sale prices for online orders only, in-store prices may vary. Order online and choose free shipping... Read more
Sunday Sale: Apple Studio Display with Standa...
Amazon has the standard-glass Apple Studio Display on sale for $300 off MSRP for a limited time. Shipping is free: – Studio Display (Standard glass): $1299.97 $300 off MSRP For the latest prices and... Read more
Apple is offering significant discounts on 16...
Apple has a full line of 16″ M3 Pro and M3 Max MacBook Pros available, Certified Refurbished, starting at $2119 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free... Read more
Apple HomePods on sale for $30-$50 off MSRP t...
Best Buy is offering a $30-$50 discount on Apple HomePods this weekend on their online store. The HomePod mini is on sale for $69.99, $30 off MSRP, while Best Buy has the full-size HomePod on sale... Read more
Limited-time sale: 13-inch M3 MacBook Airs fo...
Amazon has the base 13″ M3 MacBook Air (8GB/256GB) in stock and on sale for a limited time for $989 shipped. That’s $110 off MSRP, and it’s the lowest price we’ve seen so far for an M3-powered... Read more
13-inch M2 MacBook Airs in stock today at App...
Apple has 13″ M2 MacBook Airs available for only $849 today in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty is included,... Read more
New today at Apple: Series 9 Watches availabl...
Apple is now offering Certified Refurbished Apple Watch Series 9 models on their online store for up to $80 off MSRP, starting at $339. Each Watch includes Apple’s standard one-year warranty, a new... Read more

Jobs Board

Licensed Practical Nurse - Womens Imaging *A...
Licensed Practical Nurse - Womens Imaging Apple Hill - PRN Location: York Hospital, York, PA Schedule: PRN/Per Diem Sign-On Bonus Eligible Remote/Hybrid Regular Read more
DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Operating Room Assistant - *Apple* Hill Sur...
Operating Room Assistant - Apple Hill Surgical Center - Day Location: WellSpan Health, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular 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
DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.