TweetFollow Us on Twitter

System Snoop
Volume Number:4
Issue Number:11
Column Tag:Basic School

System Snooping in MS QuickBasic

By Dave Kelly, MacTutor Editorial Board

MS QuickBasic Arrives!!

It’s been a long wait (nearly a year and a half) but Microsoft has finally upgraded their infamous compiler. The best part is that it has really improved!! Microsoft took their interpreter which has always been an excellent product, and combined their compiler to produce what they are calling a new product named QuickBASIC 1.0.

There are some major changes that have taken place and many things have remained the same. The programming environment includes the same “pretty-printing” editor (with some improvements) which was included in earlier versions of the interpreter. There are still two versions of basic, the binary version and decimal version. Programs written using earlier versions of MS BASIC still function properly and in some cases they even work better. When you start listing all of the changes you can easily see why Microsoft chose to call it version 1.0 instead of MS Compiler version 2.0.

The first obvious change is the manual. MS QuickBASIC is now packaged as a shrink wrapped book and disk like their competitors. Most of the fancy packaging on software goes in the trash most of the time anyway. If removing the expense of the packaging lowers the price like it did for this one, I vote that all software companies do the same on all their software. QuickBASIC is priced at a mere $99!! Registered users of either MS Basic Interpreter or Compiler may upgrade to MS QuickBASIC 1.0 for $40. Upgrades are free to any registered user who acquired either of Microsoft’s BASIC products for the Macintosh after August 1, 1988. MS QuickBASIC now requires at least 1 MB of memory. The new manual includes two books in one. The user’s guide includes a description of how to use the interpreter/compiler functions, a tutorial on developing programs using QuickBASIC, a tutorial on debugging your program, creating a stand-alone application, documentation on how to access the Macintosh toolbox, and documentation for ResEdit (an older version is included with QuickBASIC) and Edit (QuickBASIC includes the latest version of the MDS editor which bombs on the Mac II). The second part of the manual is the BASIC Language Reference which includes a description of Basic variables, syntax, a statement and function reference, and appendix. The appendix contains documentation for invoking ROM routines and the Toolbox library, also some very good information about creating your own Libraries (similar to the old BMLL document) including how to write your own routines from Assembly, C or Pascal. Instructions are also given to install your own icon after compiling your stand-alone application.

The menu bar has now changed. As a matter of fact, when programs are run, a default menu is used which includes File and Edit menus. QuickBASIC removes its own menus so you no longer have to clear the menus when running your program as in earlier versions. Using the compiler options, you may disable the default menu and window for compiled programs.

The ‘Search’ menu contains new menu items, ‘Get Info’ and ‘Set Info’ which allows the user to add new items into the Help data base, or add comments to the help that already exists. The text added is stored in the BASIC source code itself so Help can be different for different programs. It is not known if the Help text can be moved from one source code file to another. The ‘Set Info’ item cannot be found in the manual and in some respects does not seem to work properly. Once it even corrupted the default help info which is stored in the QuickBASIC application. It is handy to type cmd-I (Get Info) while editing and get a dialog explaining the command that the cursor is pointing to. Another nice feature is the bookmarks. You can set a bookmark to force BASIC to remember the page that you are on so you can return there quickly.

The interpreter is able to help debug your program. For example, before executing the program, breakpoints may be set by inserting a stop sign icon. When the program stops at a breakpoint, or encounters an error, the value of key variables may be displayed. (This smells like Lightspeed doesn’t it?) You may then change the value of any variables and continue execution. The highlighted tracing option which was available in earlier versions of MS Basic is still available in QuickBASIC too.

Figure 1. Example Listing

One of the most needed enhancements was HFS support. Now, MS Basic is smart enough to find files anywhere. If you have a LIBRARY statement you don’t have to include the full path name because the first time your program is run, if QuickBASIC can’t find your library file, it asks you to look for it. Then it does something even better. After you find the file for QuickBASIC, the path is stored away automatically in your source code file and used the next time the program is run. There may have to be some slight modification to some programs written in earlier versions of BASIC, so QuickBASIC provides a way to disable the File Not Found Dialog option in the ‘Options’ menu item of the ‘Run’ menu.

