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

Whitethorn Games combines two completely...
If you have ever gone fishing then you know that it is a lesson in patience, sitting around waiting for a bite that may never come. Well, that's because you have been doing it wrong, since as Whitehorn Games now demonstrates in new release Skate... | Read more »
Call of Duty Warzone is a Waiting Simula...
It's always fun when a splashy multiplayer game comes to mobile because they are few and far between, so I was excited to see the notification about Call of Duty: Warzone Mobile (finally) launching last week and wanted to try it out. As someone who... | Read more »
Albion Online introduces some massive ne...
Sandbox Interactive has announced an upcoming update to its flagship MMORPG Albion Online, containing massive updates to its existing guild Vs guild systems. Someone clearly rewatched the Helms Deep battle in Lord of the Rings and spent the next... | Read more »
Chucklefish announces launch date of the...
Chucklefish, the indie London-based team we probably all know from developing Terraria or their stint publishing Stardew Valley, has revealed the mobile release date for roguelike deck-builder Wildfrost. Developed by Gaziter and Deadpan Games, the... | Read more »
Netmarble opens pre-registration for act...
It has been close to three years since Netmarble announced they would be adapting the smash series Solo Leveling into a video game, and at last, they have announced the opening of pre-orders for Solo Leveling: Arise. [Read more] | Read more »
PUBG Mobile celebrates sixth anniversary...
For the past six years, PUBG Mobile has been one of the most popular shooters you can play in the palm of your hand, and Krafton is celebrating this milestone and many years of ups by teaming up with hit music man JVKE to create a special song for... | Read more »
ASTRA: Knights of Veda refuse to pump th...
In perhaps the most recent example of being incredibly eager, ASTRA: Knights of Veda has dropped its second collaboration with South Korean boyband Seventeen, named so as it consists of exactly thirteen members and a video collaboration with Lee... | Read more »
Collect all your cats and caterpillars a...
If you are growing tired of trying to build a town with your phone by using it as a tiny, ineffectual shover then fear no longer, as Independent Arts Software has announced the upcoming release of Construction Simulator 4, from the critically... | Read more »
Backbone complete its lineup of 2nd Gene...
With all the ports of big AAA games that have been coming to mobile, it is becoming more convenient than ever to own a good controller, and to help with this Backbone has announced the completion of their 2nd generation product lineup with their... | Read more »
Zenless Zone Zero opens entries for its...
miHoYo, aka HoYoverse, has become such a big name in mobile gaming that it's hard to believe that arguably their flagship title, Genshin Impact, is only three and a half years old. Now, they continue the road to the next title in their world, with... | Read more »

Price Scanner via MacPrices.net

B&H has Apple’s 13-inch M2 MacBook Airs o...
B&H Photo has 13″ MacBook Airs with M2 CPUs and 256GB of storage in stock and on sale for up to $150 off Apple’s new MSRP, starting at only $849. Free 1-2 day delivery is available to most US... Read more
M2 Mac minis on sale for $100-$200 off MSRP,...
B&H Photo has Apple’s M2-powered Mac minis back in stock and on sale today for $100-$200 off MSRP. Free 1-2 day shipping is available for most US addresses: – Mac mini M2/256GB SSD: $499, save $... Read more
Mac Studios with M2 Max and M2 Ultra CPUs on...
B&H Photo has standard-configuration Mac Studios with Apple’s M2 Max & Ultra CPUs in stock today and on Easter sale for $200 off MSRP. Their prices are the lowest available for these models... Read more
Deal Alert! B&H Photo has Apple’s 14-inch...
B&H Photo has new Gray and Black 14″ M3, M3 Pro, and M3 Max MacBook Pros on sale for $200-$300 off MSRP, starting at only $1399. B&H offers free 1-2 day delivery to most US addresses: – 14″ 8... Read more
Department Of Justice Sets Sights On Apple In...
NEWS – The ball has finally dropped on the big Apple. The ball (metaphorically speaking) — an antitrust lawsuit filed in the U.S. on March 21 by the Department of Justice (DOJ) — came down following... Read more
New 13-inch M3 MacBook Air on sale for $999,...
Amazon has Apple’s new 13″ M3 MacBook Air on sale for $100 off MSRP for the first time, now just $999 shipped. Shipping is free: – 13″ MacBook Air (8GB RAM/256GB SSD/Space Gray): $999 $100 off MSRP... Read more
Amazon has Apple’s 9th-generation WiFi iPads...
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
Discounted 14-inch M3 MacBook Pros with 16GB...
Apple retailer Expercom has 14″ MacBook Pros with M3 CPUs and 16GB of standard memory discounted by up to $120 off Apple’s MSRP: – 14″ M3 MacBook Pro (16GB RAM/256GB SSD): $1691.06 $108 off MSRP – 14... Read more
Clearance 15-inch M2 MacBook Airs on sale for...
B&H Photo has Apple’s 15″ MacBook Airs with M2 CPUs (8GB RAM/256GB SSD) in stock today and on clearance sale for $999 in all four colors. Free 1-2 delivery is available to most US addresses.... Read more
Clearance 13-inch M1 MacBook Airs drop to onl...
B&H has Apple’s base 13″ M1 MacBook Air (Space Gray, Silver, & Gold) in stock and on clearance sale today for $300 off MSRP, only $699. Free 1-2 day shipping is available to most addresses in... Read more

Jobs Board

Medical Assistant - Surgical Oncology- *Apple...
Medical Assistant - Surgical Oncology- Apple Hill Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel 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
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
Business Analyst | *Apple* Pay - Banco Popu...
Business Analyst | Apple PayApply now " Apply now + Apply Now + Start applying with LinkedIn Start + Please wait Date:Mar 19, 2024 Location: San Juan-Cupey, PR Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.