ZBASIC Routines
Volume Number: 5
Issue Number: 7
Column Tag: BASIC School
Useful Routines For ZBASIC 
By Dave Kelly, MacTutor Editorial Board
Hello! Are any of you tired of switching back and forth between versions of
Basic? Although ZBasic still holds an edge over other Basics in the competition, there
are benefits in favor of using other Basics from time to time. The frustrating thing
about it is when you try to use a command, syntax, or subroutine with the wrong
version of Basic. It’s easy to do if you switch back and forth very often. It’s also
frustrating when your favorite function isn’t implemented the same (or not at all)
from what you are used to.
Charles Stricklin has sent in three functions which he wished were already
implemented in ZBasic. These have been designed to add to your ZBasic library of
routines. The GETINDSTRING$ function works similarly to the GETINDRESOURCE
function in the Macintosh toolbox. This routine allows easy retrieval of strings stored
in a ‘STR#’ resource.
The GETRESWINDOW and GETRESMENU functions will get WIND and MENU
resource data and interpret the resource to open up windows and setup menus using
standard ZBasic statements. This is useful if you would like to use resources like
‘real’ applications do.
The program demonstrates the use of these functions. In developing this and
through debugging the functions I am now even more aware of the missing capability to
include resources from a resource file when compiling with ZBasic. This is a
deficiency which I would hope Zedcor has as #1 on their ‘TO DO’ list. Charles also
listed this problem as high priority and wrote a short routine as a work around for the
meantime:
debugging = -1: ‘(or TRUE if defined previously)TRUE during
development.
“OpenResourceFork” :’used in development only
LONG IF debugging :’we’re still writing this
CALL PARAMTEXT(“Do you want to use a specific
resource”,”file?”,””,””)
myAnswer = FN CAUTIONALERT(3,NIL) :’gets my answer from alert
LONG IF myAnswer =1 :’I said “YES”
resourceFilename$ = FILES$(1,”rsrc”,, volume) :’gets a filename
‘( created with ResEdit)
refNum = FN OPENRESFILE( resourceFileName$) :’and opens it’s
‘resource fork
END IF :’(myAnswer = 1)
END IF :’(debugging)
RETURN :’(“OpenResourceFork”)
Other items on the ZBasic “Wish List” include:
(to be fixed):
• The “Save Changes?” alert should only be called after the user has actually made
changes to an existing document... e specially not right after launching ZBasic
itself when opening an existing document.
• ZBasic doesn’t run reliably under MultiFinder. After several passes editing and
running, ZBasic aborts even with 2.5+ Meg memory allocated to ZBasic. I’ve
never had this happen when not running Multi finder. I suggest that Multi finder
be turned off when editing and debugging ZBasic programs.
(to be improved):
• The ‘Find’ command is somewhat useless without a ‘Change’ command.
• The editor, even with the vast improvements over earlier versions, is still
clumsy in several (many) areas.
• The default tab settings are a nuisance. This should be user definable.
• Editing would be much easier if more than one edit window (different files too)
could be open at the same time.
• Lower the price. The ToolBox Editor should have been part of the package to begin
with. The Program Generator is useful if you don’t already have your own
custom BASIC shell defined.