The compiler is built in so it is very easy to get a stand-alone application up and running. There are several options available when compiling, including 68020 and 68881 support if you can use it. Most of the same compiler options are available here that were available in MS Compiler 1.0. As mentioned before, you may choose to use the default window or use the default menus (File and Edit) if needed. Library resources may be included if the ‘Include MBPCs and MBLCs’ option is selected. (All the CLR Toolbox libraries have been updated and the resource type changed to MBLC (Microsoft Basic Library Code????) resources. The MBPC type is used to denote pure code resources which can be created with some compilers. A utility program is included to scan a QuickBASIC source file and remove library and toolbox resources which are not used by the application. This will reduce the size of the stand-alone application. ALSO, the toolbox library (formerly called ToolLib) is now installed as MBLC resources in the QuickBASIC application. Therefore, all the toolbox statements are available at all times. You now need to specify a type (‘&’,’!’, ‘#’) for a library call only after DEFSTR; DEFINT no longer requires a type. For example:

DEFINT a-z
DrawText “No more exclamations on library invocations!”

There have been several new MBLC routines added to QuickBASIC since the last release of MS BASIC. One of these new statements is the Toolbox statement which allows access to other Toolbox ROM routines which are not specifically available as MBLC routines. You will need Inside Macintosh to make full use of this statement. Routines marked NOT IN ROM are not accessible from QuickBASIC with the ToolBox call. You must write an MBPC or MBLC to do this. The syntax for the ToolBox statement is:

ToolBox calltype$, trapnum%, arg1, arg2, ... , argn

The calltype$ argument is a BASIC string variable indicating the type of the ROM call. Procedures are indicated by either “P” or “S”, Functions returning boolean results use “B”, functions returning integers use “W” and functions returning a long integer (LONGINT) use “L”. The trapnum% is the trap address of the ROM routine as found in Inside Macintosh. A few samples are given in the manual of some ROM calls. The number of arguments in the ToolBox call will vary depending on the routine that is called.

Sample programs using the ToolBox call are shown below. The first program shows a call to the ROM routine that gets the names of fonts if given an id. The program really isn’t of much value except to demonstrate an example use of the ToolBox call. [Make sure to remove all non-printable fonts from the system (i.e. postscript escape fonts) or it will crash; I think it has something to do with zero width fonts.- ed] The second program uses the ToolBox call to get the Macintosh tick count. By using this the benchmark times could have been measured more accurately. The remainder of the program demonstrates the use of the SYSTEM function. The SYSTEM function is used to get system environment information for your program. Getting screen size is one use of the SYSTEM functions available. Other environment information is also available as shown in the program. These functions and the ToolBox calls are explained in more detail in the QuickBASIC manual.

Your old CLR libraries and other libraries you may have created can still be used with QuickBASIC without converting them to the MBLC resource type. Be sure to check to see if the routine already exists in QuickBASIC as a MBLC before using your old routine unnecessarily. You may print lists for comparison purposes with the new version of the Statement Mover program. Statement mover has also been updated to support the MBLC and MBPC resource types.

You’re probably wondering how QuickBASIC does in the benchmark tests. Table 1 shows the benchmark results for QuickBASIC , True Basic and ZBasic. ZBasic and True Basic times have appeared in previous issues of MacTutor and were not retested for this table. I have included them here for comparison purposes. Keep in mind that any one benchmark test does not determine how good a language is. All tests were performed on a Macintosh Plus Computer.

BENCHMARKMS QuickBASIC*True BasicZBasic
FOR Loop (Real)3 sec1.6 sec.15 sec.
Array Lookup (static)2 sec.20.67 sec.1 sec.
Math Operations
Addition9 sec.22.15 sec.52 sec.
Subtraction10 sec.23.23 sec.64 sec.
Multiply12 sec.25.55 sec.211 sec.
Divide35 sec.35 sec.446 sec.
String Operations
Concatenation34 sec.10.3167 sec.10 sec.
Pattern Matching25 sec.12.15 sec.6 sec.
Graphics
Line (Basic stmt)7 sec.61.25 sec.6 sec.
Horizontal line15 sec.38.867 sec.5 sec.
Circle20 sec.13.4667 sec.15 sec.
Set Pixel
(PSET or PLOT)38 sec.119.3 sec.19 sec.
File I/O (Floppy Disk)
Random READ2 sec.24.5 sec.8 sec.
Random WRITE24 sec.43.48 sec.114 sec.
Seql. PRINT#3 sec.17.0667 sec.9 sec.
Seql. INPUT3 sec.17.45 sec.???
Sieve of Eratosthenes8 sec.118.917 sec.7 sec.
Accuracy Benchmark
x503.54380215503.54380215503.54380215
s1.231.2249999999999661.23
time 1 sec..88333 sec.4 sec.

* NOTE: QuickBASIC compiled binary version used for all tests except accuracy benchmark.

To obtain optimal performance from compiled QuickBASIC for execution speed it is advisable to use static arrays, turn off array bounds, turn off event checking, generate 68020 and 68881 code if applicable, use SELECT CASE statements instead of IF/THEN/ELSE statements inside loops, and use SHARED (global) arrays when passing to subprograms.

‘ Display Fonts
‘ ©Copyright 1988 MacTutor
‘ by Dave Kelly
‘ This program will display all your system fonts
‘ with a sample and by name.
‘ This program uses the ToolBox statement in
‘ QuickBASIC version 1.0

ToolBox “I”    ‘ Initialize Toolbox
DEFINT a-z
x=0
FontName$=””
FOR i=0 TO 254    ‘ Cycle through all the fonts
    TEXTFONT(i)
    GOSUB GetFontsname
    IF FontName$<>”” THEN
        PRINT “This is a sample of font #”;
        CALL TEXTFONT(0):PRINT i;”  “;FontName$
        IF x/10 >1 THEN
             x=0:PRINT “Click mouse button to continue...”
             WHILE MOUSE(0)<>1 :WEND:CLS
         ELSE
             x=x+1
        END IF
    END IF
NEXT
WHILE MOUSE(0)<>1:WEND
END
GetFontsname:    ‘Get the name of the Font with ID = i
TrapNo%=&HA8FF
ToolBox “P”,TrapNo%,(i),FontName$
RETURN


‘ System Configuration Demo
‘©1988 MacTutor
‘ By Dave Kelly
‘ This program displays all of the system configuration
‘ data which is returned by the SYSTEM Function.
‘ Also the number of tick counts is read from the
‘ Macintosh directly to get a more accurate time.

ToolBox “I”:    ‘Initialize the toolbox call
start&=0&:finish&=0&
CALL GetTickCount(start&)   :’Call the tick count routine
Screenwidth=SYSTEM(5) :  ‘ get screenwidth
Screenheight=SYSTEM(6) :  ‘ get screen height
WINDOW 1,”System Configuration”,(4,41)-(Screenwidth-8,Screenheight-8),1
PRINT “Macintosh System Version:”;SYSTEM(0)
machine=SYSTEM(1) :   ‘ get machine type
SELECT CASE machine
    CASE 0
        machineType$=”Unknown”
    CASE 1
        machineType$=”Mac 512K”
    CASE 2
        machineType$=”Mac Plus”
    CASE 3
        machineType$=”Mac SE”
    CASE 4
        machineType$=”Mac II”
END SELECT
PRINT “Machine type: “;machineType$
PRINT “Running QuickBASIC version “;SYSTEM(2)
Math=SYSTEM(3):    ‘ Get Math type
SELECT CASE Math
    CASE 0
        MathType$=”Binary Math”
    CASE 1
        MathType$=”Decimal Math”
END SELECT
PRINT “Using “;MathType$
environmentFlag=SYSTEM(4)
    IF environmentFlag=0 THEN
        PRINT “Program is being run from the QuickBASIC environment”
    ELSE
        PRINT “Program has been compiled.”
    END IF
CALL GetTickCount(finish&)
PRINT “Total time to run this program was “;(finish&-start&)/60;” seconds”
END

SUB GetTickCount(Ticks&) STATIC:’Get the real number of ticks
    TrapNo%=&HA975
    Ticks&=0&
    ToolBox “L”, TrapNo%,Ticks&
END SUB

LETTER BAG

Your review of True Basic 2.01 was of special interest to me because I’ve been trying to port a library of thirty astronomical programs from CBasic (remember?) and MS Basic to the Mac. As you pointed out, the math libraries and advanced toolkits make True Basic very useful for scientific tasks. However, the many arbitrary differences in syntax from standard Basics has made the translating task very time-consuming and the source level debugging using DO TRACE is crude compared to MacPascal or LSP.

My greatest disappointment has been the poor speed performance. My Mac has the Turbomax accelerator board and 68881 coprocessor both rated at 16 mhz. Since my work involves heavy use of transcendentals, I use the Savage benchmark; here are some results:

MacPascal 2.0 30.1 seconds interpreted

True Basic 2.01 29.1 seconds *

Excel 1.04 12.6 seconds supports 68881

LS Pascal 1.1 4.7 seconds compiled

* This is “It’s even faster than before.” as their ad claims?

Incidentally, they carefully modified the Geneva font so that the capital O and zero [0] are identical; a real ‘gotcha’ when trying to debug. --Leonard Kalish

Maybe QuickBASIC will be better for you as it can be compiled. Also if you use CLR Libraries MathStatLib you get some of the math routines back. The difference in the Basic syntax is because of the ANSI standard influence of Thomas E. Kurtz, one of True Basic’s authors. It is interesting that most of the other Basics out there are enough different from the ANSI standard to make translating a difficult task. Thanks for your comments. DK.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Fresh From the Land Down Under – The Tou...
After a two week hiatus, we are back with another episode of The TouchArcade Show. Eli is fresh off his trip to Australia, which according to him is very similar to America but more upside down. Also kangaroos all over. Other topics this week... | Read more »
TouchArcade Game of the Week: ‘Dungeon T...
I’m a little conflicted on this week’s pick. Pretty much everyone knows the legend of Dungeon Raid, the match-3 RPG hybrid that took the world by storm way back in 2011. Everyone at the time was obsessed with it, but for whatever reason the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for July 19th, 2024. In today’s article, we finish up the week with the unusual appearance of a review. I’ve spent my time with Hot Lap Racing, and I’m ready to give my verdict. After... | Read more »
Draknek Interview: Alan Hazelden on Thin...
Ever since I played my first release from Draknek & Friends years ago, I knew I wanted to sit down with Alan Hazelden and chat about the team, puzzle games, and much more. | Read more »
The Latest ‘Marvel Snap’ OTA Update Buff...
I don’t know about all of you, my fellow Marvel Snap (Free) players, but these days when I see a balance update I find myself clenching my… teeth and bracing for the impact to my decks. They’ve been pretty spicy of late, after all. How will the... | Read more »
‘Honkai Star Rail’ Version 2.4 “Finest D...
HoYoverse just announced the Honkai Star Rail (Free) version 2.4 “Finest Duel Under the Pristine Blue" update alongside a surprising collaboration. Honkai Star Rail 2.4 follows the 2.3 “Farewell, Penacony" update. Read about that here. | Read more »
‘Vampire Survivors+’ on Apple Arcade Wil...
Earlier this month, Apple revealed that poncle’s excellent Vampire Survivors+ () would be heading to Apple Arcade as a new App Store Great. I reached out to poncle to check in on the DLC for Vampire Survivors+ because only the first two DLCs were... | Read more »
Homerun Clash 2: Legends Derby opens for...
Since launching in 2018, Homerun Clash has performed admirably for HAEGIN, racking up 12 million players all eager to prove they could be the next baseball champions. Well, the title will soon be up for grabs again, as Homerun Clash 2: Legends... | Read more »
‘Neverness to Everness’ Is a Free To Pla...
Perfect World Games and Hotta Studio (Tower of Fantasy) announced a new free to play open world RPG in the form of Neverness to Everness a few days ago (via Gematsu). Neverness to Everness has an urban setting, and the two reveal trailers for it... | Read more »
Meditative Puzzler ‘Ouros’ Coming to iOS...
Ouros is a mediative puzzle game from developer Michael Kamm that launched on PC just a couple of months back, and today it has been revealed that the title is now heading to iOS and Android devices next month. Which is good news I say because this... | Read more »

Price Scanner via MacPrices.net

Amazon is still selling 16-inch MacBook Pros...
Prime Day in July is over, but Amazon is still selling 16-inch Apple MacBook Pros for $500-$600 off MSRP. Shipping is free. These are the lowest prices available this weekend for new 16″ Apple... Read more
Walmart continues to sell clearance 13-inch M...
Walmart continues to offer clearance, but 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 MacBooks... Read more
Apple is offering steep discounts, up to $600...
Apple has standard-configuration 16″ M3 Max MacBook Pros available, Certified Refurbished, starting at $2969 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free,... Read more
Save up to $480 with these 14-inch M3 Pro/M3...
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
Amazon has clearance 9th-generation WiFi iPad...
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
Apple is offering a $50 discount on 2nd-gener...
Apple has Certified Refurbished White and Midnight HomePods available for $249, Certified Refurbished. That’s $50 off MSRP and the lowest price currently available for a full-size Apple HomePod today... Read more
The latest MacBook Pro sale at Amazon: 16-inc...
Amazon is offering instant discounts on 16″ M3 Pro and 16″ M3 Max MacBook Pros ranging up to $400 off MSRP as part of their early July 4th sale. Shipping is free. These are the lowest prices... Read more
14-inch M3 Pro MacBook Pros with 36GB of RAM...
B&H Photo has 14″ M3 Pro MacBook Pros with 36GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 Pro MacBook Pro (... Read more
14-inch M3 MacBook Pros with 16GB of RAM on s...
B&H Photo has 14″ M3 MacBook Pros with 16GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $150-$200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 MacBook Pro (... Read more
Amazon is offering $170-$200 discounts on new...
Amazon is offering a $170-$200 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1129 for models with 8GB of RAM and 256GB of storage: – 15″ M3... Read more

Jobs Board

*Apple* Systems Engineer - Chenega Corporati...
…LLC,** a **Chenega Professional Services** ' company, is looking for a ** Apple Systems Engineer** to support the Information Technology Operations and Maintenance 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
*Apple* / Mac Administrator - JAMF Pro - Ame...
Amentum is seeking an ** Apple / Mac Administrator - JAMF Pro** to provide support with the Apple Ecosystem to include hardware and software to join our team and 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
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
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.