Microsoft QuickBasics Knowledge Base for Apple Macintosh

About this program
Bug. String manipulation slower in compiler versus interpreter {20456}
Name, Files${1}, file types, in Macintosh Basic {20503}
Files saved as text are always loaded tokenized in interpreter {20505}
Return and Enter not detected by Inkey$ if a Button is present {20514}
Printing control characters and suppressing Returns in Mac Basic {20519}
Using "LPT1: Prompt", Draft Character Width Differs from Best {20520}
Redirecting fonts and grapchics to printer with Window Output# {20521}
Control characters to reset page length for multi-page Llist {20522}
Unusual, compressed Llist or Lprint output after grapchics dump {20523}
Lprint Chr${9} converts Tab to spaces; "Lpt1:Bin" workaround {20526}
Sound and Wave common questions and problems in Macintosh Basic {20537}
"System Error" with inadvertent implied Call, C-D=E, B=2;B {20538}
"Type Mismatch" passing numeric constants in Call statement {20539}
Labels and line numbers must be unique, even across subprograms {20540}
On Event Gosub, On Error Goto labels must be in main program {20541}
Invoking slashed zeros in character mode, ImageWriter printer {20542}
Listing of Macintosh system error {bomb} ID numbers {20546}
How to use "Com1" serial communications in Macintosh Basic {20549}
Timer sometimes returns number one less than previous value {20551}
Fix. Print Erl,X gives syntax error in Macintosh QuickBasic {20562}
MS Chart cannot use double precision clipboard numbers {20565}
Supplemental reference books and disks for Macintosh Basic {20566}
Timing accurate to 1/60 seconds using Peek or ToolBox call {20572}
Reading Macintosh sequential files Randomly and vice versa {20573}
"String formula too complex" passing string constants {20575}
How to print to an Apple LaserWriter {20584}
Bug. Window Output goes to wrong window in interpreter, Apple {20591}
Fix. ElseIf syntax error marked on IF line in interpreter {20592}
AppleTalk printer 60-second time-out kills Mac Basic printing {23449}
Determining Macintosh Rom version, 64K or 128K, from Basic {25341}
Rnd and Randomize alternatives for generating random numbers {28150}
How to derive inverse {ARC} and hyperbolic trigonometry functions {28249}
No Lprint, Llist, "Lpt1:Direct" allowed in AppleTalk Network {28982}
How to get logarithm Base 10 using Log{x#} and Log{10#} in Basic {31660}
Inverse of x$ = Hex${n} is Val{"&H"+x$}; inverse for octal... {31783}
Converting between decimal, octal, and binary numbers {31789}
On "event" Gosub suspended until Input or Input$ is satisfied {31885}
Macintosh QuickBasic system error 12 using Init or Old Finder {31887}
"Subprogram already in use" with recursive Sub Call {31888}
Undo command is unavailable except for desk accessories {31927}
Difference between decimal and binary Macintosh QuickBasic {31928}
Purpose of the Apple editor's time stamp command {31932}
Macintosh QuickBasic 1.00 new features {31934}
How to create custom alert boxes with ResEdit {31935}
Macintosh QuickBasic 1.00 system requirements {31937}
"Invalid function call" listing window of file saved protected {31938}
Common required and Chained compiled program not interpreter {32220}
Passing Dynamic and Static arrays in Common; Macintosh Basic {32222}
Mac Basic interpreter allocates Dynamic arrays, never Static {32223}
System restart or shutdown from Mac QuickBasic program {32264}
Using command window to change variable while debugging {32269}
Cannot view data files in the list window; use another editor {32325}
Function...End Function not supported by QuickBasic 1.00, Apple {32326}
How to Clear maximum amount of data space; heap space {32327}
TextFace{2} must be used with TextMode{1} in Macintosh Basic {32401}
Printing to Apple LaserWriter supports only PenMode 8 {copy} {32402}
$Page metacommand puts page headers in compiler listings {32403}
Using static and dynamic arrays in compiler and interpreter {32416}
"Invalid character" in compiler on Dim for dynamic array {32417}
No List, Llist, Merge, New, Tron, Troff in Basic compiler {32418}
Sound truncation end of compiled program, OK interpreter {32419}
Pattern editor, Resedit; how to create new pattern {32468}
Use "Check arrays & overflow" option with arrays {32500}
"Inside Macintosh" made easy; "Technical Introduction" {32536}
Using Files$ or Files to display filename or disk directory {32724}
"Type mismatch" using Boolean arguments in ToolBox Call {32728}
Use logical AND to determine which bits are set in an integer {32730}
"Statement not in a subprogram block"; order SUBs last {32790}
Bug. Dialog box static text not displayed in Macintosh Basic {32965}
Dialog and alert boxes in Macintosh QuickBasic {32966}
ToolBox statement "Illegal function call"; ToolBox "i" {32967}
How to find name of currently chosen Macintosh printer driver {32970}
How to send contents of a specified window to a printer {32971}
How to dump current Macintosh screen or window to printer {32972}
Only eight library files can be open at once {32973}
How to create a Macintosh pure code resource library {32974}
Multiple Resources with Same ID Number Saved in Resource File {32975}
DrawText Faster Than PRINT, Output to Screen or Printer {33018}
Eight colors available in QuickBasic on Macintosh II {33037}
Grapchics GET and PUT change colors to monochrome in QuickBasic {33038}
ForeColor changes colors for Line, Circle, and Pset {33039}
"File Code segments that conflict with QuickBasic" error {33040}
Program can hang during communications if not setup correctly {33041}
Changing text font for Macintosh QuickBasic listing window {33042}
Colors sent to Apple LaserWriter convert to black and whites {33043}
How to send PostScript commands to Apple LaserWriter printer {33047}
Using Rem $ignore On and Off metacommand in Macintosh QuickBasic {33048}
$option metacommand is similar to $long and $option {33049}
How to make a Macintosh QuickBasic program run faster {33050}
"Out of memory" using more than one Clear statement {33051}
"Can`t find file" OPENing new QuickBasic Random or Append file {33052}
Print or Beep "error 11" in QuickBasic compiled apl program {33053}
Macintosh system error, hang or no output; "Use default window" {33054}
QuickBasic's ToolBox statement cannot call routines not in Rom {33055}
ToolBox calls to system event functions fail in QuickBasic {33056}
Losing characters with Com1 communications in Macintosh Basic {33087}
Offset for Jump To... option appears incorrect after $include {33142}
"Hardware environment conflict" if no 68881 or 68020 {Mac} {33299}
"Illegal function call" when GetIcon of wrong icon ID {33300}
Using predefined standard patterns with Rom routines {33302}
Toolbox library routine string arguments have 255-byte limit {33304}
Field variables unavailable after random file is Closed {33305}
Print scrolls truncated text if window bottom covered {33623}
Edit Fields, Buttons stop Print scrolling in Mac QuickBasic {33624}
Handling ImageWriter LQ and LaserWriter printing problems in Basic {33630}
255 dimensions per array in interpreter, 7 in compiler {33735}
Macromaker Menu Item May Appear in Middle of Menus {33737}
Copying Macintosh Basic screen to Hercules screen on IBM PC {33813}
"Device unavailable", "Device I/O" network ImageWriter printing {34012}
Problems using ImageWriter grapchics mode; "Lpt1;Bin" {34013}
"Cones" Demo deliberately has "Invalid function call" {34016}
Bug. System error or hang with $check On metacommand and Sub program {34276}
Bug. Pressing BackSpace on breakpoint line del wrong character {34281}
Bug. highlighted text disappears when list window redisplayed {34282}
Readme file for QuickBasic compiler 1.00 for Apple Macintosh {34286}
Mac QB 1.00 Readme; resources stored in source and application {34287}
List "line"; moves to specified line in QuickBasic editor {34288}
Negative Math/Overflow in Compiled Program; OK in Interpreter {34290}
Using same source to Chain when both interpreted and compiled {34291}
Understanding floating point differences in Mac QuickBasic {34292}
Mac QB 1.00 Readme; System{7} returns resource file reference {34331}
Mac QB 1.00 Readme; compile statement mover program for speed {34332}
Mac QB 1.00 Readme; custom LIBinit and LIBterm; Library {34333}
Calling library routines with ! required only for Defstr {34334}
QuickBasic backcolor routine is faster than Rom backcolor {34335}
Mac QB 1.00 Readme; BlockMove works for overlapped memory {34336}
Mac QB 1.00 Readme; CopyFile moves both data and resource Fork {34337}
Mac QB 1.00 Readme; Eject routine for both Floppy disk drives {34338}
Mac QB 1.00 Readme; "Exists" routine tests if file exists {34339}
QuickBasic Forecolor routine is faster than Rom Forecolor {34340}
Mac QB 1.00 Readme; GetCatInfo and GetFCBInfo; GetpathName demo {34341}
Mac QB 1.00 Readme; GetChanRefNum; Open #; file reference # {34342}
Mac QB 1.00 Readme; GethandleSize gives size of a resource {34343}
ScrollText example to specify leading spacing in scroll bar {34344}
Mac QB 1.00 Readme; use SubLaunch to run any Mac application {34345}
Mac QB 1.00 Readme; "Out of memory"; changing Size resource {34346}
Mac QB 1.00 Readme; if Chain "Out of memory", change stack {34347}
Mac QB 1.00 Readme; Search menu features explained further {34348}
Mac QB 1.00 Readme; Command-K, no prompt if application exists {34349}
Mac QB 1.00 Readme; options... box add "Save before compiling" {34350}
Mac QB 1.00 Readme; Creating application and document icons {34351}
Mac QB 1.00 Readme; how to send screen grapchics to printer {34352}
Mac QB 1.00 Readme; how to resolve unknown error messages {34353}
Mac QB 1.00 Readme; Old library Code resources can hang {34354}
Mac QB 1.00 Readme; Single-Voice sound hang if Tmon active {34355}
Mac QB 1.00 Readme; changing names of QB run-time libraries {34356}
Bug. First PRINT after resizing output window is lost {34606}
Adding more lines of statement Help in QuickBasic "Set Info..", {Mac} {34607}
Bug. Syntax error loop using option characters in interpreter {34608}
Bug. "Device I/O" error when save with MS Mail and not on network {34609}
How to make QuickBasic smaller to fit on bootable floppy disk {34812}
Bug. Extra insertion point on list window {34959}
Fix. Window 1 or 7 size box looks incorrect in compiled app {35324}
Bug. $ Not bold in Edit$, Files$, Input$, Picture$ {35325}
Fix. Syntax error Time$ to Time$$ loading compressed 2.00 file {35326}
Fix. Shift+Double-click selects vertical box wrong InsertPoint {35328}
Bug. Decimal math QuickBasic, Print Using "long int" gives 0 {35329}
Bug. CINT "long" bad value or run error 6 compiled for 68020 {35330}
Fix. Mac QuickBasic "Line too long" pasting on breakpoint line {35358}
QuickBasic incompatible with Radius, Prodigy Accelerator board {35439}
Macintosh directory list and file search across folders and drives {35509}
Bug. Binary QuickBasic default compiled exponent {^} bad {35516}
Memory Map Correction for Mac QuickBasic Compiled Applications {35626}
"Out of data"; incorrect Call example Mac QuickBasic page 61 {35657}
QuickBasic "Device I/O error" using CloseResFile on source {35659}
Do Loop and Exit While not supported in Macintosh QuickBasic {35660}
@, ], and [ do not have special meanings in Mac QuickBasic {35661}
"Clip" clipboard contents not available across MultiFinder {35712}
SubLaunch may not work in MultiFinder, but works in Finder {35717}
FOR with conditional IF...Then Next causes problems {35718}
Macintosh QuickBasic may load wrong or unexpected file {35719}
Changing QuickBasic's Size resource to Help "Out of memory" {35720}
Explanation of resources stored in Macintosh QuickBasic 1.00 {35762}
Basic cannot make desk accessory, Pure code, or Xcmd resource {35810}
Sound Wait fails without Multivoice mode in Macintosh Basic {35829}
How to obtain names and sizes of all current Macintosh fonts {35875}
Complete QuickBasic program to browse and expand Get Info.. Help {35898}
How to make PostScript escape font for QuickBasic application {36027}
RemLine Mac Basic program removes unused line numbers {36047}
Macintosh QuickBasic cannot compile in MultiFinder's background {36079}
System{7} or OpenResFile gives resource file reference number {36080}
How to compile a batch of files with Macintosh QuickBasic {36333}
When Macintosh QuickBasic 1.00 might forget compiler options {36334}
How to avoid "String too long" using Picture$ function {36349}
Why Imported color and gray scale picture fails to draw in Basic {36350}
How to load programs faster for compilation in Mac QuickBasic {36359}
How to use HfsDispatch to create a Macintosh folder {36392}
How the Macintosh QuickBasic GetpathNames program works {36394}
How to use Rem or ' comments in Data statements without error {36395}
Program to compile QuickBasic programs from Macintosh desktop {36644}
Macintosh QuickBasic does not use Sane for floating point math {36735}
Mac QuickBasic reserved words with asterisk means not implemented {37299}
QuickBasic maximum string size is 32767; 255 saved as resource {37300}
Why QuickBasic's "Generate 68881 code" option dims out {37301}
QuickBasic 1.00 is not compatible with AppleShare file Server {37303}
A handle points to a pointer to a Macintosh Heap block {37311}
Example of Toolbox register Rom call for date and time conversion {37312}
QuickBasic string descriptor has six bytes; 3.00 has Five {37313}
Metacommands ignored inside Macintosh QuickBasic interpreter {37314}
Macintosh QuickBasic example to create and use scroll Bars {37315}
Fix. Page setup isn't supported in Macintosh QuickBasic env {37317}
How to input image from clipboard, output to screen or file {37318}
Bug. dynamic array element in Oct$ and Hex$ return bad if compiled {37320}
Rem $Include versus Merge in QuickBasic compiler and interpreter {37425}
"File not found" or hang using Init with Macintosh QuickBasic {37884}
Macintosh QB limits for names, strings, numbers, arrays {37895}
Input statement removes unquoted leading and trailing spaces {37897}
Macintosh QuickBasic change; register-based ToolBox Rom call {38070}
DialoB should be DialoG on page 77 "QB for Macintosh Ref" {38077}
Must Initialize Toolbox-Routine Parameters; GetDirName Sample {38374}
Statement Mover is in Tools folder, not in QB demos folder {38499}
About, Wait are reserved and unimplemented; Renum misspelled {38500}
Changing Macintosh system can make QuickBasic fail to run {38641}
Example ToolBox routine for moving a Window; system can bomb {39094}
How to pop up a desk accessory from Macintosh QuickBasic {39095}
Fix. Command+Period during Lprint may hang Mac QuickBasic {39096}
Fix. Bad compiled floating point with static arrays and 68020 code {39097}
Timer example; Sieve of Eratosthenes prime number correction {39188}
No line continuation in Macintosh QuickBasic; break long Field {39240}
Macintosh QuickBasic manual correction; Array1, Array2 sizes {39242}
Figure 7.30 is non-existent; should be corrected to figure 2.20 {39243}
Macintosh QuickBasic runs OK on the Macintosh IIX computer {39360}
Mac QuickBasic file browser example views and prints text files {39363}
Use "Lpt1:Prompt" for mailing labels and other printer paper sizes {39576}
Bug. Extra $ with Print Using "$$" format in Mac QuickBasic {39589}
Bug. MBPC Library fails in compiled Mac QuickBasic without Libinit {39870}
Library statement "Input past end" if bad or empty library {40038}
Closing active Macintosh window doesn't Activate other window {40080}
Refresh Basic Windows with On DialoG Gosub or SetWindowPic {40083}
Fix. Date2Secs MBLC, bad seconds for Secs2Date {40086}
Bug. DragGrayRgn works differently in QuickBasic {40140}
Bug. OpenResFile "Bad file mode" opening Macintosh application {40271}
Macintosh alternate video buffer not supported by QuickBasic {40372}
Scroll bar cannot be placed in right bar of Window type 1 or 7 {40373}
Bug. Mac QuickBasic renamed file reverts to old compiled name {40409}
Reviews of Macintosh QuickBasic 1.00 in MacWorld and byte {40412}
Bug. SetOrigin diff in compiled versus interpreted Mac QuickBasic {40712}
Macintosh Basic example to Tab between multiple Edit Fields {40713}
In Macintosh Basic, Files${0} doesn't create file; Open does {40714}
Locked printer driver file can hang Macintosh QuickBasic {40715}
How to change "About application..." using ResEdit {40720}
Bug. Mac QuickBasic compiled decimal math Div error 1D+62 between x {40722}
Compiling Mac QuickBasic program with !Vaccine C_DEV installed {40724}
Macintosh QuickBasic program to hide and unhide file in Finder {40887}
How to Print superscript and subscript Letters in Mac QuickBasic {40889}
If communications buffer overflows during output to "Com1" {40897}
How to poll Mouse{0} to detect single, double, triple click {40951}
AppleTalk network connects Apple Macintosh and printers {41042}
Macintosh QuickBasic "Packing List", release disk contents {41392}
Screen width and height for Macintosh Plus, SE, and II {42322}
"Bad file name or number" {error 52} if Cancel "Lpt1:Prompt" {42361}
Debugging system errors in compiled programs with Mac Debugger {42364}
"Invalid function call"; OpenResFile makes empty file; path {42462}
How Macintosh QuickBasic uses resource and data Forks of files {42463}
OpenResFile; resources may save incorrectly in interpreter {42464}
How to print or view QuickBasic compiler "lst" listing file {Mac} {42516}
Use long integer with Peek, PeekW, and PeekL; Single can fail {42550}
Line Input #N drops null characters from file; use Input$ {42669}
Input and Line Input make Macintosh mouse pointer disappear {42702}
Cint and integer assignments round x.5 to nearest even integer {42732}
Triple clicking highlights entire line in QuickBasic editor {42804}
Opening "Com1" for a printer may print random characters {42854}
Bug. Window sizing affects Picture scaling in Macintosh Basic {42930}
QuickBasic example of grapchics output to disk and printer {42979}
BackPat sets pattern used by subsequent CLS, or ToolBox Erase {42983}
{Complete} Compile-time error chart for Macintosh QuickBasic {43020}
Making Pict resource with Picture$ picture and SavePicture {43021}
Input or Line Input erases existing line when accepting input {43025}
Decimal file format to binary file format {43202}
Fix. TextFont reset in interpreter on 2nd printed page {43204}
Language ref. page 35 has incorrect double precision format {43205}
How to align misaligned columns in Macintosh program output {43206}
Example of playing a sound resource in Macintosh QuickBasic {43253}
How to create ToolBoxNewOS, ToolBoxNewTool for new Rom calls {43561}
Bug. Double precision to power of integer Var fails compiled {43566}
QuickBasic for Macintosh is not multi-launchable on network {43689}
Lower-right pixels of rectangle not included in FrameRect {43697}
Directly connected ImageWriter LQ problem with Open "Lpt1:" {43744}
PtInRects returns incorrect value with multidimensional arrays {43747}
Error 35 "Subprogram not defined" compiling Cones program {43785}
Nvir resources result from infection by Nvir virus {43790}
Macintosh QuickBasic compiled program can give error line # {43792}
How to set and restore a clipping region in QuickBasic {44134}
EdHandle& missing from parameter list of TeSetSelect routine {44136}
Fix. Wrong line marked with error box in $include file {44213}
QuickBasic program to disable Apple menu from menu bar {44232}
QuickBasic program to delete Apple menu from menu bar {44233}
Bug. System{2} function incorrectly returns 4 interpreted {44356}
DialoG status is not reset in interpreter when program ends {44495}
Fix. "Type mismatch" on compile when subpgm has more than 25 params {44758}
System{} function returns Macintosh information {44796}
Instr{} function performs ASCII compare and is case sensitive {44799}
Bug. Zero frequency still plays Sound in Macintosh QuickBasic {45053}
ChangeCursor changes Macintosh mouse cursor to Wristwatch {45056}
Explanation of Top% in ToolBoxSampler example for QuickBasic {45058}
No Button Text Using Backpat and TextMode 3 on Macintosh II {45172}
QuickBasic AllocTempDesc gets descriptor of last string used {45173}
ToolBox Forecolor "Type Mismatch" using Col% instead of Col& {45174}
How to Eject a disk in only one drive in Macintosh QuickBasic {45175}
Bug. Csrlin can return incorrect value for TextSize not equal to 12 {45419}
Garbage assigning Val or single precision to double precision {45421}
Region {Rgn} routines not supported on Apple LaserWriter {45422}
How to use DisposePtr ToolBox to release NewPtr memory block {45425}
How to allocate a block of Heap using NewPtr ToolBox routine {45426}
Macintosh QuickBasic example for PicComment is incomplete {45444}
Print, Locate, then Print misaligned if TextSize changed {45477}
DiffRgn {region} example for Macintosh QuickBasic and Basic {45478}
TextWidth "Type mismatch" interpreted but not when compiled {45479}
How to draw border around Button in QuickBasic for Macintosh {45480}
DrawPicture,,corner%{0} correction for QuickBasic page 479 {45482}
File and file Creator type can be set within Lightspeed C {45484}
Bug. Mouse{0} doesn't reset in Reopened Window if compiled {45485}
Cannot use printer port for serial Com input in QuickBasic {45486}
How to round up a Fraction to its Integral Ceiling in Basic {45686}
Communications Open "Com1" also supports random access {45689}
Compiled Picture On statement renders Window border invisible {45691}
Bug. List window may not update correctly when using Bookmark {45893}
Edit$ returns "Invalid function call" in Nonactive window {45894}
Variable names starting with "FN" give "Syntax error" {45896}
Chain Merge can repeatedly append second program to first {45899}
Correction for StuffHex, ToolBox trap example on page 523 {45910}
Fix. X Mod 65536& gives system error ID=2 in interpreter {45947}
Get Info version number data can be changed using ResEdit {45949}
Definition of a Macintosh "Pure Code" resource {45950}
Bug. QuickBasic cannot print Lightspeed C's Sane floating point {46030}
"Text editor" index entry doesn`t belong in language reference {46373}
Sending control codes to ImageWriter I, II, LQ from QuickBasic {46815}
Fix. Cannot nest Select Case after Case Else in Mac QuickBasic {47059}
Font table correction for QuickBasic; Helvetica=21, Courier=22 {47061}
QuickBasic page 375 "rograms" should Say "Programs" {47121}
Table 7.1 reference should be 2.1 on QuickBasic page 126 {47123}
Double-clicking text file runs program of chosen Creator code {47352}
"Invalid function call" BitTst ToolBox example error, page 507 {47564}
Bug. Lcopy prints mouse cursor after HideCursor {47567}
Bug. Files${1} fails in interpreter on Mac II, IIcx, SE/30 {47662}
Bug. AlertMover's alert.- new file option doesn't make new file {Mac} {47751}
Fix. QuickBasic CopyFile routine may return bad error code {47752}
QuickBasic for Macintosh not supported under the Switcher {47757}
How to create pop-up menus in Macintosh QuickBasic {47782}
"Syntax Error" correction for QuickBasic printscreen example {47891}
Common MBLC ToolBox programming errors in Macintosh QuickBasic {47970}
How to read "Lpt1:Prompt" Dialog record, Macintosh QuickBasic {47971}
Foreign Alphabets, Option key, extended ASCII on Macintosh {47986}
How to center the printing of any font in QuickBasic {48013}
Adding ToolBox type Checking to QuickBasic's MBTS resource {48057}
Macintosh Basic MS Press Book References no longer Published {48726}
Prb. ScrollText and improper Return from On Event Gosub can bomb {48727}
Bug. QuickBasic Window type 2 disable switching with MultiFinder {49129}
Bug. When compiled, Line Input fails and hangs with 341 Iterations {49211}
No Watch in debug menu of QBI.exe interpreter Academic edition {49258}
Val function concatenates digits that have embedded spaces {49709}
Inkey$ cannot distinguish F1-F15 on Macintosh extended keyboard {49710}
LocalToGlobal and GlobalTolocal convert window and screen coordinates {49753}
How QuickBasic can use the 38 patterns in system Pat# resource {49888}
Bug. bad values returned in compiled decimal QuickBasic {49891}
Microsoft cannot update Apple ResEdit for Macintosh customers {50307}
Example of finding a file's type in Macintosh QuickBasic {50468}
Fix. CopyFile changes file type to "Text" in Mac QuickBasic {50469}
Picture On does not capture picture after Window change {50806}
How to make text gray with PenPat in Macintosh QuickBasic {50807}
How Basic's grapchics GET statement stores grapchics in an array {51412}
ResEdit cannot change some system fonts; Macintosh QuickBasic {51593}
How to Peek status of Command, Shift, Caps Lock, Option keys {51658}
How to list all Str# resources as GetIndstring and Getstring do {51731}
Cannot increase stack in interpreter {Macintosh QuickBasic} {52048}
Correction to Line statement example in Macintosh QuickBasic {52098}
Transferring files between Macintosh and Ms-Dos computers {57345}
Passing long integers between QuickBasic and MPW Pascal 3.00 {57347}
Passing single precision between QuickBasic and MPW Pascal {57348}
Passing double precision data between QuickBasic and MPW Pascal {57349}
Passing integers between QuickBasic and MPW Pascal 3.00 {57350}
Bug. Serialprinter driver from Word 3.x causes system error {57372}
Bug. Cursor from Input statement incorrectly displayed {57373}
Bug. Boolean expression using Val function returns wrong value {57374}
How to create a folder using HfsDispatch in Mac QuickBasic {57375}
Fix. Passing PeekL to a subprogram returns "Type mismatch" {57376}
Bug. Error generated using a Boolean expression in array index {57378}
Fix. Shift+Click to select text in 100 kbs file may fail {57380}
How to use CopyBits ToolBox call in Macintosh QuickBasic {57381}
Macintosh QuickBasic ToolBox call to trap any key press {57441}
"Invalid function call" using Edit Field bigger then 14 pixels Wide {57514}
Bug. Math with long-integer constants gives bad answer compiled {57710}
How to make Command+Key alternatives to Menus in Basic {57778}
Modifying file and edit menus in compiled QuickBasic programs {57779}
Bug. QuickBasic's Addstrings.C incorrect for MPW C Vers 3.00 {58036}
Bug. Correction for Rtrim and Ltrim QuickBasic utilities {58038}
How to open Macintosh QuickBasic data file with shared access {58177}
Hiding folders and changing other folder attributes with ResEdit {58212}
Correction for ToolBox statement example calling ScrollRect {58659}
Correction for PaintArc, QuickBasic ToolBox example, page 516 {58674}
Correction for ColorBit ToolBox argument on page 508 {58675}
How to Put an icon in a menu item using ToolBox statement {58677}
ToolBox "Type mismatch"; use VarPtr on array parameter {58820}
Correction for FillArc ToolBox example on page 511 "Reference" {58821}
GetFontname ToolBox example correction on page 514 "Reference" {58822}
SetDatetime ToolBox example correction on page 520 "Reference" {58823}
How to use Apple Symbol in menus; create custom Apple menu {58824}
Fix. Compiled QuickBasic Sys error on Macintosh IIci IIcx IIfx {59137}
Example of Savestring, Getstring, LoadString library routines {59286}
Example of alert, a QuickBasic ToolBox library {Mblc} routine {59287}
How to read binary files using Basics without Binary access {59290}
FramePoly and FramePgon don't Frame same polygon twice {59317}
Polygon routines don't affect Total Area of Framed polygon {59318}
Bug. Polygon Rom Calls top-justify within their rectangle {59319}
How to use "!C/P Script" MPW Script file, Macintosh QuickBasic {59322}
Basic &num constant defaults to &Onum {octal}, not &Hnum {Hex} {59403}
Passing long integers between Macintosh QuickBasic and MPW C {59486}
Passing single precision data between QuickBasic and MPW C {59487}
Passing integers between QuickBasic and MPW C version 3.00 {59533}
Bug. IF Then SUBname causes "Undefined Label"; requires Call {59757}
Bug. Width not reset in Mac QuickBasic interpreter; use 255 {59764}
Passing double precision data between QuickBasic and MPW C {60419}
Correction for "BasicMPWC.h" file producing error 261 {60420}
Correction to ForeColor ToolBox example {60426}
Bug. Probs using long integers in Mac QuickBasic 1.00 {60862}
Extra comma listed in description of alert ToolBox routine {61333}
Bug. Undefined subprogram Calling machine language using long {61334}
Bug. Cannot Erase passed arrays that are Dimmed in subprograms {61404}
Width statement incorrectly lists all parameters as optional {61658}
Scroll bar ToolBox routines for use only with ScrollText {61677}
Bug. Mac QB forgets clip region when changing between windows {62271}
Bug. Cannot Drag window across two monitors in compiled program {62951}
EOF{n} returns True on random file until GET is executed {63002}
Call PenMode and PenSize work with Call Line, not Circle or Line {63160}
Line Input #1 reads up to 32,767 characters into string {63621}
Macintosh QuickBasic 1.0A disk contents; released through PSS {64013}
GetDirname works only for Boot drive in Macintosh QuickBasic {64104}
Bug. QuickBasic interpreter allows duplicate line numbers {64431}
How to define a string array in Fields in a For...Next loop {64498}
Bug. Macintosh QuickBasic listing window corrupted during Edit {65936}
Macintosh QuickBasic printVerRec code resource prints garbage {65937}
ToolBox statement with wrong array can corrupt listing or hang {65938}
Bug. Macintosh 1000x1000 Window Snaps back to smaller size {65939}
No BasicLib.obj in Macintosh QuickBasic, Use BasicLib.Lib {65940}
Bug. Divide by zero hangs on SE/30 if compiled with 68881 option {65941}
Bug. Zero to zero power returns bad result if compiled with 68881 {65942}
Correction to QuickBasic Allocstring function Prototype {66228}
Bug. Circle{x,y},rad,,-0.1,0 draws only the radius in Basic {67374}
Macintosh QuickBasic converts "Clip:" clipboard Tabs to commas {67377}
"Illegal function call", negative number to Fractional power {67887}
Basic can write files for MS Excel Spreadsheet {68122}
Bug. Multiple Timer On resets On Timer Gosub in QuickBasic {69043}
Bug. QuickBasic cannot find; file dialog fails on System 6.0.7 {69113}
Bug. Incomplete edit menu in QuickBasic 1.0B and 1.0E compiled Pgm {69161}
Basic uses Radians, not Degrees, for trigonometric functions {69164}
Fix. Int{} rounds large negatives badly if compiled in 1.00 {69165}
How to get a Macintosh file's size without opening the file {69176}
Macintosh parameter-block record format {used by HfsDispatch} {69177}
How to get the names of all Mounted Macintosh disk Volumes {69211}
Grapchics Get and Put and Savearray and Loadarray example in QuickBasic {69584}
How to use a modeless dialog box in Macintosh QuickBasic {69602}
Fix. Macintosh QuickBasic 1.0B tested with IIcx, IIci, IIfx {71237}
Fix. Trace On in run menu Indicated when You Open a new file {71238}
Bug. Incorrect result, no "Overflow" error, in compiled app {71239}
Bug. Compiled error 57 68020 and 68881 option String${32767,32} {71240}
Fix. "Block Else/End IF must begin line" error message {71241}
Bug. Mouse{0} returns -1 after MouseUp on Modal dialog {71242}
Bug. Literal parameters not passed to nested subprogram calls {71243}
Bug. bad floating point result when using Static array {71568}
Macintosh QuickBasic error using HP "LaserJet IIP" Chooser {72678}
Bug. no sound using Sound statement in compiled Pgm on Mac LC {72680}
"Forst" "Path not found" correction on page 552, QuickBasic {72845}
Bug. Subpgm run-time "Error 35"; compiled with line length=255 {75413}
Bug. CopyFile fails with system Err 3 with binary Mac QB 1.0B {76667}
Bug. Compiled static array in SUB, Err 10 duplicate definition {77736}
Bug. When compiled, Print Chr${0} incorrectly concatenates {77877}
Sales specification for QuickBasic 4.50 for Ms-Dos available {77907}
QuickBasic can get date and time of Mac file's last Modification {78072}
Bug. Cannot Erase arrays in Subs Dimmed in main program {78133}
Bug. GetPicture "Invalid function call" after Chain {78387}
Bug. Mouse{0} with Window Output gives incorrect coordinates {79118}
Documentation error causes "Unprintable error" in QB for Mac {81954}
"Input past end of file" with Input #; use Line Input # {82001}
"Duplicate definition", Chain, dynamic array in Common {82912}
Bug. IF statement with Pos function problem in decimal QB {84384}
QuickBasic "Launch after compile" option fails on Mac System 7 {84552}
QuickBasic for Macintosh will not run with 32-bit addressing {84557}
Bug. System{1} function gives incorrect value in 1.0E Env {85154}
Mac QB 1.0E; cannot change options because file is Locked {90893}
Troubleshooting QB problems on Macintosh Quadra and Powerbook {92830}
How to Enable program compiled in Mac QB to run in background {94118}
Viewing file in QuickBasic environment can change spacing {94315}
Files${1} function doesn't work properly with System 6.0.8 {95332}
QuickBasic for Macintosh; drawing a Pict file larger than 32KBS {95482}


BUG: String Manipulation Slower in Compiler Vs Interpreter (20456)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    String manipulation functions can be several times slower in compiled programs than in interpreted programs. The speed of the compiled example below can be improved by 50 percent by compiling with the Microsoft QuickBasic Compiler 1.0 for Macintosh, instead of compiling with the earlier Microsoft Basic Compiler 1.0. However, the example compiled in QuickBasic is still five times slower than the interpreted version.

    Cause

    This speed problem is partly due to a tradeoff of code size versus speed. For example, the interpreter offers efficient extra code to handle strings quickly; the compiled program offers smaller code size but less efficient string handling. The interpreter itself takes much more disk space than the independent, compiled program.

    Status

    Microsoft has confirmed this to be a bug in Microsoft QuickBasic 1.0 for the Macintosh. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

    More information

    The string manipulation program below gives the following timing results on a Macintosh SE computer:
    Product                                      Timing Result
----------------------------------------------------------

QuickBasic 1.0 interpreter (binary)  25 seconds
Basic version 3.0 interpreter (b)            25 seconds
QuickBasic 1.0 compiler (b)          127 seconds
Basic version 1.0 compiler (b)               194 seconds
    The example below was compiled using the R option in the Basic compiler version 1.0 and using the equivalent Include the Runtime Code option in the QuickBasic compiler. The Process Runtime Events option was off at compile time.
    DEFINT I-J
Start=Timer
A$=SPACE$(10000)
FOR K=1 TO LEN(A$)
J=ASC(MID$(A$,K,1))
NEXT
PRINT TIMER-Start;"Seconds"
WHILE Mouse(0)=0 : WEND
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB20456
    ©2002 Microsoft Corporation. All rights reserved.


NAME, FILES$(1), File Types, in Macintosh Basic (20503)

Summary

This information applies to Microsoft QuickBasic 1.00, Basic compiler Version 1.00, and Basic interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

The NAME command can be used to change the file type of Basic files and programs. The FILES$(1) function displays files of a given type. By default, FILES$(1) shows files of type "Text". For an illustration, try PRINT FILES$(1).

Decimal Basic programs saved as Compressed have the type "MSBB", and ones saved as Protected have the type "MSBP". Binary Basic programs saved as Compressed have the type "MSBC", and ones saved as Protected have the type "MSBD". Applications like MacWrite, MacPaint, and Basic have the type "Appl".

The following Basic files have the type "Text":

  1. Basic programs saved as Text.
  2. Random and Sequential access files created by Basic. The Open window displays programs created in that version (decimal or binary) of Basic, plus files of type "Text".
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB20503


Files Saved as Text Are Always Loaded Tokenized in Interpreter (20505)

Summary

This article applies to the interpreter in Microsoft QuickBasic Version 1.00, and Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh.

Program files that are loaded into the interpreter environment are stored in memory in Compressed format -- even programs that are stored on disk in Text format. Text format programs on disk are converted into Compressed (or "tokenized") form when they are loaded into Basic. When you Save with Text format, the programs are converted from Compressed form in memory to Text form and written to the disk.

Programs saved in Compressed format load quicker that files saved in Text format. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB20505


RETURN and Enter Not Detected by INKEY$ If a Button Is Present (20514)

The information in this article applies to:
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft Basic Compiler 1.00

    • Summary

    The information below applies to the following products:

    1. Microsoft QuickBasic Compiler 1.00, 1.00a, 1.00b for the Apple Macintosh
    2. Microsoft Basic Compiler 1.00 for the Apple Macintosh
    3. Microsoft Basic Interpreter versions 2.00, 2.10, and 3.00 for the Apple Macintosh
    The INKEY$ function cannot detect the RETURN key (the Enter key on the main keyboard) or the Enter key (the Enter key on the numeric keypad) if there is also a Button on the same window, because Button traps the RETURN and Enter keys first. This priority of Buttons over the INKEY$ function is by design. Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB20514


Printing Control Characters & Suppressing RETURNs in Mac Basic (20519)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    Question:

    How can control characters be sent to the ImageWriter from Basic for the Macintosh? Is there any way to suppress the automatic carriage-return (ASCII 13) character?

    Response:

    The information below applies to the following products:
    1. Microsoft QuickBasic 1.00 1.00a 1.00b for the Apple Macintosh
    2. Microsoft Basic Compiler 1.00 for the Apple Macintosh
    3. Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh
    First, note that there are two modes of printing in Basic for the Macintosh:
    1. Basic character mode, which includes LPRINT, or output with PRINT#n or WRITE#n to the device name "Lpt1:Direct" or "Lpt1:Bin"
    2. Basic graphics mode, which includes output to the device name "LPT1:" or "Lpt1:Prompt" with PRINT#n, WRITE#n, or WindOW OUTPUT #n
    ImageWriter control characters Cannot be sent to the printer device name "LPT1:" or "Lpt1:Prompt", since these devices build a special bit-mapped image in a temporary disk file for output.

    ImageWriter control codes CAN be sent using LPRINT, or by OPENing "Lpt1:Direct" or "Lpt1:Bin" as #n and sending output with PRINT#n to a directly connected ImageWriter.

    The "Lpt1:Bin" device name outputs all characters, including the ASCII 9 (Tab), without translation. "Lpt1:Bin" is thus better than LPRINT or "Lpt1:Direct" to successfully output all control codes (such as for the task of sending ImageWriter-specific graphics control codes, byte by byte). "Lpt1:Bin" is not supported in the earlier Basic Compiler Version 1.00, but is supported in QuickBasic 1.00 and the earlier Interpreter Version 3.00.

    To print control characters to the printer with the LPRINT statement, you must usually suppress RETURNs on the printer with the WIDTH LPRINT 255 statement, as in the following example:
       WIDTH LPRINT 255   ' A width of 255 suppresses RETURNs.
   ' Printer control characters can now take effect. For
   ' example, Escape "Q" sets ultracondensed characters
   ' on the ImageWriter (See ImageWriter printer manual):
   LPRINT CHR$(27);"Q"
   WIDTH LPRINT 130   ' Reinvokes RETURNs, at 130th character.
   FOR I=1 TO 20 : LPRINT "1234567890"; : NEXT    ' Wrap demo.
   LPRINT : LPRINT
   LLIST              ' Prints this program in ultracondensed.
    LPRINT and "Lpt1:Direct" are supported on directly connected ImageWriter printers only; they are not supported for AppleTalk network devices such as AppleTalk ImageWriters and LaserWriters. Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB20519


Using "LPT1: Prompt", Draft Character Width Differs from Best (20520)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1

    • Summary

    The information below applies to the following products:

    1. Microsoft QuickBasic Compiler 1.00 1.00a 1.00b for the Apple Macintosh
    2. Microsoft Basic Compiler 1.00 for the Apple Macintosh
    3. Microsoft Basic Interpreter versions 2.00, 2.10, and 3.00 the Apple Macintosh
    When you OPEN "Lpt1:Prompt" FOR OUTPUT AS #n, the spacing of the characters using Draft mode differs from that of Faster and Best modes. The spacing difference occurs because when you select Draft mode, the ImageWriter printer driver supplied by Apple lines up the letters in the same place as they appear in Faster or Best quality modes. Since M's and W's are narrower in Draft mode, a space will follow them.

    To demonstrate this behavior, run the following example twice, the first time choosing Faster or Best from the dialog box, and the second time choosing Draft mode:
       OPEN "Lpt1:Prompt" FOR OUTPUT AS #1
   PRINT #1,"Note the spacing of the letters in Draft:"
   PRINT #1,"M.M.m.m.W.W.w.w.i.x.1234567890"
   CLOSE #1
    (In the version 2.30 ImageWriter driver that comes with Finder version 5.3, the higher quality modes are called Faster and Best. The higher quality modes were called Standard and High in the older ImageWriter driver that came with version 4.1 of the Finder.) Modification Type: Major
    Last Reviewed: 12/11/2003
    Keywords: KB20520
    ©2003 Microsoft Corporation. All rights reserved.


Redirecting Fonts and Graphics to Printer with WindOW OUTPUT# (20521)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    You can redirect the sending of fonts or graphics from the current output window to the Macintosh printer.

    You can first OPEN "Lpt1:Prompt" or "LPT1:" as device #n, and then use WindOW OUTPUT #n to redirect output to the printer device, as shown in the example below.

    To change text font or face, you must execute the CALL TextFont or CALL TextFace statement After the WindOW OUTPUT #n statement. Then a subsequent PRINT statement will use the specified font or face to the printer. (The font or face won't change on the printer if CALL TextFont or CALL TextFace is before the WindOW OUTPUT #n statement.) When sending output with WindOW OUTPUT #n, use the PRINT statement instead of PRINT#n.

    More information

    For a description of which Basic versions support the Apple ImageWriter I, II, or LQ, or the Apple LaserWriter, please query on the following words for a separate article in this database:

    LQ and ImageWriter and Macintosh and Support and LaserWriter

    The following is a code example:
    OPEN "LPT1:" FOR OUTPUT AS #1         ' Opens printer as #1.
WindOW OUTPUT #1            ' Redirects output to device #1.
REM  Perform any window output here (TextFont, TextSize, PRINT,
REM  Circle, Picture, ROM Routines, etc.) to redirect to the printer.
REM  Exceptions:  The Backpat ROM routine (and PUT in Basic Interpreter
REM  2.00) is not redirected to the printer.
REM  The image must lie within coordinates (1,1)-(638,750)
REM  on the Standard ImageWriter printer.
TextFont 4 : TextSize 9    ' Changes to Monaco font, size 9.
LOCATE 3,1
PRINT "This is in monaco font."
LINE (1,20)-(55,34),,b  ' Draws box.
CLOSE #1     ' The output won't print until you CLOSE #1.
    Using this technique, you can send to the printer a much larger area than you can see on the screen. The maximum window that you can see on the standard Macintosh screen must lie within screen coordinates (1,21)-(510,338). By using the above program, you can print to window coordinates (1,1)-(638,750) on the ImageWriter (or LaserWriter) printer, corresponding to a full 8.5-inch x 11-inch printed page. An even larger area can be printed to the wide (15-inch) ImageWriter printer.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB20521


Control Characters to Reset Page Length for Multi-Page LLIST (20522)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    When sending more than one page of output to the Apple ImageWriter printer with the LLIST statement, the printer prints continuously. To specify page breaks for a tidier printout, you can reset the number of lines printed per page using control codes.

    This information applies to Microsoft QuickBasic 1.00, 1.00a, 1.00b, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh.

    More information

    The following program resets the number of lines printed per page to 60 on the ImageWriter Printer. LLIST then creates a multi-page listing that does not print over the perforations between sheets of paper. (See Page 64 of the ImageWriter reference manual for further information on the printer control codes.)
    WIDTH LPRINT 255    'Sets infinite printer line width, suppressing RETURN.
TF$=CHR$(29)+"A@"   'Codes to set starting top of form (TOF).
BF$="C@"            'Codes to set bottom of form (BOF).
NF$="A@"+CHR$(30)   'Codes to set top of next form.
LPRINT TF$;         'This and the next line set top of form (TOF)
FOR I=1 TO 58 : LPRINT "@@"; : NEXT I
LPRINT BF$;         'This and the next line set bottom of form (BOF)
FOR I=1 TO 6 : LPRINT "@@"; : NEXT I
LPRINT NF$          'Sets top of next form.
'Demonstrate the new page length:
WIDTH LPRINT 80     'Enable RETURNs at 80th character (or as desired).
LPRINT CHR$(12);    'Do a form feed, since first line had control chars.
FOR J=1 TO 75 : LPRINT J : NEXT I   'Tests the new page length.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB20522


Unusual, Compressed LLIST or LPRINT Output After Graphics Dump (20523)

Summary

Question:

When an LLIST or LPRINT statement (e.g. "character mode") is performed after "graphics mode" output to the ImageWriter printer, the output is compressed vertically. How can the output be changed back to normal text size?

Response:

This information applies to Microsoft QuickBasic 1.00 1.00a 1.00b, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh.

After a graphics-mode dump, such as Lcopy or Shift+Command+4, to the ImageWriter printer, you will notice that an LLIST and LPRINT (character mode output) produces 8 lines per vertical inch, which looks compressed. The characters also appear elongated. To avoid the compressed look, you must reset the printer before doing an LLIST or LPRINT after a graphics-mode dump.

You can easily reset the printer back to 6 lines per inch by doing one of the following:

  1. Turning the printer off, then on
  2. Sending the following control characters to the ImageWriter printer:
          LPRINT CHR$(27);"A"          ' This gives 6 lines per inch.
We can't design Basic to automatically compensate for this problem, such as sending control characters to the printer, since this would confuse the printer. (The Macintosh print manager offers no device-independent way of resetting the printer after a graphics-mode screen dump.)

Definitions

"Graphics mode" printer output comes from the following:

  1. Output to "LPT1:" or "Lpt1:Prompt" (Pages 42-43 of the "Microsoft Basic Interpreter for Apple Macintosh" manual for Versions 2.x and 3.00)
  2. Lcopy statement
  3. Pressing Shift+Command+4
"Character mode" printer output comes from the following:

  1. Output to "Lpt1:Direct" (Pages 42-43) or "Lpt1:Bin" (not in manual)
  2. LPRINT statement
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB20523


LPRINT CHR$(9) Converts TAB to Spaces; "LPT1: BIN" Workaround (20526)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    Question:

    In Macintosh Basic (also in CP/M and Ms-Dos Basic), a horizontal tab, or CHR$(9), is converted into eight spaces when the LPRINT statement is executed. Why does this happen? Is there any way to keep CHR$(9) from being converted into spaces?

    Response:

    This information applies to the following products:

    1. Microsoft QuickBasic 1.00, 1.00a, 1.00b for Apple Macintosh
    2. Microsoft Basic Compiler 1.00 for Apple Macintosh
    3. Microsoft Basic Interpreter Versions 1.x, 2.x, and 3.00 for Apple Macintosh
    The LPRINT statement in Basic converts a tab (an ASCII 9) into spaces to provide a generic, machine-independent behavior of tabs on a variety of printers.

    To suppress the conversion of CHR$(9) to spaces, you can output with PRINT#n to the device "Lpt1:Bin", which you OPEN as #n. "Lpt1:Bin" works the same as "Lpt1:Direct", except that the horizontal tab, CHR$(9), is not converted to spaces. "BIN" stands for "binary dump," where bytes are dumped without any translation.

    "Lpt1:Bin" is not supported in Basic Interpreter Version 2.00 or Basic Compiler 1.00. "Lpt1:Bin" is supported in QuickBasic 1.00 (both interpreter and compiler) and in Basic Interpreter Versions 1.00, 1.01, 2.10, and 3.00.

    LPRINT, "Lpt1:Direct", and "Lpt1:Bin" are supported on directly connected printers only. They are not supported for AppleTalk devices such as AppleTalk ImageWriters and LaserWriters.

    The following is an example of setting your own tab stops on the Apple ImageWriter using control codes obtained from the Apple ImageWriter printer manual:
    OPEN "Lpt1:Bin" FOR OUTPUT AS #1
PRINT #1, "12345678901234567890"    'Provides handy tab counter.
' See Pages 57-59 of the ImageWriter printer manual for control codes:
PRINT #1, CHR$(27); "(004,009,023.";   'Sets tabs at columns 4, 9, 23.
PRINT #1, CHR$(9); "x"; CHR$(9); "y"; CHR$(9); "z"   'Uses tabs.
PRINT #1, CHR$(27); CHR$(48);     ' Clears all tabs set above.
PRINT #1, CHR$(9); "x"; CHR$(9); "y"; CHR$(9); "z"   'Tabs are clear.
CLOSE #1
    Note that the device "Lpt1:Bin" is not supported in Basic Interpreter Version 2.00 or Basic Compiler 1.00. To work around the tab translation to spaces in these versions, you may use Basic's TAB function with LPRINT, instead of CHR$(9), as in the following example:
    LPRINT TAB(12);"X";TAB(24);"Y"    ' This successfully performs a tab.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB20526


SOUND & Wave Common Questions and Problems in Macintosh Basic (20537)

Summary

Below is a list of common questions, problems, and answers regarding the SOUND and Wave statements. SOUND and Wave are found in Microsoft QuickBasic 1.00, 1.00a, 1.00b, in Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00, and in Microsoft Basic Compiler 1.00 for Apple Macintosh.

More information

  1. Which type of wave is quieter, SIN waves or Square waves?

    SIN waves are much quieter than the default Square waves when using the SOUND command. Synthesizers also display this characteristic. The attack (and decay) of the Square wave signal amplitude is much quicker than a SIN wave, which results in a louder sound from the speaker.
  2. Why can't I change the volume of the SOUND statement when using a non-default wave such as a SIN wave?

    The volume argument of the SOUND statement works only in single-voice mode. Page 239 of "Microsoft Basic Interpreter for Apple Macintosh" manual for Versions 2.x and 3.00 correctly states the following:

    The volume argument [of the SOUND statement] is ignored if the system is in multivoice mode.

  3. How do I change to multivoice mode?

    The following invokes multivoice mode:

    Wave 0,SIN

    You are in multivoice mode whenever you specify any Wave statement other than Wave 0. For example, the statement Wave 0,SIN invokes multivoice mode, and the volume argument on subsequent SOUND statements will then have no effect.
  4. Why does a volume of zero make a sound yet the manual for Basic interpreter Versions 2.x and 3.00 states that it should not have a volume?

    The following is a correction:

    Page 239 of the "Microsoft Basic Interpreter for Apple Macintosh" manual for Versions 2.x and 3.00 should be changed to state that a volume of zero will still make a (minimal) sound.

    Page 310 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" correctly states the following:

    The number given for volume can range from 0 (minimum volume) to 255 (maximum volume). The default volume is 127. The volume argument is ignored if the system is in multivoice mode.

  5. Why does a SOUND statement make a continuous sound that won't stop (in Basic interpreter Version 2.00 or 2.10)?

    If you run programs in Basic interpreter Versions 2.00 and 2.10 on the new 128K ROM that comes with ROM upgrades, the MacPlus, and later Macintoshes, then single-voice SOUND creates a sound that cannot be stopped except by resetting the beep volume in the control panel or rebooting.

    Because of this ROM problem, Basic Versions 2.x programs can only use multivoice sound on ROM upgrades, the MacPlus, and later Macintoshes. A sample workaround in Basic Versions 2.x is Wave 0,SIN. This workaround puts you into multivoice mode, and subsequent SOUND statements work normally.

    The problem has been eliminated in later versions of Basic. Both single-voice and multivoice sound work correctly in Basic interpreter Versions 3.00, Basic compiler Version 1.00, and QuickBasic 1.00.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB20537


"System Error" with Inadvertent Implied CALL; B=2: B ; C-D=E (20538)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 1.0b
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft Basic Compiler 1.00

    • Summary

    This information applies to Microsoft QuickBasic 1.00, 1.00a, 1.00b, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

    The following "valid" Basic statement can cause a System Error:
      B=2 : B    ' This is the same as B=2 : CALL B
    Because B has not been defined as a subprogram, Basic assumes that you are calling the machine-language routine at the address (2) contained in B. Because you have not yet placed a proper machine-language routine at this address, you usually will get a System Error and must reboot. This is an example of an "implied CALL", a special CALL syntax that does not require an explicit CALL statement. For more information about implied CALLs, refer to the CALL statement documentation.

    More information

    Here is another example of an implied CALL that hangs the system:
       C - D = E
    You might type a statement like the above by mistake, but this perfectly legal syntax tells Basic to use an equal sign (=) as a relational operator instead of the assignment operator. When C, D, and E are zero (by default), then the above expression D=E returns a value of true (-1). C minus -1 equals +1. The value of the expression C-D=E is thus +1. The one-line program C-D=E will therefore make an implied CALL to the machine code routine at the address +1, which is not a valid routine; at this point, the computer hangs or you get a System Error. (For more information, please look up "relational operators" in the index of the "Microsoft Basic Compiler 6.00 for MS OS/2 and Ms-Dos: Basic Language Reference.")

    An inadvertent implicit call is easy to do by mistake when debugging from the interpreter's Command window. If you simply type a variable name in the Command window and hit the RETURN key, you will probably hang because this is a syntactically legal implicit CALL, and the number stored in the variable is almost certainly not a valid address of executable machine code.

    This process also may occur if the machine code array moves between the time you take its address and make the CALL. For this reason, the "Microsoft Basic Interpreter for Apple Macintosh" Versions 2.x and 3.00 manual warns you to always take the address Immediately before the call, as in the following program fragment:
    code# = VARPTR( MyCode%(0) ) 'get address of my machine code array
code# arg1%,arg2%   'call my routine
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB20538 kbAudDeveloper


"Type Mismatch" Passing Numeric Constants in CALL Statement (20539)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    When you pass numeric constants as arguments in a CALL statement to invoke a subprogram, they must agree in type (integer%, single-precision!, or double-precision#) with the formal parameters in the subprogram SUB statement, or else you will get a "Type Mismatch" error.

    This information applies to Microsoft QuickBasic 1.00, 1.00a, 1.00b, Basic compiler Version 1.00, and Basic interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

    More information

    An example of making CALL arguments and SUB formal parameters agree is as follows:
    ' It is best to explicitly type numeric constants with %, !, and #
' to be sure that they are passed with the correct type:
CALL Test (2%, 4.5!, 8.5436#)
STOP
' Formal parameters X%, Y!, Z# must agree in type with CALL arguments:
SUB Test(X%, Y!, Z#) STATIC
PRINT X%, Y!, Z#
END SUB
    Note the arguments passed to DEF FN functions do not have to agree in type with the formal parameters used in the DEF FN statement.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB20539


Labels & Line Numbers Must Be Unique, Even Across Subprograms (20540)

Summary

This information applies to Microsoft QuickBasic 1.00, 1.00a, 1.00b, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

All labels and line numbers used in interpreted program must be unique. No two labels or line numbers can be the same when a program is interpreted, even if they are in separate subprograms.

Basic interpreter Version 2.00 does not properly warn you about duplicate labels, and incorrect branching can occur when using duplicate labels in Version 2.00.

Basic interpreter Versions 2.10 and 3.00 and the interpreter in QuickBasic properly stop the program with an error message "Duplicate Label" when duplicate labels are found at run time.

The Basic compiler Version 1.00 and the QuickBasic Compiler treat line numbers and labels locally and will not generate an error message if there are duplicates in separate subprograms. This is an undocumented difference between compiled and interpreted programs. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB20540


ON Event GOSUB, ON ERROR GOTO Labels Must Be in Main Program (20541)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    This article describes how to perform event and error trapping in subprograms. This information applies to Microsoft QuickBasic 1.00, 1.00a, 1.00b, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

    You can use the "ON ERROR" and "ON event" trapping statements in subprograms; however, the error-handling subroutine label given in the GOTO or GOSUB statement must be located outside the subprogram, as follows:
        CALL Mytest
    END               ' Run the subprogram Mytest then stop.
    SUB Mytest STATIC
      ON ERROR GOTO Errorhandler    ' Turn on error trapping.
      ERROR 200                     ' Simulates an error.
      PRINT "This was printed after the error"
    END SUB
    ' The error handler must be outside the SUBprogram block:
    Errorhandler:
       PRINT "Error trapped=";ERR
       RESUME NEXT   ' Resumes on next line after error occurred.
    Error and event-handler code must be outside of subprograms because error and event handlers are global across the whole program. When trapping errors that occur in a subprogram, you cannot use the RESUME <line> statement, you may only use RESUME or RESUME NEXT.

    Note also that labels and line numbers are also global across the whole program. Labels or line numbers used in a subprogram cannot be used in the main program. Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB20541


Invoking Slashed Zeros in Character Mode, ImageWriter Printer (20542)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    This article applies to Microsoft QuickBasic 1.00, 1.00a, 1.00b, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh.

    To invoke printing of slashed zeros on the Apple ImageWriter printer using control codes, refer to Page 42 of the ImageWriter printer manual. Although the manual gives the control codes for printing slashed zeros, it fails to mention that a space (" ") is also needed at a particular point, as follows:
    LPRINT CHR$(27);CHR$(68);" ";CHR$(1);CHR$(0);    ' Sets slashed zeros.
X=5.003 : LPRINT "101010",X    ' Demonstrates slashing of zeros.
LPRINT CHR$(27);CHR$(90);" ";CHR$(1);CHR$(0);    ' Sets non-slashed 0.
LPRINT "101010",X    ' Demonstrates non-slashing of zeros.

    More information

    ImageWriter control codes like this only have an effect in character-mode output. Character-mode printer output comes from one of the following:

    1. LPRINT
    2. PRINT#n to the device "Lpt1:Direct" or the device "Lpt1:Bin" that was OPENed as #n.
    The undocumented device "Lpt1:Bin" turns off conversion of horizontal tabs (CHR$(9)) to spaces, and is useful if you wish to actually output a CHR$(9). "Lpt1:Bin" is not supported by the Microsoft Basic Compiler Version 1.00 or the Microsoft Basic Interpreter Version 2.00. "Lpt1:Bin" is supported by the QuickBasic Compiler 1.00 and all versions of the Microsoft Basic Interpreter other than Version 2.00.

    LPRINT, "Lpt1:Direct", and "Lpt1:Bin" are supported on directly connected printers only. They are not supported for Appletalk devices such as Appletalk ImageWriters and LaserWriters.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB20542


Listing of Macintosh System Error (Bomb) ID Numbers (20546)

Summary

The Macintosh System Error (Bomb) ID Codes for applications are listed below.

This information is useful for owners of Microsoft QuickBasic 1.00, 1.00a, 1.00b, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh.

More information

The Macintosh System Error codes are as follows:
   ID Code   Error

         1   Bus error
         2   Address error
         3   Illegal instruction
         4   Zero divide
         5   Range-check error
         6   Overflow
         7   Privilege violation
         8   Trace-mode error
         9   Line 1010 trap
        10   Line 1111 trap (breakpoint)
        11   Hardware exception
        12   Unimplemented core routine
        13   Uninstalled interrupt
        14   I/O core error
        15   Segment-loader error
        16   Floating-point error
        17   To 24 Package 0 (to package 7) not present
        25   Memory full
        26   Bad program launch
        27   File system map trashed
        28   Stack ran into heap
        29   None
        30   Disk-insertion error
        31   No disk insertion
     32-56   Memory manager errors
A given System Error can have a variety of causes.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB20546


How to Use "Com1: " Serial Communications in Macintosh Basic (20549)

This article was previously published under Q20549

Question:

How can I use the Macintosh serial communications port ("com1:") in Ms-Basic Interpreter, Ms-Basic Compiler, or QuickBasic for the Apple macintosh? Are there any examples or books to which I can refer for additional information?

Response:

To use the Macintosh serial port, you must first open it with the Open statement. The "Com1:" device can be Opened with the parameters (baud-rate, parity, data-bits, and stop-bits) as shown in the following manuals:

1. Page 124 of the "Ms-QuickBasic for Apple Macintosh: User's Guide" for Versions 1.00, 1.00a, 1.00b.

2. Page 42 of the "Ms-Basic Interpreter for Apple Macintosh" manual for 2.00, 2.10, or 3.00. (QuickBasic succeeds these earlier interpreter versions.)

3. "Com1:" is not documented in Ms-Basic Compiler 1.00 for Macintosh, a product which was succeeded by QuickBasic.

The following is an example Open statement

Open "Com1: 1200, N, 8, 1" AS #1

where 1200 is the baud rate, the speed of communication. (default baud is 300 if you don't specify a baud rate. The baud rate can be 110, 150, 300, 600, 1200, 1800, 2400, 3600, 4800, 7200, 9600, 19,200, or 57,600. However, transmission errors are more likely at the higher speeds.)

Most programs input from "Com1:" with the input$ function in a loop using the LOC function to determine the number of characters currently waiting in the communications input buffer. Output to "Com1:" is usually done with the print# statement. Communications programs can be tricky to write.

For an example of how to use the Macintosh serial port from Basic, please refer to the Terminal program that comes on the release disk for QuickBasic 1.00, 1.00a, 1.00b, Basic interpreter Versions 2.00, 2.10, and 3.00, and Basic compiler Version 1.00.

The Terminal program is a dumb-terminal emulator, the simplest kind of communications program. The Terminal program allows you to transmit characters to and from another computer that is running a similar dumb-terminal-emulator program.

More advanced programs that upload and download files can be designed with some creativity. For more information about using and expanding the Terminal program, please refer to the following book:

"Creative Programming in Ms-Basic for Optimal Macintosh Performance," by Steve Lambert (Microsoft Press, 1985); Section Iii, Pages 145-260.

This book shows how to extend the Terminal program to add the ability to upload and download files (with a simplistic xon/xoff handshaking protocol) and store and edit a directory of telephone numbers. (xon is a Ctrl+q, a character with Ascii value 17. Xoff is a Ctrl+s, a character with Ascii value 19.)

Commercial communications applications are often quite expensive, but some communications programs written in Macintosh Basic, such as Red Ryder, are available in the public domain. Macintosh user's groups are a good source of public domain communications programs.

For communications on the "Com1:" serial port, Basic uses the Rom serial driver that is built into the Macintosh Rom. Apple sells a program called MacTerminal that circumvents the Rom serial driver and uses its own serial driver. If you notice a difference between Apple's MacTerminal program and Basic's Terminal program, it could be due to a problem in the Rom serial driver built into the Macintosh Rom.

Note: You cannot change the communications parameters when you Open the printer port (with the "Lpt1:" device name, or the Lprint statement) in Macintosh Basic. You can change only baud rate, parity, data bits, or stop bits when you Open the "Com1:" device name. You can Open "Com1:" as #n and send output with the print#n statement.

Additional query words: BasicCom Mquickb ___ Modification Type: Minor ___
Last Reviewed: 1/8/2003 ___
Keywords: KB20549


TIMER Sometimes Returns Number One Less Than Previous Value (20551)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    There is a problem in the Macintosh ROM (both 64K and 128K ROMs) that, every one to five minutes, causes the TIMER function in QuickBasic or Basic to return a number that is one less than the previous value.

    More information

    The following program demonstrates this ROM problem:
         Loop:  Newtime=TIMER
     IF Newtime < Oldtime THEN GOSUB Ouch
     Oldtime=Newtime
     GOTO Loop
     Ouch:  BEEP
     PRINT "Newtime",Newtime,"Oldtime",Oldtime
     PRINT "Timer",TIMER
     RETURN
    To duplicate the problem, run this program for ten minutes. The subroutine should print only when the TIMER wraps around from the highest value back to zero, but instead, it prints every one to five minutes when TIMER mistakenly returns a number that is one less than the previous value of TIMER. The problem is in the Macintosh ROM routine Readdatetime that is called by TIMER. The problem may have to do with a software/hardware clock updating idiosyncrasy in Readdatetime.

    This behavior is not due to a fault in QuickBasic or Basic; it is an Apple Macintosh ROM problem.

    To work around the problem, you can use PEEK(527), which counts from 0 to 255 by seconds, or use ON TIMER(1) GOSUB and increment a second counter.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB20551


FIX: PRINT ERL,X Gives Syntax Error in Macintosh QuickBasic (20562)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0e
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Symptoms

    The following statement mistakenly gives a "Syntax Error" in the interpreter in QuickBasic 1.0 and in the Basic interpreter version 2.1 for Macintosh. (An "Undefined Label" error occurs in the Basic Interpreter version 2.00.)
    PRINT ERL,<variable>

    Resolution

    The problem does not occur in a compiled program. To work around the problem in the interpreter, explicitly type the variable with %, !, #, or $. For example, instead of the following

    PRINT ERL,X ' This gives error.

    use one of the following:

    PRINT ERL,X% ' This works OK.
    PRINT ERL,X! ' This works OK.
    PRINT ERL,X# ' This works OK.
    PRINT ERL,X$ ' This works OK.

    Status

    Microsoft has confirmed this to be a bug in the Microsoft QuickBasic Interpreter versions 2.00, 2.10, and 3.00 and in the interpreter in Microsoft QuickBasic 1.00 for the Macintosh. This problem was corrected in Microsoft QuickBasic 1.00b for the Macintosh.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: kbbug KB20562


MS Chart Cannot Use Double-Precision Clipboard Numbers (20565)

Summary

When you send numbers from QuickBasic or Basic for Apple Macintosh through the clipboard to Microsoft Chart, be sure to send only single-precision numbers; otherwise, Chart will not use the numbers correctly.

For more information on sending data to the clipboard, please refer to Page 55 of the "Microsoft Basic Interpreter for Apple Macintosh" Versions 2.x and 3.00 manual, and Page 138 of the "Transferring Data Between Basic and Other Programs" section in the "Microsoft QuickBasic: User's Guide" for QuickBasic 1.00, 1.00a, 1.00b. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB20565


Supplemental Reference Books and Disks for Macintosh Basic (20566)

Summary

This article lists books helpful for programming in Microsoft Basic Interpreter versions 2.00, 2.10, and 3.00, Microsoft Basic Compiler version 1.00, and Microsoft QuickBasic 1.00, 1.00a, 1.00b for Apple Macintosh.

More information

The following book is a completely integrated, low-cost self-study system that contains everything needed to learn Basic programming (including a copy of the QuickBasic Interpreter):

"Learn Basic for the Apple Macintosh Now," by Michael Halvorson and David Rygmyr. 496 pages, one 800K 3.5-inch disk. Published October 17, 1990, from Microsoft Press.

The following book contains information about programming in Microsoft QuickBasic 1.00 for the Apple Macintosh. This book is specific to QuickBasic for the Macintosh and contains information that is not applicable to the earlier Microsoft Basic interpreters and compiler for Macintosh (such as ToolBox statement trap calls, MBLC's, code resources, and color):

"Microsoft Macintosh QuickBasic: A Structured Approach," by Harvey M. Deitel & Paul J. Deitel, Prentice-Hall (1990).

The three Microsoft Press books listed below were published in 1985 to explain how to program in the Macintosh Basic Interpreter versions 2.00 and 2.10. There is an optional companion disk for each book. These books are no longer published by MS Press, but should be available from public libraries, college libraries, or stores that sell used books.

These books are also excellent references for programming in later versions of Basic for the Macintosh (including Microsoft Basic Interpreter version 3.00, Microsoft Basic Compiler 1.00, or QuickBasic 1.00):

  1. The following book is an excellent, definitive tutorial for programming in Basic for Macintosh for both beginning and advanced programmers:

    "Microsoft Macinations," Microsoft Press (1985).

    This book is the best supplement to the manual available. It teaches how to take full advantage of Macintosh Basic Interpreter version 2.00 or 2.10.
  2. The following book and its optional companion disk contain a set of utilities, games, and other diversions written in Macintosh Basic:

    "Macintosh Midnight Madness," by Mitchell Waite, Microsoft Press (1985).

  3. The following book and its optional companion disk help intermediate programmers develop creative programming skills:

    "Creative Programming in Microsoft Basic for Optimal Macintosh Performance," by Steve Lambert, Microsoft Press (1985).

These three books do not discuss using QuickBasic's MBLC routines or the similar Toolbox library routines found in the "ToolLib" file in Basic interpreter version 3.00 or Basic compiler version 1.00. To learn how to use the Toolbox routines, please refer to the many excellent demonstration programs on the Basic or QuickBasic disk.

For more complete technical information about Macintosh Toolbox ROM routines, please see "Inside Macintosh" by Apple Computer, a five-volume set of books published by Addison-Wesley. See also "How to Write Macintosh Software: The Debugging Reference for Macintosh" Second Edition, by Scott Knaster, published by Hayden Books (1988). The examples in these books are mainly in Pascal, C, and assembly language.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB20566


Timing Accurate to 1/60th Second Using PEEK or ToolBox Call (20572)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    Basic provides a TIMER statement that is accurate to within one second.

    In Macintosh System Version 4.2 and earlier, you can PEEK a Macintosh low memory address to obtain ticks accurate to 1/60th of a second, as shown below.

    However, because this memory location may change in the future, you should instead call the system function TickCount using the Microsoft QuickBasic ToolBox statement. The ToolBox statement is only provided in QuickBasic for Macintosh, and is not available in earlier versions of the Basic Interpreter or Compiler for Macintosh.

    More information

    With Macintosh QuickBasic 1.00, 1.00a, 1.00b, time intervals may be determined by using PEEKL(&H16A). &H16A is the Macintosh Global Ticks, the number of system "ticks" (1/60 second) since startup. Future versions of the Macintosh System may not support this as a global variable.

    For future compatibility, a QuickBasic program should use a call to the system function TickCount. The following QuickBasic program shows how to call TickCount:
        ' This program requires QuickBasic.
    ToolBox "i"
    ticks& = 0
    ToolBox "LQ", &H975, ticks&
    PRINT "About"; ticks&\60 ;"seconds have elapsed since startup."
    Note that the value of Ticks is not guaranteed to be exact.

    Versions of Basic earlier than QuickBasic do not support the ToolBox statement or PEEKL, but do support PEEK. PEEK can be used in combination with ON TIMER(1) GOSUB to provide timing accurate to sixtieths of a second as shown in the Ticks program below.

    The following program returns the amount of time between two key presses, accurate to 1/60 of a second. The heart of the program is the function FNtic, which counts 0 to 255 by sixtieths of a second by making use of a PEEK into Macintosh low memory:
    ' Ticks
' This program is designed for Microsoft Basic Interpreter 3.00 and
' earlier, and for the Basic Compiler 1.00.
DEF FNtic=PEEK(365)    ' FNtic counts 0 to 255 by 60ths of a second.
loop:
seconds=0              ' Seconds start out as 0.
PRINT "Timing is done between your next two keystrokes:"
nokey:
a$=INKEY$
IF a$="" GOTO nokey    ' Start timing at key press:
ON TIMER (1) GOSUB handler    ' Every second, increment seconds.
TIMER ON              ' Turns on timer event trapping.
startic=FNtic         ' Initial 60ths of a second.
nopress:
a$=INKEY$
IF a$="" GOTO nopress   ' Wait for 2nd press.
endtic=FNtic    ' Final 60ths of a second.
ticdif=ABS(endtic-startic)  ' Adjust for rollover (255 to 0) of tic count:
IF endtic=>startic THEN ticks=ticdif ELSE ticks=256-ticdif
tenths=(ticks MOD 60)/60    ' Use MOD function, convert 60ths>10ths.
total=seconds+tenths
PRINT "elapsed time="total
TIMER OFF              ' Turn off second counting until a key is pressed.
GOTO loop
handler:   seconds=seconds+1   :   RETURN
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB20572


Reading Macintosh Sequential Files Randomly and Vice Versa (20573)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    This information applies to Microsoft QuickBasic 1.00, 1.00a, 1.00b, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

    To read with Sequential access from a file created with Random access, you must put a carriage-return character, CHR$(13), at the end of each Random record. In Sequential access, each record is delimited with a carriage-return character, and records can have different lengths.

    To read with Random access from a file created with Sequential access, all the records must have the same length; otherwise, the records will not line up properly into the fielded variables. Each record in a file created sequentially will have the number of characters written to it plus an extra byte for the return CHR$(13) at the end. The record length specified in the random OPEN statement should thus reflect the number of characters in the record plus a byte for the return.

    More information

    If you are going to use the INPUT #n or LINE INPUT #n statement to read a file created with Random access, the file should only contain alphanumeric strings, and NO non-ASCII binary information. Otherwise, records may be delimitted prematurely by binary numeric data because a binary value of ASCII 13 may be in a byte of an integer or floating-point number.

    If the file contains binary numeric data, then sequential input from a Random file may be done with the INPUT$() function. For example, if the record size is 128 bytes, then the following statements will read the first record into x$, leaving the file ready to read the next record, as follows:
       OPEN f$ FOR INPUT AS #1
   x$ = INPUT$(128,1)
    You also could read in the records a piece at a time. For example, if the file is made up of records consisting of two integers, a single precision value, and an 80-character string, the following program shows how to read the first record of the file:
        OPEN f$ FOR INPUT AS #1
    id% = CVI( INPUT$(2,1) )
    count% = CVI( INPUT$(2,1) )
    price! = CVS( INPUT$(4,1) )
    descr$ = INPUT$(80,1)
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB20573


"String Formula Too Complex" Passing String Constants (20575)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Question:

    What is the cause of getting the "String Formula Too Complex" error message when passing strings in a CALL statement? Is there a limit to the number of string constants that can be passed in a CALL?

    Response:

    Only up to nine string constants can be passed in all nested calls added together starting in a given call from the main program. To pass more string constants, pass string variables instead of constants in the CALL parameter list. If no string constants are passed to a second-level call, it is possible to pass ten string constants in the first-level call. This limitation applies to the Basic interpreter Versions 2.10 and 3.00 for the Apple Macintosh and the interpreter in QuickBasic 1.00 for the Apple Macintosh. The limitation does not pertain to compiled programs.

    Code Example

    In the following program, the first-level CALL Prompt passes eight string constants, and a second-level subprogram CALL passes two more string constants. As a result, you get a "String Formula Too Complex" error at run time:
    CALL Prompt (1,"Input String:",25,"N","O"," ","+","Y","Y","Y",2!,Timout$)
END
SUB Prompt (Device%,Strout$,Numchr%,Hotchr$,Cvtcase$,Mask$,
    Cursor$,Range$,Userbells$,Local$,Maxmin!,Timout$) STATIC
CALL Modemout (Device%,Local$,"N","N",Userbells$,Strout$)
END SUB
SUB Modemout (Device%,Local$,Invisible$,Creturn$,Userbells$,Strout$) STATIC
A$="A"
END SUB
    If you remove ("+",) from the CALL Prompt line and remove the corresponding formal argument (Cursor$,) from the SUB Prompt line, the program works properly, since a total of nine string constants have been passed in the two nested calls. Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB20575


How to Print to an Apple LaserWriter (20584)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    To print to the LaserWriter, the LaserWriter and LaserWriter Prep files must be on the Startup disk in the System Folder.

    This information applies to Microsoft QuickBasic 1.00, 1.00a, 1.00b, Basic Compiler 1.00, and Basic Interpreter Version 3.00 for Apple Macintosh.

    More information

    Once you are connected through the AppleTalk network to the printer, select the correct printer in the Chooser. The name of the LaserWriter must be selected and displayed in inverse video in the Chooser printer list so it can print.

    If the name of the LaserWriter is not displayed in inverse video, the network is not connected to the LaserWriter. You may receive a "Device I/O ERROR" message at print time right after the "Looking for LaserWriter" message.

    If you see a "Device I/O ERROR" message while printing, the network is not properly connected between your Macintosh and the printer. The most likely problem is that a connector wire is loose at some point along the network between your Macintosh and the printer. Tighten all connectors (taping them together if necessary), check the above settings, and print again.

    To print a program listing to the LaserWriter, select Print from the Basic file menu.

    To output to the LaserWriter from a Basic program, open the device "LPT1:" or "Lpt1:Prompt" for output as #n, and use PRINT#n or WRITE#n to output.

    WindOW OUTPUT #n can be used to redirect to the printer what would have gone to the screen. Use PRINT or WRITE instead of PRINT#n or WRITE#n when WindOW OUTPUT #n is in effect.

    Note that LPRINT, LLIST, and output to the device "Lpt1:Direct," will not send output to the LaserWriter because they provide character mode output and the LaserWriter supports only graphics mode output. You will receive an error message ("FILE NOT Found") when attempting to output using LPRINT, LLIST, or "Lpt1:Direct."

    The following is a code sample:
    OPEN "LPT1:" FOR OUTPUT AS #1
PRINT #1,"This goes to the laserwriter printer"
WRITE #1,"This goes to the laserwriter printer"
CLOSE #1
    To use WindOW OUTPUT #n, do the following:
    OPEN "LPT1:" FOR OUTPUT AS #1
WindOW OUTPUT #1      'Redirects window output to printer
CALL TextFont(4): CALL TextSize(9)
PRINT "Redirected to printer"
CLOSE #1
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB20584


BUG: WindOW OUTPUT Output Goes to Wrong Window in Interpreter (20591)

The information in this article applies to:
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Symptoms

    The sample program shown in the More Information section below demonstrates a problem with the WindOW OUTPUT n statement in interpreted programs. In the program, the PRINT and LINE output correctly appears the first time in window 1 (the current output window); however, after the INPUT statement is invoked, all subsequent output statements incorrectly go to window 2.

    Resolution

    In compiled QuickBasic programs, PRINT and LINE output correctly goes to window 1.

    To eliminate the problem, place another WindOW OUTPUT 1 statement after the INPUT statement.

    Status

    Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

    More information

    Program Code Sample to Reproduce Problem

    WindOW 1,"Window 1",(4,40)-(510,200)
WindOW 2,"Window 2",(4,220)-(510,340)
WindOW OUTPUT 1
Display:
PRINT "This should always print in window 1"
LINE (1,1)-(30,30)        ' This line should always go to window 1.
INPUT "OK";R$
IF F$<> "exit" THEN Display
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: kbbug KB20591


FIX: ELSEIF Syntax Error Marked on IF Line in Interpreter (20592)

Symptoms

In the following program, a syntax error in the ELSEIF portion of a block IF is misleadingly marked on the IF line instead of the ELSEIF. Other errors in a block IF usually are marked on the line that contains the error. The following is a code sample:
x=0           ' 0 means false.
IF (X) THEN   ' Error misleadingly marked here when ELSEIF executed.
    PRINT "X IS TRUE"
ELSEIF ( THEN    ' But the syntax error is actually here.
    PRINT "X IS FALSE"
END IF
Microsoft has confirmed this to be a bug in the Microsoft Basic Interpreter version 3.00 for the Macintosh and in Microsoft QuickBasic 1.00 (buglist1.00) for the Macintosh . This problem is corrected in QuickBasic 1.00b (fixlist1.00b).
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB20592


AppleTalk Printer 60-Second Time-Out Kills Mac Basic Printing (23449)

The information in this article applies to:
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    When printing over the AppleTalk Network, the network will time out and nothing will print if a program delays sending output for more than 60 seconds while the printer device ("LPT1:" or "Lpt1:Prompt") is OPEN. This is a problem when the output per page is complicated enough to take more than a minute before the output is sent, or if you attempt to print more than about twenty pages. The problem can occur when printing to either an Apple LaserWriter or ImageWriter over the AppleTalk Network. The problem does not occur with a directly connected LaserWriter or ImageWriter.

    This information applies to the Microsoft Basic Compiler 1.00, the Microsoft Basic Interpreter Version 3.00, and QuickBasic 1.00 for the Apple Macintosh.

    As a workaround, you can design your program to prepare and store the printer output before opening the printer. The statements Picture ON, Picture OFF, and Picture$ are useful for storing images in string variables, which can be directed to the printer later with the Picture and WindOW OUTPUT#n statements. Printing can then be performed in one- to ten-page batches so as not to time out.

    More information

    The 60-second, automatic time-out is controlled by the interaction between the LaserWriter driver and the AppleTalk Network; Basic does not have control over it, except as discussed in the above workaround. The purpose of the time-out is to prevent one application from blocking other printer users on the AppleTalk Network.

    The following program demonstrates the printer time-out over the AppleTalk Network:
    OPEN "LPT1:" FOR OUTPUT AS #1
X=TIMER
PRINT#1, TIMER   ' Print once.
LOCATE 15,1  :  PRINT TIMER
LOOP: X=Timer-X
IF X<70 GOTO LOOP  ' Then delay 70 seconds before printing again.
PRINT #1,TIMER
PRINT TIMER
CLOSE#1
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB23449


Determining Macintosh ROM Version, 64K or 128K, from Basic (25341)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    Question:

    How can I determine the Macintosh ROM version from Basic or QuickBasic?

    Response:

    To determine the type of ROM (64K or 128K), test the high order bit of Low Memory Global Rom85 as follows:
       IF PEEK(654)AND(2^7) THEN ROM=64 ELSE Rom=128
   PRINT ROM
    This information applies to the following products:

  • Microsoft QuickBasic 1.0, 1.0a, and 1.0b for Apple Macintosh
  • Microsoft Basic Compiler 1.0 for Apple Macintosh
  • Microsoft Basic Interpreter versions 1.0, 1.01, 2.0, 2.1, and 3.0 for Apple Macintosh
    • Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB25341


RND and Randomize Alternatives for Generating Random Numbers (28150)

The information in this article applies to:
  • Microsoft Visual Basic for Ms-Dos 1.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.01
  • Microsoft QuickBasic 1.02
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 1.0b
  • Microsoft QuickBasic 2.0
  • Microsoft QuickBasic 2.01
  • Microsoft QuickBasic 3.00
  • Microsoft QuickBasic 4.00
  • Microsoft QuickBasic 4.0B
  • Microsoft QuickBasic 4.50
  • Microsoft GW-Basic 3.2
  • Microsoft GW-Basic 3.22
  • Microsoft GW-Basic 3.23
  • Microsoft QuickBasic Compiler for the Apple Macintosh
  • Microsoft Basic Interpreter (Basic86.Exe) for Ms-Dos
  • Microsoft Basic Interpreter for Apple Macintosh

    • Summary

    If you want a substitute for RND and Randomize, you can use your own equation to generate random numbers as shown below.

    Microsoft Basic offers the RND function to return random single-precision numbers between 0.000000 and 1.000000. The Randomize statement can be used to reseed (or initially start) a given sequence returned by RND. Microsoft Basic uses the linear-congruential method for random-number generation in the RND function.

    This information is also included with the Help file provided with the Standard and Professional Editions of Microsoft Visual Basic for Ms-Dos, version 1.0.

    More information

    Microsoft Basic uses the linear-congruential method for random-number generation in the RND function. The following is an example of the linear-congruential method formula, similar to that used by RND in Microsoft Basic:
       x1 = ( x0 * a + c ) MOD 2^24
    In the above example, the variables equal the following:

    x1=new number
    x0=previous number
    a=214013
    c=2531011

    (Note: the MOD operator in the formula above returns the integer remainder after an integer division.)

    The expression x1/(2^24) returns a floating-point number between 0.0 and 1.0. Please refer to Code Examples 1 and 2 below for an illustration.

    For more random number generation algorithms, see pages 353-364 of "Microsoft QuickBasic Programmer's Toolbox," by John C. Craig, published by Microsoft Press (1988). Seven random number subprograms are documented, and a companion disk in Ms-Dos format is also available from Microsoft Press.

    The programs in Craig's book are written for Microsoft QuickBasic for Ms-Dos, version 4.0 for the IBM PC. Some programs, such as the random number programs, are general and can easily be modified to run in Microsoft QuickBasic for the Apple Macintosh. When you run these programs, you may want to reseed the random number sequence regularly (such as every few hundred invocations) for greater uniformity.

    Code Example 1

    The following is an example of the linear congruential method for generating pseudo-random numbers:
    ' To try this example in Vbdos.Exe:
' 1. From the File menu, choose New Project.
' 2. Copy the code example to the Code window.
' 3. Press F5 to run the program.
DEFDBL A-Z  ' Requires double-precision intermediate variables.
a = 214013
c = 2531011
z = 2 ^ 24
INPUT "Input any seed value: ", x0
FOR count = 1 TO 25   ' print 25 random numbers between 0.0 and 1.0:
  temp = x0 * a + c
' Calculate (temp MOD z) and assign to x1:
  temp = temp / z
  x1 = (temp - FIX(temp)) * z
' Print the result as value between 0.0000000 and 1.0000000:
  result = x1 / z
  PRINT result
' Reseed the calculation before the next iteration:
  x0 = x1   ' x0 and x1 range from 0 to 16777216 (2^24)
NEXT

    Code Example 2

    The following is the same as Example 1, except the random numbers are plotted to illustrate their uniform distribution:
    ' To try this example in Vbdos.Exe:
' 1. From the File menu, choose New Project.
' 2. Copy the code example to the Code window.
' 3. Press F5 to run the program.
DEFDBL A-Z     ' Requires double-precision intermediate variables.
Screen 2
a = 214013
c = 2531011
z = 2 ^ 24
INPUT "Input seed value: ", x0
FOR count = 1 TO 5000
  temp = x0 * a + c
  ' Calculate (temp MOD z) and assign to x1:
  temp = temp / z
  x1 = (temp - FIX(temp)) * z
  result = x1 / z  ' Result is between 0.000000 and 1.000000
  GOSUB 100       ' Plot Result
  x0 = x1   ' x0 and x1 range from 0 to 16777216 (2^24)
NEXT
END
' Plot the random points to see their uniform distribution:
100 y = y + 1
    IF y > 200 THEN y = 0   ' Wrap plot at y=200 pixels.
    x = result * 500   ' Assumes screen mode <= 500 pixels wide.
    PSET (x, y)   ' PSET requires a graphics screen mode.
    RETURN
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB28150


How to Derive Inverse (ARC) and Hyperbolic Trig Functions (28249)

The information in this article applies to:
  • Microsoft Visual Basic for Ms-Dos 1.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft Business Basic Compiler for Ms-Dos 1.00
  • Microsoft Business Basic Compiler for Ms-Dos 1.10
  • Microsoft GW-Basic 3.2
  • Microsoft GW-Basic 3.22
  • Microsoft GW-Basic 3.23
  • Microsoft GW-Basic 5.28
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft Basic Compiler 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.10
  • Microsoft Basic Interpreter (Basic86.Exe) for Ms-Dos

    • Summary

    From the built-in Basic functions LOG, COS, SIN, TAN, SGN, EXP, and SQR, you can derive the other transcendental functions as shown below.

    This information is also included with the Help file provided with the Standard and Professional Editions of Microsoft Visual Basic for Ms-Dos, version 1.0.

    More information

    The following trigonometric and mathematical functions that are not intrinsic to Microsoft Visual Basic for Ms-Dos can be calculated as shown. In these formulas, X is an angle measured in radians and Y is a unitless number:
    Function                  Basic Equivalent
--------                  ----------------

Secant                    SEC(X) = 1/COS(X)
Cosecant                  CSC(X) = 1/SIN(X)
Cotangent                 COT(X) = 1/TAN(X)
Inverse Sine              ARCSIN(Y) = ATN(Y/SQR(1-Y*Y))
Inverse Cosine            ARCCOS(Y) = -ATN(Y/SQR(1-Y*Y)) + Pi/2
Inverse Secant            ARCSEC(Y) = ATN(Y/SQR(1-Y*Y)) + (SGN(Y)-1)
                                      * Pi/2
Inverse Cosecant          ARCCSC(Y) = ATN(1/SQR(1-Y*Y)) + (SGN(Y)-1)
                                      * Pi/2
Inverse Cotangent         ARCCOT(Y) = -ATN(Y) + Pi/2
Hyperbolic Sine           SINH(Y) = (EXP(Y) - EXP(-Y))/2
Hyperbolic Cosine         COSH(Y) = (EXP(Y) + EXP(-Y))/2
Hyperbolic Tangent        TANH(Y) = (EXP(Y) - EXP(-Y))/(EXP(Y)
                                    + EXP(-Y))
Hyperbolic Secant         SECH(Y) = 2/(EXP(Y) + EXP(-Y))
Hyperbolic Cosecant       CSCH(Y) = 2/(EXP(Y) - EXP(-Y))
Hyperbolic Cotangent      COTH(Y) = EXP(-Y)/(EXP(Y) - EXP(-Y)) * 2 + 1
Inverse Hyperbolic Sine   ARCSINH(Y) = LOG(Y + SQR(Y*Y+1))
Inverse Hyperbolic Cos    ARCCOSH(Y) = LOG(Y + SQR(Y*Y-1))
Inverse Hyperbolic Tan    ARCCTANH(Y) = LOG((1 + Y)/(1 - Y)) / 2
Inverse Hyperbolic CSC    ARCCSCH(Y) = LOG((SGN(Y)*SQR(Y*Y+1)+1)/Y)
Inverse Hyperbolic Sec    ARCSECH(Y) = LOG((SQR(1-Y*Y)+1) / Y)
Inverse Hyperbolic Cot    ARCCOTH(Y) = LOG((Y+1)/(Y-1)) / 2
    The general formulas listed above may be used in Microsoft Visual Basic for Ms-Dos or any other language. Note that the constant Pi has the following approximate value:
       Pi# = 3.14159265359
   Pi# = 4.0# * ATN(1.0#)
    To convert degrees to radians, multiply the degrees by pi/180.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB28249


No LPRINT, LLIST, "LPT1: DIRECT" Allowed in AppleTalk Network (28982)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    This information applies to Microsoft QuickBasic 1.00, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

    Macintosh Basic does not support LPRINT, LLIST, or output to the device "Lpt1:Direct" over the AppleTalk network. Basic can only send graphics mode output over the network. Basic cannot send character mode output over the network.

    To output from Basic to a printer through the AppleTalk network, output to the "LPT1:" or "Lpt1:Prompt" device name. Select Printer Chooser from the Apple menu.

    To print a program listing over the AppleTalk Network, select Print from the File menu instead of using LLIST.

    Note that you must have the Basic interpreter Version 3.00, the Basic compiler Version 1.00, or QuickBasic 1.00 to output to the Apple LaserWriter printer. The Basic interpreter Versions 1.00, 1.01, 2.00, and 2.10 cannot output to the Apple LaserWriter.

    More information

    To output to a printer on the AppleTalk Network, OPEN the device "LPT1:" or "Lpt1:Prompt" FOR OUTPUT AS #n and use PRINT#n or WRITE#n to output (where n is any arbitrary file number between 1 and 255).

    WindOW OUTPUT #n can be used to redirect to the printer what would have gone to the screen. However, PRINT and WRITE statements must be used instead of PRINT#n or WRITE#n when WindOW OUTPUT #n redirection is in effect. The WindOW OUTPUT #n redirection ends as soon as you perform CLOSE#n or a general CLOSE.

    Code Examples

    To open the device "LPT1:" or "Lpt1:Prompt" for output, use the following:
    OPEN "Lpt1:Prompt" FOR OUTPUT AS #1
PRINT #1,"This goes to the networked printer"
WRITE #1,"This goes to the networked printer"
CLOSE #1
    To use WindOW OUTPUT #n to redirect window output to the printer, use the following:
    OPEN "Lpt1:Prompt" FOR OUTPUT AS #1
WindOW OUTPUT #1
CALL TextFont(4) : CALL TextSize(9)
PRINT "Monaco Font Redirected From Screen TO Printer"
LINE (20,20)-(50,50)    ' This drawn line goes to the printer.
CLOSE #1
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB28982


How to Get Logarithm Base 10 Using LOG(x#)/LOG(10#) in Basic (31660)

Summary

Microsoft Basic offers a LOG() function that returns only the natural logarithm, that is, the logarithm to the base e. The number e is a constant approximately equal to 2.718282.

To return a logarithm base b, you can use the following general mathematical formula:

(Log base b of x) = (natural log of x) / (natural log of b)

To return a logarithm base 10, you can use the following specific mathematical formula:

(Log base 10 of x) = (natural log of x) / (natural log of 10)

More information

The following example defines a Microsoft Basic single-line function called FNLog10, which returns the logarithm base 10 of a number:
   DEF FNLog10(x#) = LOG(x#) / LOG(10#)
   y#=45
   PRINT "The logarithm base 10 of y# = "; FNLog10(y#)
The above formula applies to any product that supports the natural logarithm (LOG) function, such as the following products:

  1. For the Apple Macintosh:

    1. Microsoft QuickBasic 1.00, 1.00a, 1.00b
    2. Microsoft Basic Compiler 1.00
    3. Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, 3.00
  2. For the IBM PC and compatibles:

    1. Microsoft Basic Compiler 5.35 and 5.36 for Ms-Dos
    2. Microsoft QuickBasic 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.0B, 4.50 for Ms-Dos
    3. Microsoft Basic Compiler 6.00, 6.0B for MS OS/2 and Ms-Dos
    4. Microsoft Basic PDS 7.00, 7.10 for MS OS/2 and Ms-Dos
    5. Microsoft GW-Basic Interpreter Versions 3.20, 3.22, and 3.23 for Ms-Dos
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB31660


Inverse of x$ = HEX$(n) Is VAL("&H"+x$); Inverse for Octal... (31783)

Summary

The HEX$(n) function converts a number n to a string in hexadecimal notation.

To convert a hexadecimal-notation string (x$) back to a numeric value from x$ = HEX$(n), use VAL("&H" + x$).

The OCT$(n) function converts a number n to a string in octal notation.

To convert a octal-notation string (x$) back to a numeric value from x$ = OCT$(n), use VAL("&O" + x$).

These formulas apply to any of the following Microsoft Basic products:

  1. Microsoft QuickBasic 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.0B, 4.50 for the IBM PC
  2. Microsoft Basic Compiler 5.35 and 5.36 for Ms-Dos
  3. Microsoft Basic Compiler 6.00 and 6.0B for Ms-Dos and MS OS/2
  4. Microsoft Basic PDS 7.00 for Ms-Dos and MS OS/2
  5. Microsoft GW-Basic Interpreter Versions 3.20, 3.22, and 3.23 for Ms-Dos
  6. Microsoft QuickBasic 1.00 for the Apple Macintosh
  7. Microsoft Basic Compiler 1.00 for the Apple Macintosh
  8. Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB31783


Converting Between Decimal, Octal, and Binary Numbers (31789)

The information in this article applies to:
  • Microsoft Visual Basic for Ms-Dos 1.00
  • Microsoft Visual Basic Standard Edition for Windows 1.00
  • Microsoft Visual Basic Standard Edition for Windows 2.0
  • Microsoft Visual Basic Standard Edition for Windows 3.00
  • Microsoft Visual Basic Professional Edition for Windows 2.0
  • Microsoft Visual Basic Professional Edition for Windows 3.00
  • Microsoft Basic Compiler 1.0, when used with:
  • the operating system: Mac OS (all versions)
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.01
  • Microsoft QuickBasic 1.02
  • Microsoft QuickBasic 2.0
  • Microsoft QuickBasic 2.01
  • Microsoft QuickBasic 3.00
  • Microsoft QuickBasic 4.00
  • Microsoft QuickBasic 4.0B
  • Microsoft QuickBasic 4.50
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.10
  • Microsoft GW-Basic Interpreter 3.20

    • Summary

    The Microsoft Basic code below demonstrates how to perform the following conversions between decimal, octal, and binary numbers:

  • Convert an octal number to a decimal (base 10) number
  • Convert a decimal number to an octal (base 8) number
  • Convert a decimal number to a binary (base 2) number

    • More information

    The following code example will perform the conversions:
    ' 1. Octal string to decimal Number:
INPUT "INPUT Octal number:"; octal$
PRINT VAL("&O" + octal$)

' 2. Decimal Number to octal string:

INPUT "INPUT Decimal number:"; Decimal
PRINT OCT$(Decimal)

' 3. Decimal Number to Binary string:
Bin$ = ""
INPUT "INPUT Decimal number:"; Decimal
FOR i = 14 TO 0 STEP -1           ' Positive numbers only
  pow2 = 2 ^ i
  IF Decimal >= pow2 THEN
     Decimal = Decimal - pow2: Bin$ = Bin$ + "1"
  ELSE Bin$ = Bin$ + "0"
  END IF
NEXT i
PRINT Bin$
    The above information applies to most Microsoft Basic products, including the following Basics:

  • Microsoft Visual Basic version 1.0 for Ms-Dos
  • Microsoft Visual Basic versions 1.0, 2.0, 3.0 for Microsoft Windows. Note: You will need to replace the INPUT statement in the above code with a feature that is supported in this product, such as a text box used with a Click event procedure.
  • Microsoft Basic Compiler 1.0 for the Apple Macintosh
  • Microsoft Basic Interpreter versions 1.0, 1.01, 2.0, 2.1, and 3.0 for the Apple Macintosh
  • Microsoft QuickBasic Compiler 1.0, 1.01, 1.02, 2.0, 2.01, 3.0, 4.0, 4.0b, and 4.5 for the IBM PC
  • Microsoft Basic Compiler 5.35 and 5.36 for Ms-Dos
  • Microsoft Basic Compiler 6.0 for Ms-Dos and MS OS/2
  • Microsoft Basic PDS 7.0 and 7.1 for Ms-Dos and MS OS/2
  • Microsoft GW-Basic Interpreter version 3.2
    • Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB31789


ON <Event> GOSUB Suspended Until INPUT or INPUT$ Is Satisfied (31885)

Summary

Execution of event trapping GOSUB routines is suspended in Basic until an INPUT or LINE INPUT statement or INPUT$ function is satisfied. Events suspended during INPUT, INPUT$, or LINE INPUT include the following:

  1. ON TIMER(n) GOSUB (found in many Microsoft Basics, including GW-Basic, QuickBasic for Ms-Dos, and QuickBasic for Macintosh)
  2. ON KEY(n) GOSUB (found in QuickBasic and GW-Basic for Ms-Dos, but not in QuickBasic for Macintosh)
  3. ON DialoG GOSUB, ON Menu GOSUB, and ON Mouse GOSUB (found in QuickBasic for the Apple Macintosh, but not in QuickBasic for Ms-Dos)
The suspending of event GOSUBs during INPUT, INPUT$, or LINE INPUT is an intentional design requirement and occurs in all Microsoft Basic products that support event trapping, including the following products:

  1. Microsoft QuickBasic 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.0B, and 4.50 for Ms-Dos
  2. Microsoft Basic Compiler 6.00 and 6.0B for MS OS/2 and Ms-Dos
  3. Microsoft Basic PDS 7.00 and 7.10 for Ms-Dos and MS OS/2
  4. Microsoft GW-Basic Interpreter versions 3.20, 3.22, and 3.23 for Ms-Dos
  5. Microsoft QuickBasic 1.00 for the Apple Macintosh
  6. Microsoft Basic Compiler 1.00 for the Apple Macintosh
  7. Microsoft Basic Interpreter versions 2.00, 2.10, and 3.00 for the Apple Macintosh (Event trapping is not supported in Microsoft Basic Interpreter versions 1.00 and 1.01 for the Apple Macintosh.)

More information

Suppose you write a program with ON TIMER(5) GOSUB so that every five seconds a message is displayed on the screen. If an INPUT$ function or INPUT or LINE INPUT statement is executed that expects a value from the keyboard, the ON TIMER(5) GOSUB will not execute until the Enter key is pressed to terminate the input. Only one TIMER event is remembered on the stack, no matter how much time passed during the INPUT$, INPUT, or LINE INPUT. An example of this event suspension is demonstrated in Program 1 below.

If you want to trap events and also input from the keyboard, you can poll the INKEY$ function as shown in program 2 below instead of using INPUT$, INPUT, or LINE INPUT. The INKEY$ function returns one key press at a time, and allows event GOSUB traps to occur between invocations.

Basic checks between statements to see if an event has occurred. When the INPUT$, INPUT, or LINE INPUT executes, execution of the ON event GOSUB statement is suspended until the INPUT$, INPUT, or LINE INPUT is satisfied. This behavior is intentional and occurs in all Microsoft Basic products that support event trapping.

If you are using ON KEY(n) GOSUB to trap keys (in GW-Basic or QuickBasic for Ms-Dos), only one key press during INPUT$, INPUT, or LINE INPUT will be remembered on the stack for a given defined KEY, no matter how many times that key is pressed. This behavior is by design (to prevent stack overflow).

The following are code examples:

Program 1

The following program shows that ON TIMER(n) GOSUB waits while the INPUT statement is pending:
   REM  Program 1, using the INPUT statement.
   ON TIMER(5) GOSUB Message     ' Trap Every 5 Seconds
   TIMER ON
   INPUT X$   ' NO GOSUB IS Done UNTIL This INPUT IS Satisfied.
   FOR I=1 TO 2000

    PRINT X$
   NEXT
   END
   Message:
       PRINT " Five Seconds "
       RETURN

Program 2

The following program polls the INKEY$ function for INPUT and lets the ON TIMER(5) GOSUB statement successfully perform the TIMER event trap every five seconds:
   REM  ********   Program 2, using the INKEY$ function.
   ON TIMER(5) GOSUB Message          ' Trap Every 5 Seconds
   TIMER ON
   CLS
   Morein:
      A$ = INKEY$
      IF A$ = "" GOTO Morein
      IF A$ = CHR$(13) GOTO Done   'Input until Enter key is pressed.
      X$ = X$ + A$: J = J + 1
      PRINT A$;
      IF J > 79 THEN PRINT "Exceeded 79 characters.": GOTO Done
   GOTO Morein
   Done:
       PRINT
       FOR I = 1 TO 2000
         PRINT X$
       NEXT
       END
   Message:
       PRINT " Five Seconds "    ' Display Message After 5 Seconds.
       RETURN
Note: The following Microsoft Basic products do NOT support event trapping features, such as ON TIMER(n) GOSUB or ON KEY(n) GOSUB:

  1. Microsoft Business Basic Compiler 1.00 and 1.10 for Ms-Dos
  2. Microsoft Basic Compiler 5.35 and 5.36 for Ms-Dos
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB31885


Macintosh QuickBasic System Error 12 Using Init or Old Finder (31887)

Summary

A System Error ID=12 ("Unimplemented core routine error") can occur when trying to run QuickBasic under a Finder version earlier than 5.5 or a System version earlier than 4.1. A system hang occurs because QuickBasic makes a call to the system trap that is not implemented in earlier versions of the System and Finder.

These system version requirements are documented on Page 4 of the "QuickBasic for Apple Macintosh: User's Guide" (and also further below).

System Error 12 can also occur if system traps used by QuickBasic conflict with an Init file stored in your System Folder. QuickBasic is not designed to be compatible with Inits and you will need to remove the incompatible Inits from the System Folder.

System Error 12 can also occur if you use the Toolbox statement to invoke a routine that is not implemented in your version of the System or ROM. For example, the new routines in "Inside Macintosh" Volume V (Published by Addison-Wesley) require System Version 6.0 or later. The SndPlay system trap, which is documented in Volume V, plays a sound or "snd " resource and gives System Error 12 unless you boot with System 6.0 or later.

More information

Microsoft QuickBasic 1.00 for the Apple Macintosh has the following system requirements:

  1. A Macintosh with a 128K ROM (such as the Macintosh Plus, Macintosh SE, or Macintosh II)
  2. System Version 4.1 or later
  3. Finder Version 5.5 or later
  4. Two disk drives, at least one of which must handle 800K disks
Note that QuickBasic will not run on a 128K-RAM or 512K-RAM Macintosh that has the older, non-Enhanced (64K) ROM.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB31887


"Subprogram Already in Use" with Recursive SUB CALL (31888)

Summary

The message "Subprogram Already in Use" (error 36) is generated when trying to recursively call a STATIC subprogram in an interpreted or compiled program. This is because the STATIC argument must be removed from the SUB statement to make it a dynamic subprogram, which can then be called recursively.

Any attempt to call a dynamic subprogram in the interpreter will give a "Missing STATIC in SUB statement" message. The Macintosh QuickBasic Interpreter does not support dynamic subprograms (i.e., recursive subprogram calls). Only compiled programs support recursive subprogram calls.

More information

Both the compiler in QuickBasic and the older Microsoft Basic Compiler Version 1.00 for Apple Macintosh support recursive, dynamic SUBprogram CALLs.

The interpreter in QuickBasic and the Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh do not support SUBprogram recursion, and require the STATIC argument on the SUB statement.

The program below contains a recursive (dynamic) subprogram which calls itself five times. If this program is executed in the Interpreter, the error will occur. As a compiled program, the error does not occur.

The following is a code example:
DEFINT A-Z
PRINT "OUTPUT:  "
CALL RECursION(5)
SUB RECursION(5)     ' Dynamic subprogram
  IF MAX <> 0 THEN
     FOR I=1 TO MAX
       PRINT I;
     NEXT I
     PRINT
     MAX=MAX-1
     CALL RECursION(MAX)   ' calls itself until max = 0
   END IF

END SUB
This is the output of the program:
OUTPUT:
 1  2  3  4  5
 1  2  3  4
 1  2  3
 1  2
 1
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB31888


Undo Command Is Unavailable Except for Desk Accessories (31927)

Summary

The Undo feature on the Edit menu is not available in the Macintosh QuickBasic editor.

The Undo command can be used only with a desk accessory that has been activated from the Apple menu. Desk accessories may be invoked from the Apple menu at any time to run on top of QuickBasic. The Undo command remains dimmed (i.e., it cannot be selected) when no desk accessory is currently active. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB31927


Difference between Decimal and Binary Macintosh QuickBasic (31928)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The binary and decimal versions of Microsoft QuickBasic for the Macintosh include the same features. They differ only in that they use different formats for floating-point numbers. The two versions have different desktop icons, as do applications written with them.

    The binary version (IEEE format) is best suited to scientific and engineering applications. Arithmetic operations are always faster in this version than in the decimal version, especially for the transcendental functions (i.e., SIN, COS, SQR, LOG, and ATN). The default numeric type is single precision in binary QuickBasic.

    The decimal version (BCD format) is best suited to business and financial applications because it introduces no round-off error for calculations involving dollars and cents. The default numeric type is double precision in decimal QuickBasic. Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB31928


Purpose of the Apple Editor's Time Stamp Command (31932)

Summary

Edit, the Apple Editor, is a utility supplied with Microsoft QuickBasic 1.00 for the Macintosh and the Microsoft Basic Compiler 1.00.

The Time Stamp command in the Edit menu of the Edit editor inserts the current date and time into a document at the current location of the text cursor. The date and time can be inserted into a string constant or a Basic remark statement (beginning with REM or a single quotation mark (')). Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB31932


Macintosh QuickBasic 1.00 New Features (31934)

Summary

The following is a list of the new features found in Microsoft QuickBasic 1.00 for the Macintosh that are not found in the Microsoft Basic Version 3.00 Interpreter or Basic Version 1.00 Compiler:

  1. Full compiler/interpreter integration
  2. New language and Toolbox extensions, including color support
  3. New support for machine-language and high-level-language routines
  4. Improved HFS (Hierarchical File System) support
  5. Full compatibility with Macintosh SE and Macintosh II
  6. Access to the 68881 math coprocessor (compiler only)
  7. New debugging tools
  8. Long-integer support
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB31934


How to Create Custom Alert Boxes with ResEdit (31935)

Summary

Custom alert boxes can be created for QuickBasic programs using ResEdit, as follows (before using ResEdit, please read the ResEdit section in the "Microsoft QuickBasic Compiler for Apple Macintosh: User's Guide"):

  1. Run ResEdit.
  2. Go into the resource area of the program or resource file.
  3. If there is not a resource called Alrt, use the New option on the File menu to select Alrt for the New Type Name.
  4. To create a custom alert box, go into the Alrt resource and select New on the File menu. This creates a new alert box and opens a window with the blank alert displayed.
  5. To create items for the new alert, double click the blank alert box. This will bring up the dialog-item list associated with the alert.
  6. At this point, selecting New on the File menu brings up a window that allows you to create buttons and areas for text, and to insert icons and other resources.
  7. Once an item has been selected, closing that window brings you back to the dialog-item list window where the newly created item can be placed in its desired position in the alert box.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB31935


Macintosh QuickBasic 1.00 System Requirements (31937)

Summary

Microsoft QuickBasic 1.00 for the Apple Macintosh requires a Macintosh with a 128K ROM and 1 megabyte of RAM, as follows:

  1. Macintosh Plus
  2. Macintosh SE
  3. Macintosh II
QuickBasic will not run correctly on (and has not been tested on) a 128K-RAM, 512K-RAM, or 512K-RAM E (Enhanced) Macintosh. (The 512K-RAM unenhanced Macintosh has a 64K ROM. The 512K-RAM Enhanced Macintosh has a 128K ROM. The "Enhanced" refers to the upgrade to the 128K ROM.)

QuickBasic requires System and Finder versions no earlier than System Version 4.10 and Finder Version 5.50.

Programs can be developed using only one 800K disk drive, but very frequent disk exchanges will be required. Using two drives, at least one of which is 800K, is much more efficient. Microsoft recommends two drives, at least one of which is 800K or larger. For the serious developer, a hard disk is better still. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB31937


"Invalid Function Call" Listing Window of File Saved Protected (31938)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    If a program has been saved in the Protected file format, you cannot open a List window for that file. Protected files cannot be listed, edited, or compiled; they can only be run in the interpreter. QuickBasic displays an "Invalid function call" error if you attempt to display the Listing window for a program that has been saved in Protected format. The Basic interpreter Versions 2.x and 3.00 display an "Illegal function call" error.

    A file is protected by saving it with the Protected option in the Save As... command in the File menu. The default format when saving files is Compressed. You Must save a copy of the file under another name using the Text or Compressed format Before saving the file as Protected if you wish to access the source code in the future.

    This article applies to the interpreter in Microsoft QuickBasic Version 1.00, and to Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for Apple Macintosh. Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB31938


COMMON Required/CHAINed Compiled Program, Not Interpreter (32220)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    The use of COMMON blocks during a CHAIN operation differs in compiled programs compared to programs that are run in the interpreter. The interpreter requires COMMON statements only in the CHAINing program. Compiled programs require matching COMMON statements in both the CHAINing and CHAINed programs.

    This information applies to Microsoft QuickBasic 1.00, the Microsoft Basic Compiler 1.00, and the Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for Apple Macintosh.

    More information

    When a program is being interpreted, the names of all variables are always available, and variables are looked up by name. The CHAINing program can send all of the variables specified by COMMON statements to the CHAINed program, which can then look them up by name as it encounters statements containing variables. Therefore, the interpreter requires COMMON statements only in the CHAINing program.

    Compiled programs do not use variable names. During compilation, names are translated to addresses, which are stored as part of the object code. At run time, the addresses are used to manipulate objects contained at the addresses. Thus, the names are used only at compile time and are not known at run time. Therefore, unlike the interpreter, the compiler requires that the same variables be declared in both the CHAINing and CHAINed programs. The same variables must be declared in COMMON in exactly the same order in both the CHAINing and CHAINed programs.

    The following program (Program A) assigns values to variables and an array. It then CHAINs to Program B, which prints out the values.
    ' Program A
COMMON A%,B&,C!,D#,E$,X(1)
DIM X(3)
A% = 12345
B&amp; = 1234567890&
C! = 1.2345
D# = 1.23456789#
C$ = "string"
FOR I=1 TO 3
X(I) = I
NEXT I
Ext$ = ""
IF SYSTEM(4) then Ext$ = " Apl"   ' SYSTEM(4) requires QuickBasic 1.00.
CHAIN "B.Bas" + Ext$              ' CHAINing to program B.
    The following program (Program B) prints out the values of variables generated in Program A:
    ' Program B
COMMON A%,B&,C!,D#,E$,X(1)   ' This Statement IS Only Required FOR
                             ' Compiled ProgRAMS. IT IS Optional IF
                             ' Used IN THE Interpreter.
PRINT A%,B%,C!,D#,E$
FOR I=1 TO 3
PRINT X(I)
NEXT I
END
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB32220


Passing Dynamic and STATIC Arrays in COMMON; Macintosh Basic (32222)

Summary

Passing STATIC and Dynamic arrays in COMMON differs for compiled and interpreted Macintosh QuickBasic programs. The order in which arrays are declared in COMMON and dimensioned is crucial for the compiler. Because either of the compiler formats is acceptable under the interpreter, Microsoft recommends following the syntax rules for compiled programs, as shown in formats 1 and 2 below.

More information

The formats for Dynamic and STATIC arrays in COMMON for the compiler and interpreter are as follows:

  1. The following information pertains to passing STATIC arrays in COMMON in a compiled program:

    The DIM STATIC statement (or the DIM statement when the "Use Static Arrays" option is on) must come before the COMMON declaration. The array name in the COMMON declaration must be followed by empty parentheses, as shown below:
             DIM STATIC A(20,20)
         COMMON A()
  2. The following information pertains to passing Dynamic arrays in COMMON in a compiled program:

    The DIM statement must come after the COMMON declaration. The array name in the COMMON declaration must be followed by the number of dimensions (not the sizes of the dimensions) in parentheses as shown below:
             COMMON A(2)
         DIM A(20,20)
  3. The following information pertains to passing Dynamic arrays in COMMON in an interpreted program:

    The COMMON declaration may come before or after the DIM statement in the interpreter. The array name in the COMMON declaration may be followed by the number of dimensions (not the sizes of the dimensions) in parentheses, or the array name may be followed by empty parentheses.
  4. The following information pertains to STATIC arrays in an interpreted program:

    There are no STATIC arrays in an interpreted program. Although you may use DIM STATIC in the interpreter, it allocates only Dynamic arrays. The STATIC keyword in a DIM statement is ignored by the interpreter. Because either of the compiler formats is accepted by the QuickBasic interpreter, Microsoft recommends following the rules for compiled programs.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32222


Mac Basic Interpreter Allocates Dynamic Arrays, Never STATIC (32223)

Summary

The interpreter in QuickBasic 1.00 for Macintosh supports only Dynamic arrays. (The same is true for the Basic interpreter Versions 3.00 and earlier.) The compiler supports both STATIC and Dynamic arrays.

The STATIC keyword in a DIM statement is ignored by the QuickBasic interpreter, and the array is made Dynamic. In the older Basic interpreter Versions 3.00 and earlier, the DIM STATIC statement gives a "Syntax Error" message when executed and does not dimension the array.

More information

STATIC arrays are allocated space at compile time, and cannot be removed from memory with the ERASE statement. Accessing STATIC arrays is faster than accessing Dynamic arrays.

Dynamic arrays are allocated space at run time, and can be removed from memory with the ERASE statement, which allows more flexible memory management than STATIC arrays when memory is tight. Using Dynamic arrays in a program makes it slower than if it were using STATIC arrays.

Although you may use DIM STATIC in the QuickBasic interpreter, it allocates only Dynamic arrays. The STATIC keyword in a DIM statement is ignored by the QuickBasic interpreter. Because either of the compiler formats would be acceptable under the QuickBasic interpreter, Microsoft recommends following the rules for the compiler.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB32223


System Restart or Shutdown from Mac QuickBasic Program (32264)

Summary

The program below allows you to restart or shut down the Macintosh from within a QuickBasic program. For the program to work, the System file must be Version 4.10 or later. (To obtain the version number, select the System file and choose Get Info from the File menu.)

Before executing the following portion of code, it is very important to be sure all files and resources have been closed. If files and resources are left open when the computer is restarted, the files may be corrupted.
DIM restart%(2), ShutDown%(2)
setarray restart%(0),&H3F3C,&H2,&HA895
setarray ShutDown%(0),&H3F3C,&H1,&HA895
input "Enter 1 for Restartm 2 for Shut Down",i
if i = 1 then rs = VARPTR(restart%(0))  : CALL rs
if i = 2 then sd = VARPTR(ShutDown%(0))  : CALL sd
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32264


Using Command Window to Change Variable while Debugging (32269)

Summary

The following information pertains to changing the value of a variable while debugging a program in the Macintosh QuickBasic Interpreter.

Consider the following program:
   LET X% = 100
   LET Y% = 200
   PRINT X%
   PRINT Y%
   END
Assume that you have set a breakpoint at the third line. Before continuing the program's execution, you can change the value of any variable by selecting the Command window from the Windows menu and issuing the proper QuickBasic statement.

For example, to change the value of X% from 100 to 2, do the following:

  1. Select the Command window.
  2. Type the following:

    LET X% = 2

    Now, when Continue is selected from the Run menu, 2 will print for X% and 200 for Y%.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32269


Cannot View Data Files in the List Window: Use Another Editor (32325)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh

    • Summary

    This article applies to the Microsoft Basic Interpreter Version 3.00 and the interpreter environment of the Microsoft QuickBasic Compiler 1.00 for the Apple Macintosh.

    Viewing files in the List window that are not Basic program source files may display unexpected results. Files loaded into the List window are parsed and converted into an internal format with the assumption that the file is a Basic source program.

    A different editor, such as Apple's Edit, should be used to view data files.

    More information

    The following transformations will take place if a file is loaded into the List window:

    1. Spaces separating numeric data may be removed.
    2. Numbers may have "&", "!", or "#" numeric type symbols appended to them.
    3. Each tab character is converted into a single space.
    4. Basic reserved words are boldfaced.
    5. Option characters will cause a syntax error and halt file loading.
    If you inadvertently load a data file into Basic, you should not edit or save it, since it will be saved in the changed format.

    To view data files or other files that are not Basic program source files, you may use a text editing Desk Accessory, Edit, Microsoft Word, or another text editing program.

    Edit is included with QuickBasic 1.00 and Basic Compiler 1.00. If you only want to view the file, and not make changes, you may use the File Browser program included with QuickBasic 1.00.

    A text editing Desk Accessory (installed in the Apple menu) is very useful, and there are many good ones that are shareware or in the public domain, available through user groups or electronic bulletin boards.

    The following is an example:

    If the MYFILE.DAT file created by the following program is loaded into the Basic List window, the spaces will appear to be removed between numbers. If MYFILE.DAT is loaded into another editor, such as Apple Edit, the file will display as expected. The following is a code example:
    A = 1.2
OPEN "MYFILE.DAT" FOR OUTPUT AS #1
FOR I = 1 TO 5
  PRINT #1, USING "####.#"; A;   'The ";" at the end represses CR/LF
NEXT
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB32325


Function...END FUNCTION Not Supported by QuickBasic 1.00 (32326)

Summary

Microsoft QuickBasic 1.00 for the Apple Macintosh does not support function procedures or the FUNCTION or END FUNCTION statements. Only functions defined with the DEF FN statement are supported.

Function procedures (which are defined with the FUNCTION and END FUNCTION statements) are only supported by the following Basic products, which do not run on an Apple Macintosh:

  1. Microsoft QuickBasic 4.00 and later for the IBM PC and strict compatibles
  2. Microsoft Basic Compiler 6.00 and later for Ms-Dos and MS OS/2
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB32326


How to CLEAR Maximum Amount of Data Space; Heap Space (32327)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    The CLEAR statement can be used to set the maximum amount of data space that a Macintosh Basic program can use. This information applies to the Microsoft QuickBasic Compiler 1.00, Basic Compiler Version 1.00, and Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for Apple Macintosh.

    The program below sets the maximum amount of data space that can be safely allocated given a set heap space size. The variable heap& should be set to the amount of heap space desired. About 5K serves as a minimum amount for heap space; however, because many programs using ROM routines or system resources require more heap space, it is recommended to use between 50K to 100K for such programs.

    More information

    FRE(n), where n is any number or string (except -1 or -2), returns the number of bytes in Basic's memory space that are not currently being used.

    FRE(-1) returns the number of bytes in the Macintosh heap that are not being used by Basic.

    FRE(-2) returns the number of bytes in the stack that have never been used.

    The following is a code example:
    k&=100   ' Set k& to the number of kilobytes (1024 bytes) of heap desired.
heap&=k& * 1024&
PRINT "data";FRE(0);"heap";FRE(-1);"stack";FRE(-2)

' Subtract the desired heap size from the currently unused
' Datasize + Heapsize:
max& = FRE(0) + FRE(-1) - heap&
PRINT max&, heap&

' This CLEAR sets aside max& data space from the currently unused
' memory, and all other memory is taken by heap and stack:
CLEAR ,max&
PRINT "data";FRE(0);"heap";FRE(-1);"stack";FRE(-2)
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB32327


TextFace(2) Must Be Used with TextMode(1) in Macintosh Basic (32401)

Summary

TextFace(2), which converts output text to italic, cannot be used with TextMode(0), in which the text replaces the background when using the PRINT statement. You must first call TextMode(1), in which the text overlays (i.e., does not replace) the background, before calling TextFace(2). If you are using PRINT while TextMode(0) and TextFace(2) are set, unreadable output will result. TextMode(0) is the default TextMode.

The DrawText Toolbox routine works correctly in TextMode(0) with TextFace(2).

This information applies to the Microsoft QuickBasic Compiler 1.00, Basic Compiler 1.00, and Basic Interpreter Version 3.00 for the Apple Macintosh.

More information

TextFace(n) is a routine from the Macintosh ROM Toolbox that changes the character-face type for output purposes.

TextMode(n) is also a routine from the ROM Toolbox. Different values for TextMode affect how text output to the screen interacts with the existing contents of the screen.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB32401


Printing to Apple LaserWriter Supports Only PenMode 8 (Copy) (32402)

Summary

Only PenMode 8 (Copy mode) is supported by the Apple LaserWriter when you output from a Basic program using the WindOW OUTPUT #n statement to send output to the "LPT1:" or "Lpt1:Prompt" device name. This is a limitation of the PostScript page description language used by the LaserWriter.

This information applies to Microsoft QuickBasic 1.00, Basic Compiler 1.00, and Basic Interpreter Version 3.00 for the Apple Macintosh.

More information

The PenMode routine determines how subsequent ROM routine graphics calls will affect any images that are already on the output window. Only one of the eight modes, PenMode 8 (Copy mode) is supported by the LaserWriter. This limitation is documented on Page 393 of the "Microsoft QuickBasic for Apple Macintosh: Basic Language Reference."

This is a limitation of the PostScript page description language that does the actual drawing within the LaserWriter. Your QuickDraw calls are translated into PostScript when they are sent to the LaserWriter.

All PenModes should work correctly on an Apple LaserWriter SC, since this printer uses QuickDraw, and not PostScript as its imaging language. All PenModes should also work on an Apple ImageWriter I, II, or LQ.

The eight PenModes (numbered 8 through 15) are documented on Page 394 of the "Microsoft QuickBasic for Apple Macintosh: Basic Language Reference." In PenMode 11, which is Black-Is-Changed (BIC) mode, black pixels of the pen pattern change output window contents to white; white pixels of the pen pattern do not interact with the output window contents.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32402


$Page Metacommand Puts Page Headers in Compiler Listings (32403)

Summary

You can use the REM $Page or '$Page metacommand to specify page headers in Macintosh QuickBasic Compiler listing files. A listing file is created by selecting the Create Program List File option before compiling. Compiler listing files are given the extension "lst" by the compiler. This information applies to the Microsoft QuickBasic Compiler 1.00 and the Microsoft Basic Compiler 1.00 for Apple Macintosh.

More information

The compiler replaces the REM $Page metacommand with a page header. Like other metacommands, the $Page metacommand must be the first word of a comment starting at the beginning of a line. If a $Page follows a single-quotation mark (') or REM that is not in the first column, the metacommand will be ignored.

Macintosh QuickBasic 1.00 does NOT include a form feed character in the page header, since control characters may not be handled correctly by some text editors.

The Microsoft Basic Interpreter Version 3.00 or QuickBasic editor are unsuitable for printing or examining listing files. You may use the following programs to print out the program listing file:

  1. The "Print Listing File" program provided with QuickBasic 1.00
  2. Edit (included on the compiler distribution disk)
  3. Microsoft Word for Apple Macintosh, or another text editor
The Print Listing File program is the most convenient because it automatically forces a new page at the beginning of a page header. If you are using Edit, Word, or another text editor, then you will have to insert page breaks yourself.

In the following example, the $Page metacommand is used to create a page header between the main program and the "print2:" subroutine when the compiler-listing (" lst") file is created. You may use either '$Page or REM $Page to force a page header:
FOR i = 1 TO 100
   PRINT "hello"
NEXT i
GOSUB print2
END
'$Page
print2:
   PRINT "in print2 subroutine"
   RETURN
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB32403


Using Static/Dynamic Arrays in Compiler and Interpreter (32416)

The information in this article applies to:
  • Microsoft Basic Interpreter for Apple Macintosh 1.00

    • Summary

    All arrays in the Macintosh Basic interpreter are dynamic, but the compiler permits both static and dynamic arrays. Dynamic arrays can be erased and redimensioned during run time. Dynamic arrays give your program more control over how it uses memory. Static arrays are set up at compile time and cannot be redimensioned during run time.

    In compiled programs, static arrays are much more efficient than dynamic arrays because static array indices are calculated at compile time and do not have to be recalculated at run time. Whenever possible, specify static arrays for the compiler.

    More information

    You can make your programs handle arrays correctly in both the compiler and the interpreter in the following three ways:
    1. Define all arrays you would like to be compiled as static arrays as DIM STATIC in your program's source code. The QuickBasic interpreter allows this declaration but ignores it and defines your arrays as dynamic. This assures compatibility with the compiler.
    2. If none of the arrays in your program needs to be redimensioned and the size of the arrays is known at compile time, you can choose the "Use Static Arrays" option from the "Options..." command in the Run menu. This option makes all arrays static. Therefore, arrays will be dynamic in the QuickBasic interpreter, but static when compiled. If you choose the "Use Static Arrays" option, you may not use the ERASE statement because you can only ERASE dynamic arrays. Also, all static array sizes must be specified with constants or simple constant expressions, not with variables.
    3. If some, but not all, arrays in your program must be redimensioned at run time, or if the size of some arrays is not known at compile time, you must declare static arrays separately for the compiler. Dynamic arrays need no special treatment because they are dynamic in both environments. Arrays that can be static for the compiler must still be dynamic in the interpreter.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB32416


"Invalid Character" in Compiler on DIM for Dynamic Array (32417)

Summary

The compiler in QuickBasic for Macintosh gives an "Invalid character" message for a DIM statement at compile time if an array is dimensioned using a variable or function in the subscript, and the "Make All Arrays Static" compiler option is selected (or DIM STATIC is used). This error occurs because a static array must be dimensioned with a constant or simple constant expression in the array subscript in the DIM statement.

To allow a variable or function in the array subscript in the DIM statement, you must make the array dynamic (by turning off the "Make All Arrays Static" option and by using DIM instead of DIM STATIC).

If some arrays need to remain dynamic while others are static, use the DIM STATIC statement to dimension static arrays and DIM to dimension dynamic arrays, and do not select "Make All Arrays STATIC" (in the "Options..." item of the Run menu).

More information

The following code gives an "Invalid character" error at compile time only when you select the "Make All Arrays STATIC" compiler option:
   B=180
   DIM X(B)          ' Array must be dynamic.
   DIM Y(SQR(16))    ' Array must be dynamic.
The following code always gives "Invalid character" at compile time with or without the "Make All Arrays STATIC" option:
   B=180
   DIM STATIC X(B)        ' Always static when compiled.
   DIM STATIC Y(SQR(16))  ' Always static when compiled.
The following code compiles successfully with (or without) the "Make All Arrays STATIC" compiler option selected:
   DIM X(5 * 36)  ' Can be static or dynamic.
   DIM Y(4)       ' Can be static or dynamic.
ProgRAMMING Notes:

Arrays are always dynamic (never static) in the interpreter in QuickBasic. In the compiler, you can specify static or dynamic arrays.

Note that QuickBasic for Macintosh offers no REM $ metacommand feature to specify static or dynamic arrays.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB32417


No LIST, LLIST, Merge, NEW, TRON, TROFF in Basic Compiler (32418)

Summary

The interpreter in QuickBasic (and in the earlier Basic Interpreter Versions 1.x, 2.x, and 3.00) for Macintosh supports statements that control editing, debugging, and other features that are specific to the interpreter. Such statements have no meaning in compiled programs. They will produce compile-time errors if encountered in the source code. These statements include CHAIN Merge, LIST, LLIST, Load, Save, Merge, NEW, TRON, and TROFF.

More information

The following interpreter statements are not allowed in compiled source code; the compiler concepts that replace them are provided:

  1. CHAIN Merge: This command has no equivalent in the compiler. The compiler supports only a simple CHAIN with no Merge.
  2. LIST: You can view all or part of a program with a text editor, such as the interpreter environment or the Apple Edit program.
  3. LLIST: Compiled programs do not support the LLIST statement in source code. Normally, you would never need LLIST in source code, since you can invoke LLIST in the interpreter's Command window to print out the source listing. Note that the interpreter's LLIST command can only send output to a directly-connected ImageWriter I or II. LLIST cannot output to an Apple ImageWriter LQ or LaserWriter, and cannot output to a printer on the AppleTalk Network. To output to a greater variety of printers, you can print a source file by choosing the Print command from the interpreter's File menu; this will send output to any selected and supported Apple ImageWriter (I, II, or LQ) or LaserWriter.
  4. Load/Save: These commands have no equivalent in the compiler.
  5. Merge: You can merge two files in the interpreter and most text editors by copying one file to the clipboard, loading the next file, and then pasting. The QuickBasic Interpreter only opens one file at once.

    The Edit program on the QuickBasic 1.00 disk lets you open more than one file at once, and you can cut, copy, and paste between windows.
  6. NEW: This command has no close equivalent in the compiler. A compiled application is automatically cleared from memory after it finishes executing.
  7. TRON/TROFF: These debugging commands have no equivalent in the compiler. Programs can be debugged in the interpreter, then compiled.
Note that QuickBasic for Macintosh integrates the compiler into the Run menu of the interpreter environment. The earlier Basic Interpreter (Versions 1.00, 1.01, 2.00, 2.10, and 3.00) and earlier Basic Compiler (Version 1.00) are separate products.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32418


SOUND Truncation End of Compiled Program, OK Interpreter (32419)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    A sound created with the SOUND statement is placed in a queue and execution continues with the next statements while the sound is played. Sounds created with the SOUND statement are not heard if the compiled program ends before the sound can be played. This does not happen with programs in the QuickBasic interpreter since the QuickBasic interpreter is still available to make the sound after the program ends. If SOUND statements are put at the end of a program, you should create a delay in compiled programs so that the sound finishes before termination. This information applies to most Microsoft Basic compilers.

    More information

    The following line of code produces a sound that lasts for three seconds in the interpreter; however, no sound is heard when it is compiled:
       SOUND 523, 54
    The following program creates a four-second delay using the ON TIMER statement so that the compiled program will continue to execute and the sound will be heard:
          SOUND 523, 54
      IF SYSTEM(4)=0 THEN
      GOTO Finish               ' SYSTEM(4)=0 means program is interpreted
      ELSEIF SYSTEM(4)=1 THEN
      TIMER ON                  ' SYSTEM(4)=1 means program is compiled
      ON TIMER (4) GOSUB finish
      top: GOTO top
      END IF
      finish:
      END
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB32419


Pattern Editor, Resedit: How to Create New Pattern (32468)

Summary

The Pattern Editor program on the Basic released disk can be used to create a pattern to determine its hexadecimal (hex) representation. The hex representation of the pattern can then be loaded into an array to use with the various pattern toolbox routines. The Pattern Editor does not write patterns in a program's resource fork.

The Save and New options are always dimmed and cannot be selected. They appear on the screen and may be implemented in the future; however, these options are currently inactive.

To store a pattern in the resource fork of a program, you can use the Resedit application, as described below.

More information

To create a pattern using Resedit, do the following:
  1. Create a resource called PAT using the New option on the File menu if the PAT resource is not already present for the file.
  2. Open the PAT resource and select New on the File menu to bring up a blank window.
  3. Create your pattern by clicking in the center portion of the window. Clicking will toggle points in the window that represent an 8-byte pattern.
  4. The pattern's identification number can be changed by doing a Get Info on the File menu and changing the value in the ID field.
The following program loads a pattern (which was added to the resource fork of a program by Resedit) and fills a rectangle with the pattern:

   ref% = system(7)    'Sets reference number to current file
   id% = 1
   DIM pat%(3)
   DIM rect%(3)
   SetRect rect%(0),10,10,120,120
   LoadPattern ref%, id%, pat%(0)     ' Retrieves pattern into array.
   CALL FillRect(VARPTR(rect%(0)),VARPTR(pat%(0)))     ' Uses array.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32468


Use "Check arrays & overflow" option with arrays (32500)

The information in this article applies to:
- Microsoft QuickC Compiler, version 1.00

Summary
For Macintosh QuickBasic programs that use arrays, Microsoft recommends that you use the "Check Arrays & Overflow" compiler option. This option will ensure that any subscript-related problems will be made known to you at run time. If this option is not selected, out of bound array references are not detected.

Out of bound array references may corrupt program data, array descriptors, string descriptors, or program code. Corrupt descriptors or program code can easily produce a system hang.

If your program is mysteriously hanging or giving strange results, try recompiling with the Process Runtime Events and Check Arrays and Overflow options enabled.

Additional query words: MQuickB
Version: 1.00


"Inside Macintosh" Made Easy: "Technical Introduction" (32536)

Summary

The following book is a good introduction to the internal workings of the Apple Macintosh computer:

"Technical Introduction to the Macintosh Family" by Apple Computer, Inc.
300 Pages. $19.95.
Published by Addison-Wesley (1988).

This book fully describes the design and operations of the Macintosh Plus, SE, and II without all the programming details. The book is written for experienced users and novice programmers. The book defines all special terms and explains the Macintosh user interface, the ROM toolbox, Macintosh graphics, system software, files and volumes, memory management, the operating system, resources, hardware, and A/UX (Apple's version of the Unix operating system).

More information

If you want a more complete programmer's reference guide to the Macintosh, you can obtain the following set of books:

"Inside Macintosh"
by Apple Computer, Inc.
Five Volumes, 2100 total pages. List price is more than $100.00.
Published by Addison-Wesley.

See also the following book:

"How to Write Macintosh Software: the Debugging Reference for Macintosh" Second Edition
by Scott Knaster
Published by Hayden Books (1988).

The above books are valuable references for advanced programming in all Microsoft Basic interpreters and compilers sold for the Macintosh, including the following:

  1. Microsoft QuickBasic 1.00 for the Apple Macintosh
  2. Microsoft Basic Compiler 1.00 for the Apple Macintosh
  3. Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32536


Using FILES$ or FILES to Display Filename or Disk Directory (32724)

Summary

The FILES$ function and the FILES statement cannot display files based on the letters in the filenames. Wild cards in filenames, such as the "*" or "?" symbols supported in Ms-Dos file commands, are not supported in Basic for the Macintosh. (For example, the Ms-Dos command DIR *.DOC displays all files with .DOC in the name; however, Basic for the Macintosh does not have a similar feature.)

Although the FILES statement can send a disk directory to the screen, there is no easy feature to send a disk directory to a file or array, except through calls to Toolbox routines. (For more information, query on the word "HFSDispatch".)

Note that the CHDIR command affects the file folder (subdirectory) displayed by the FILES statement, but CHDIR does NOT affect the file folder displayed by the FILES$(1) function. FILES$(1) always displays the files in the folder where the source file is located (if run in the interpreter), or the files in the folder where the compiled program apl file is located (if run from a compiled program). The FILES$(1) window lets you manually look through other folders with the mouse.

This information applies to Microsoft QuickBasic 1.00, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Version 3.00 for the Apple Macintosh.

More information

The FILES$(n) function (where n can be 0 or 1) and the FILES statement offer different capabilities.

The FILES$(n) function can be used to display all files of a certain type and to return one selected filename in a string variable. For example, x$=FILES$(1,"Text") displays a dialog box listing all files of type Text. The following program displays a scroll box containing all files of type Appl (applications) and Text:
   x$=FILES$(1,"TextAppl")
   PRINT X$   ' Prints the name of the one selected file.

The FILES statement displays on the screen the filenames in the "current" folder and drive. On a 400K disk, all files will display regardless of their folders; however, on 800K or hard disks, only the files in the current folder will display. (The current folder is defined as the folder in which the Basic interpreter or compiled program is located.)

Basic's current folder can be changed with the CHDIR command. For example, the following program changes the current folder on the disk called "HD 20" to a folder called "System," and the FILES statement displays the files in that folder:
CHDIR "HD 20:System:"
FILES
A colon (:) is required after both the disk name and folder name, as shown above.

The CHDIR statement affects the folder displayed by the FILES statement, but NOT the folder displayed by default by the FILES$(1) function. The FILES$(1) function displays a scrolling dialog box which lets you manually change folders (subdirectories) with the mouse.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32724


"Type Mismatch" Using Boolean Arguments in ToolBox CALL (32728)

Summary

Some ToolBox routines require boolean arguments; however, boolean is not an inherent data type of Basic. In Macintosh QuickBasic, an integer variable may substitute for a boolean under certain constraints. The integer variable must be initialized to one of two values, -1 (true) or 0 (false). If the variable is not initialized in the prescribed manner, a "TYPE Mismatch" error will occur at run time.

For more information on making calls to ToolBox routines, please refer to Pages 418-430 of the "Microsoft QuickBasic for the Apple Macintosh: Reference" manual. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32728


Use Logical AND to Determine Which Bits Are Set in an Integer (32730)

The information in this article applies to:
  • Microsoft Visual Basic for Ms-Dos 1.00
  • Microsoft QuickBasic for Ms-Dos 4.00
  • Microsoft QuickBasic for Ms-Dos 4.0B
  • Microsoft QuickBasic for Ms-Dos 4.50
  • Microsoft Basic Compiler for Ms-Dos and OS/2
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.10
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft GW-Basic Interpreter 3.20
  • Microsoft GW-Basic Interpreter 3.20 and later

    • Summary

    The logical AND operator can be used in Basic to determine which bits are set. For example, the program below determines whether a bit has been set in the High or Low byte of a 2-byte integer variable.

    More information

    The CALL INTERRUPT or Int86old functions in Visual Basic for Ms-Dos return information by setting certain bits in the AH or AL register. The program listed below determines whether a bit has been set in the High or Low byte of a 2-byte integer variable:
    ' To try this example in Vbdos.Exe:
' 1. From the File menu, choose New Project.
' 2. Copy the code example to the Code window.
' 3. Press F5 to run the program.

INPUT x%  'Give it an integer value.
PRINT "Bits set in the High byte of x%."
IF x% < 0 THEN PRINT "Bit 7 set!"
mask% = &H4000
FOR i% = 6 TO 0 STEP -1
   IF x% AND mask% THEN PRINT "Bit"; i%; " set!"
   mask% = mask% \ 2
NEXT
PRINT "Bits set in the Low byte of x%."
' For just the Low byte, mask% starts out as 128.
FOR i% = 7 TO 0 STEP -1
   IF x% AND mask% THEN PRINT "Bit"; i%; " set!"
   mask% = mask% \ 2
NEXT
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB32730


"Statement Not in a Subprogram Block"; Order SUBs Last (32790)

Summary

The compile-time error message "Statement not in a subprogram block" occurs in QuickBasic for the Macintosh when compiling a program in which main-level code occurs after a subprogram (SUB...END SUB) definition. The Macintosh Basic interpreter allows subprogram (SUB...END SUB) blocks to be interspersed within main level code; however, in compiled programs, all subprogram declarations must come after the main program.

To move the subprograms to the end of the program, you may do either of the following:

  1. Cut and paste in the QuickBasic editor.
  2. Run "SortSub" (provided on the Macintosh QuickBasic release disk) or the compiled version "SortSub apl". Note that "SortSub" can only sort programs that are saved as text. "SortSub" renames the original program (by giving it an extension) and gives the sorted program the original program name.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32790


BUG: Dialog Box Static Text Not Displayed in Macintosh Basic (32965)

Symptoms

The program below, which repeatedly gets and disposes a dialog box, fails to display the dialog box's static text field. Editable text fields are displayed correctly.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic Version 1.00, Microsoft Basic Compiler 1.00, and Basic Interpreter Version 3.00 (buglist3.00) for the Macintosh .

More information

The following program accesses a dialog box that has an editable text field (id = 3), a static text field (id = 4), and two buttons (id = 1 and 2):
item%=0
ref%=0
OpenResFile "TestEditField.Res",REF%
Cancel%=0
Text$ = "Editable Text"
While (Cancel% = 0)
   Pointer! = 0
   GetNewDialog ref%, 100, Pointer!
   SetDialogText Pointer!, 3, Text$
   ModalDialog Pointer!,Item%
   IF Item% = 1 THEN
      Cancel% = 0
   ELSE
      Cancel% = 1
   END IF
   DisposeDialog Pointer!
WEND
CloseResFile ref%
END
Program Note: You must use ResEdit to create the dialog box in the file TestEditField.Res to duplicate the problem in the above program.

Another customer reported a similar problem where a static picture was not consistently displayed in a dialog box created in ResEdit.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB32965


Dialog and Alert Boxes in Macintosh QuickBasic (32966)

Summary

Macintosh dialog boxes and alert boxes are special types of Macintosh resources which can be created with ResEdit. Toolbox library routines provided with QuickBasic allow you to display and use dialog and alert boxes. QuickBasic gives you some predefined dialog and alert boxes in the "Demo Resources" file on the release disk.

Macintosh programs use dialog boxes when the program requires information in order to perform an operation. An alert box is a special kind of dialog box used by a program to call your attention to something or to report an error.

Please see the following for more information about dialog and alert boxes:

  1. "Dialog Example" program on the QuickBasic 1.00 release disk.
  2. "Alert Demo" program on the QuickBasic 1.00 release disk.
  3. Section E.7 "Alert and Dialog Boxes" in "Microsoft QuickBasic for Apple Macintosh: Language Reference," Pages 439-442.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32966


ToolBox Statement "Illegal Function Call"; ToolBox "i" (32967)

Summary

An "Illegal Function Call" error message will be generated if you attempt to use the ToolBox statement (to call a ROM routine) without first performing the following statement:
   ToolBox "i"
In order to use the ToolBox statement, it must first be initialized as shown above. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB32967


How to Find Name of Currently Chosen Macintosh Printer Driver (32970)

Summary

The following Macintosh QuickBasic program shows how to find the name of the current printer driver:
   printer$ = ""
   WHILE INKEY$ = "
       LoadString PEEKW (&HA58),-8192,printer$
       IF printer$<>last$ THEN CLS: PRINT printer$; :last$=printer$
   WEND
The memory location &HA58 contains the reference number of the Macintosh System file. The string id -8192 contains the name of the currently chosen printer driver. However, because these names may be changed freely with the Chooser in the Apple menu of the Finder, this may not be very useful. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB32970


How to Send Contents of a Specified Window to a Printer (32971)

Summary

The following subprogram can be used to print a copy of a specified window to the printer. This example requires all arrays to be dynamic; therefore the Make All Arrays STATIC compile option cannot be used. The following PrintWindow subprogram can be found on the QuickBasic distribution disks in the Utility Subprograms file in the QB Demos folder.

More information

The program below does the following:

  1. Uses the WindOW() function to determine the coordinates of the current window
  2. Executes a graphics GET statement to get the whole window into an array
  3. OPENs the "Lpt1:Prompt" printer device as #10
  4. Executes the WindOW OUTPUT #10 statement to redirect screen output to the printer
  5. Executes a graphics PUT statement using the array obtained in step 2
The following is the code example:
'The following statement makes a window that fills the screen:
WindOW 1,"Maximum-Sized Window",(0,21)-(SYSTEM(5),SYSTEM(6)),3
FOR J=1 TO 18 : PRINT "This IS ON THE WindOW" : NEXT
PrintWindow 1,3
END
SUB PrintWindow (n%,type%) STATIC
' n% = window id number.
' type% = window type.
' If 1 < type% < 7, then the window frame and contents are printed;
' otherwise only the window contents are printed. Window types can be
' from -7 through 7.
    max&=(4+(WindOW(2)+21)*2*INT((WindOW(3)+36)/16))/4+1
    IF max&>32767 OR max&*4+26>FRE(0) THEN BEEP: EXIT SUB
    DIM win&(max&)
    saved%=WindOW(0): WindOW n%
    l% = -1: t% = -1: b% = WindOW(3)+1: r%=WindOW(2)+1
    SELECT CASE type%
    CASE 1,7    :t%=t%-18 :r%=r%+15
    CASE 2      :t%=t%-7  :l%=-8 :b%=b%+6 :r%=r%+6
    CASE 3      :b%=b%-1  :r%=r%-1
    CASE 4      :b%=b%+1  :r%=r%+1
    CASE 5      :t%=t%-18
    CASE 6      :t%=t%-18 :b%=b%-1 :r%=r%-1
    CASE ELSE   :t%=0 :l%=0 :b%=WindOW(3)-1 :r%=WindOW(2)-1
    END SELECT
    GET (l%,t%)-(r%,b%),win&
    OPEN "lpt1:prompt" FOR OUTPUT AS #10
    WindOW OUTPUT #10
    PUT (0,0),win&
    CLOSE #10
    ERASE win&
    WindOW saved%
END SUB
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32971


How to Dump Current Macintosh Screen or Window to Printer (32972)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    This article describes how a QuickBasic program can dump the entire Macintosh screen (Code Example 1) or dump just the current window contents (Code Example 2) to an Apple ImageWriter or LaserWriter printer.

    When the examples below print color screens, the pixel colors are translated as follows:

    White <= yellow, magenta, cyan, white

    Black <= red, green, blue, black

    For more information about color translation of the GET and PUT statements, query on the following words in the Microsoft Knowledge Base:

    graphics and get and put and monochrome and macintosh

    More information

    Both examples 1 and 2 require dynamic arrays; therefore, if you compile, you must compile Without the "Make All Arrays STATIC" option in QuickBasic. The interpreter in QuickBasic always uses dynamic arrays.

    Code Example 1

    The PrintScreen subprogram in the Utility Subprograms file in the "QB Demos" folder is very similar to the following example, and can be used in place of this example to save retyping.

    The QuickBasic subprogram below enables you to dump the entire current Macintosh screen contents to the printer. Unlike the Lcopy statement, which also performs a screen dump, this subprogram also works for color screens and LaserWriters, although LaserWriter output will take a very long time. (Lcopy works only with a directly connected Apple ImageWriter and does not work over the AppleTalk network or to an Apple LaserWriter.)
    PrintScreen 0,0,0   ' Prints whole screen without any scaling.
END
SUB PrintScreen(scale%,x%,y%) STATIC
' If scale% is true (nonzero) then the output is scaled to x% wide and
' y% high. If scale% is false (zero) then the screen is printed full
' size, and x% and y% are ignored.
    ' Calculate array size:
    max&=(4+(SYSTEM(6)+1)*2*INT((SYSTEM(5)+16)/16))/8+1
    ' Make sure there's enough memory and the array is within bounds.
    ' BEEP and EXIT if screen too big:
    IF FRE(0)<max&*8+26 OR max&>32767 THEN BEEP :EXIT SUB
    DIM origin%(1),screen#(max&)
    ' Get relative offset from current window(0,0):
    LocaltoGlobal origin%(0)
    x2 = SYSTEM(5)-origin%(1)
    y2 = SYSTEM(6)-origin%(0)
    GET (-origin%(1),-origin%(0))-(x2,y2),screen#
    OPEN "lpt1:prompt" FOR OUTPUT AS #10
    WindOW OUTPUT #10
    IF scale% THEN PUT(0,0)-(x%,y%),screen# ELSE PUT(0,0),screen#
    CLOSE #10
    ERASE origin%,screen#
END SUB

    Code Example 2

    The following example sends just the contents of the current window to the printer:
    FOR J=1 TO 10 : PRINT "This goes to printer" : NEXT
' Calling this SUBprogram prints just the contents of the current
' window:
CALL PrintWindow
END
SUB PrintWindow STATIC
    max&=FRE(-1)  ' Compacts memory to avoid heap memory fragmentation
    ' Calculate array size:
    wh=WindOW(3)-1   ' Window height minus one pixel of border.
    ww=WindOW(2)-1   ' Window width minus one pixel of border.
    max&=(4+(wh+1)*2*INT((ww+16)/16))/4 + 1
    ' Make sure there's enough memory and the array is within bounds.
    ' BEEP and EXIT if window image is too big:
    IF max&*4+26>FRE(0) OR max&>32767 THEN BEEP :EXIT SUB
    DIM win&(max&)
    GET (0,0)-(ww,wh),win&   ' GET current window contents into array.
    max&=FRE(-1)  ' Compacts memory before OPENing printer device name
    OPEN "lpt1:prompt" FOR OUTPUT AS #10
    WindOW OUTPUT #10
    PUT(0,0),win&   ' PUT image to printer.
    CLOSE #10
    ERASE win&
END SUB
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB32972


Only Eight Library Files Can Be Open at Once (32973)

Summary

A Macintosh QuickBasic program may have up to eight library files open at a time.

When QuickBasic encounters a Library statement, it opens the named file as a resource file. The routines are then available to the QuickBasic program. QuickBasic leaves a library file open until the program executes a NEW, SYSTEM, RUN, or Library CLOSE statement. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB32973


How to Create a Macintosh Pure-Code Resource Library (32974)

Summary

The steps for turning a C or Pascal program into a Macintosh pure-code resource depend upon which compiler you have. However, the following five steps must be done before you can use the pure-code resource in a QuickBasic library file:

  1. The file creator type must be set to MSBB for the binary version of QuickBasic or MSBD for the decimal version.
  2. The file type must be MSBL.
  3. Each pure-code resource must have a resource type of MBPC.
  4. You must assign an ID number to each pure-code resource. The ID number must be unique within the library and across libraries if you use multiple libraries.
  5. Each pure-code resource must have a resource name. The resource name is the name used to call the routine from QuickBasic.

More information

You can create two kinds of libraries to use with QuickBasic: libraries of pure-code resources and libraries of assembly-language routines.

  1. Pure-code resources are libraries of routines that are written in a high-level language such as C or Pascal, compiled into pure code, then combined into a resource file. (The QuickBasic Compiler itself is not able to output pure code.)
  2. Assembly-language libraries are first written in assembly language, then assembled, and finally combined into a resource files containing code resources.
For instructions on how to create a pure-code resource library using C or Pascal, please refer to the "Microsoft QuickBasic for the Apple Macintosh: Language Reference" manual Pages 444 - 467, particularly Pages 450 - 451.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB32974


Multiple Resources with Same ID Number Saved in Resource File (32975)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    The routines that save resources to a resource file (listed below) do NOT overwrite (replace) an existing resource that has the same ID number. Instead, the following routines place a second resource with the same ID in the file:

    AddCursor, AddIcon, AddPattern, AddPicture, AddRes, AddString, SaveArray, SaveCursor, SaveIcon, SavePattern, SavePicture, SaveString

    You can avoid writing two resources with the same ID number in a resource file by executing GetRes to get the handle of the existing resource, then executing RemoveRes to delete it before saving the new resource.

    This information applies to the above routines in Microsoft QuickBasic Version 1.00 (MBLC toolbox library routines), Microsoft Basic Compiler Version 1.00 (Library "ToolLib" routines), and Microsoft Basic Interpreter Version 3.00 for the Apple Macintosh (Library "ToolLib" routines).

    More information

    The Add*** routines take a resource identified by a handle in memory (heap) and put that resource into a resource file on disk. (The Get*** routines do the converse operation. Get*** routines take a resource identified by an ID number in a resource file, place that resource into memory, and assign it a handle.)

    The Save*** routines store a Basic variable (or array) into a resource file on disk. (The Load*** routines do the converse operation. Load*** routines take a resource identified by an ID number in a resource file and place that resource into a Basic variable or array in memory.)

    The following Add*** and Save*** routines put resources into a resource file (and the corresponding Get*** and Load*** routines in parentheses show the reverse operation):

    1. AddCursor, AddIcon, AddPattern, AddPicture, AddRes, AddString (GetCursor, GetIcon, GetPattern, GetPicture, GetRes, GetString)
    2. SaveArray, SaveCursor, SaveIcon, SavePattern, SavePicture, SaveString (LoadArray, LoadCursor, LoadIcon, LoadPattern, LoadPicture LoadString)
    In QuickBasic, Toolbox library routines such as Add***, Get***, Save***, and Load*** are stored as MBLC resources in QuickBasic itself. In the earlier Basic Compiler 1.00, and in the earlier Basic Interpreter Version 3.00, Toolbox library routines are provided in a separate library file called ToolLib on the Basic Toolbox Disk (Disk 2 of 2).
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB32975


DrawText Faster Than PRINT, Output to Screen or Printer (33018)

Summary

If output to the screen or WindOW OUTPUT# to the printer is slow, use the DrawText toolbox routine instead of PRINT statements. DrawText is much faster than the Basic PRINT statement. PRINT outputs each character individually, whereas DrawText outputs an entire string of characters at once. However, you will still need to use PRINT for number formatting or carriage returns. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB33018


Eight Colors Available in QuickBasic on Macintosh II (33037)

Summary

The only colors supported by QuickBasic for Macintosh are the colors that are available with the Macintosh QuickDraw.

The colors and their respective values are as follows:

Black = 33
White = 30
Red = 205
Green = 341
Blue = 409
Cyan = 273
Magenta = 137
Yellow = 69

These color numbers are used in the following QuickBasic Toolbox Library routines:
   ForeColor color%
   BackColor color%

More information

The windows that Basic opens can only contain the plain QuickDraw 8 colors. In technical terms, Basic's windows are based on GrafPorts, not CGrafPorts. This guarantees that the Basic program will run on any Macintosh, whether it has color QuickDraw or not.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB33037


Graphics GET and PUT Change Colors to Monochrome in QuickBasic (33038)

Summary

The graphics GET statement in QuickBasic 1.00 for the Macintosh does not preserve the colors of graphics in its array argument, and a subsequent graphics PUT using that array will draw in monochrome, using only the current foreground and background colors.

The following list shows how the GET statement translates pixel colors on the screen and stores them in the array:

  1. White (or current background color) <= yellow, magenta, cyan, white
  2. Black (or current foreground color) <= red, green, blue, black

More information

The GET statement captures screen information as a bitmap only, i.e., only the on or off status of each pixel -- not the color information -- is stored in the array.

The ForeColor and BackColor MBLC routines let you change the color used by subsequent graphics statements. For example, invoking ForeColor and BackColor will cause a subsequent graphics PUT to use that foreground and that background for all pixels (regardless of any multiple colors that were on the screen when the graphics GET filled the array).

For an example of how to create color images with ForeColor and BackColor in Macintosh QuickBasic, run the Crazy Colors program found in the "QB Demos" folder on the Examples disk that comes with QuickBasic 1.00.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB33038


ForeColor Changes Colors for LINE, Circle, and PSET (33039)

Summary

In Microsoft QuickBasic for Macintosh, the only numbers that can be specified in the color parameter for LINE, Circle, and PSET are 30 and 33. By default, 30 represents white and 33 represents black.

(Actually, any even number defaults to white and any odd number to black.) If no number is specified, the color defaults to black.

However, the ForeColor Toolbox routine can be used to change what colors are associated with numbers 30 and 33. The following example fills in rectangles with the various available colors:
   FOR i = 0 TO 7
   ForeColor (i-1)*64 + 1
   LINE (i*10,10)-(i*10+8,300),,bf
   NEXT i
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB33039


"File Code Segments That Conflict with QuickBasic" Error (33040)

Summary

The error message "File contains Code segments that conflict with QuickBasic's Code" is encountered if you are using library routines in the program's resource fork with Code resources that conflict with QuickBasic's Code resources.

This message often occurs when updating from the earlier Basic compiler Version 1.00 or Basic interpreter Version 3.00 for Macintosh. QuickBasic's Code resources have ID numbers 0 through 37. If the program has a Library or OpenResfile statement which opens Code resources that have numbers between 0 and 37, this message will be generated.

This error also occurs if you mistakenly overwrite your source code at compile time by specifying a name for the compiled application that matches the name of the source code. Do not overwrite your source code with an application; otherwise, your source will be lost!

More information

QuickBasic accesses a routine by its ID number; therefore, because the program's resource fork is opened after QuickBasic's, this causes QuickBasic to access the wrong resources. To resolve the problem, comment out the Library statement in the Basic program and compile with the "Copy MBLCs and MBPCs" switch enabled.

If you need to use older custom libraries, make sure the ID numbers for those Code segments are greater than 100. To accomplish this, compile and run the "Renumber Codes" utility on the Examples disk in the "Tools" folder. This message is only generated when running the program in the QuickBasic interpreter environment.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB33040


Program Can Hang During Communications if Not Setup Correctly (33041)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    QuickBasic for the Macintosh will hang if there is something wrong with the serial communications setup, e.g. if the modem is not connected or the cables are not hooked up correctly, QuickBasic will hang.

    This problem is not associated with QuickBasic because you cannot check for the status of the communication port before attempting to OPEN it through the "Com1:" device name. This problem is a limitation in the design of the Macintosh hardware and System environment. It is the responsibility of those using Macintosh equipment to ensure that the communication setup is correct. Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB33041


Changing Text Font for Macintosh QuickBasic Listing Window (33042)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    The default text font for the Listing window in Microsoft QuickBasic for Macintosh is the default System application font, which is Geneva, size 12, and Face 0 (plain text).

    To change the text font used in the QuickBasic editing window, you can type the following statement in the Command window, where "n" is the family number of a currently installed System font [such as 0 = Chicago (the default System font), 4 = Monaco]:
       POKEW &H984,n
    To see the new font, you must refresh the Listing window (by pressing Command+L or by choosing List from the Windows menu). The specified font is active only for the current session and is not carried over when another program is sublaunched. The font also displays when you send the source listing to the printer by choosing Print from the File menu, letting you fit in more lines per printed page (depending upon the font).

    You can also change the font in QuickBasic's Listing window by modifying QuickBasic's font resource as described further below.

    This is not an official feature of QuickBasic. This information is provided as is, and no performance guarantees are implied for current or future versions.

    This information applies to Microsoft QuickBasic for Apple Macintosh versions 1.0, 1.0a, and 1.0b.

    More information

    You can access only font numbers that are currently installed in your Macintosh System file. If a font number is not installed, then Geneva, the default application font, is displayed. You can use Apple's Font/DA Mover program to add more fonts to your Macintosh System file. The Font/DA Mover program and additional fonts are distributed on Apple System disks (not shipped with QuickBasic).

    If you want columns to line up in your source listing, you can use Monaco (4) or Courier (22) font, but note that bold reserved words will still be wider than nonbold characters and will throw off alignment accordingly.

    As an alternative to the QuickBasic editor, if you want a different text font (and size) for editing the source code, you can use Apple's Edit program that is included on the QuickBasic distribution disk in the Tools folder.

    The default font for Apple's Edit program is Monaco, but once the program is loaded, the font and size can be changed by menu options. The Monaco font is useful if you want columns of characters in the source code to line up in the editing window.

    Most fonts other than Monaco or Courier are "proportional" fonts, which look more attractive but have different character widths. Columns of characters do not line up in proportional fonts.

    A disadvantage of editing in Apple's Edit program is that you cannot quickly run the program to locate syntax errors the way you can in the QuickBasic editor.

    Font numbers that are accessible from QuickBasic are listed on page 397 of "Microsoft QuickBasic for Apple Macintosh: Language Reference." (Correction for page 397: Courier should be 22, and Helvetica 21.)

    Note: You can call the following routines from a running program to change text characteristics sent to the program's output window:
       TextFont
   TextSize
   TextFace
   TextMode
    These routines do not affect the Listing window in QuickBasic's editor; they affect only the output window at run time.

    How to Change QuickBasic's Listing Font by Modifying Font Resource

    You can also change the text font used in the QuickBasic Listing window by modifying QuickBasic's font resource with ResEdit. By following the steps below, you can substitute any font for Geneva 12, the font used by QuickBasic. Warning: always keep backup copies of QuickBasic before modifying its resources.

    1. Launch ResEdit. ResEdit is supplied on the distribution disk titled Examples in the folder named Tools.
    2. Open the System file on your boot disk. You can do this by following these steps:

      1. Double-click System Folder.
      2. Double-click System.
    3. You will see a list of resource names. Double-click Font.
    4. You will see a list titled Fonts From System that contains all available fonts in each available point size. Select the font and point size you want to use in the QuickBasic Listing window.
    5. From the Edit menu, choose Copy.
    6. Close the top three window boxes so that ResEdit appears as it did when you first launched it. You should see one box with your hard disk name as the title.
    7. Open the QuickBasic application. You can do this by following these steps:

      1. Double-click on the folder in which QuickBasic is located.
      2. Double-click on Microsoft QuickBasic (b) or Microsoft QuickBasic (d).
    8. From the File menu, choose New. A dialog box asks you for a resource name. Type Font (in uppercase) and click OK.
    9. From the Edit menu, choose Paste.
    10. Select the font that appears in the box titled Fonts from Microsoft QuickBasic.
    11. From the File menu, choose Get Info.
    12. In the box to the right of the label ID:, change the number to 396, the ID number for Geneva 12.
    13. From the File menu, choose Quit.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB33042


Colors Sent to Apple LaserWriter Convert to Black and White (33043)

Summary

When a Macintosh QuickBasic program sends colors to an Apple LaserWriter printer (using OPEN "LPT1:" or "Lpt1:Prompt", and WindOW OUTPUT #n), the colors are translated to black and white as follows:

White = yellow, magenta, cyan, white

Black = red, green, blue, black

Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB33043


How to Send PostScript Commands to Apple LaserWriter Printer (33047)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    A PostScript Escape font and the DrawText library routine enable you to send PostScript commands to the Apple LaserWriter printer with the WindOW OUTPUT # statement.

    This information applies to Microsoft QuickBasic 1.00, the Microsoft Basic Compiler 1.00, and the Microsoft Basic Interpreter Version 3.00 for the Apple Macintosh.

    More information

    When Basic sends output to the LPT1: or Lpt1:Prompt device, the currently chosen printer driver processes the output. Unlike the ImageWriter driver, the LaserWriter driver converts Macintosh QuickDraw ROM calls to PostScript commands before printing. PostScript is the command language (written by Adobe, Inc.) that is used to control the output of the Apple LaserWriter printer.

    For more information about the PostScript language, there are several excellent books written by Adobe, Inc., published by Addison-Wesley Publishing Company, Inc.

    To use literal PostScript commands, you must have a font named "PostScript Escape" available. The "Font/DA Mover" program can be used to copy fonts from one file to another. The PostScript Escape font can be obtained from user groups or Apple, Inc. For more information about the PostScript Escape font, please refer to "MacTutor Magazine," June 1986.

    An alternate approach is to specify one of the current fonts as the PostScript Escape font. To do this, you must use ResEdit and change the "STR ID -8188" of the LaserWriter driver from "PostScript Escape" to the name of the font of your choice. Whenever this font is used for output, the LaserWriter driver passes this text directly to the printer as PostScript commands. Note that text in this font from other programs such as Microsoft Word or Apple MacWrite is also printed as literal PostScript commands.

    A separate article describes how to set up the PostScript Escape font in a compiled application (query on the keywords Postscript AND Escape).

    However, rather than defining a PostScript font, it is easier to embed PostScript commands as a picture comment when sending a picture to the LaserWriter, as shown in another separate article found by querying on the keyword PicComment.

    Code Example

    '    This program draws a box around the page using PostScript commands.
'    For the Basic interpreter 3.00 and Basic compiler 1.00, you must
'    add the following statement to access the DrawText routine:
'  Library "ToolLib"
'    This Library statement is not needed for QuickBasic programs.
'    The variable PS% must be initialized to the font number of the
'    PostScript Escape font:
   PS%=xxx  ' xxx must specify font number of PostScript Escape.
   OPEN "LPT1:" FOR OUTPUT AS #1
   WindOW OUTPUT #1         ' Redirects window output to printer.
   PRINT "PostScript will draw a box around this page."
   TextFont PS%             ' Set the PostScript Escape Font
   DrawText "initclip  clippath  stroke"    ' PostScript commands
   CLOSE#1
    Note: You cannot use PRINT; you Must use DrawText or DrawString to send the PostScript commands. PRINT always sends information one character at a time, but PostScript commands must be sent in whole strings. If you attempt to use PRINT, a PostScript error results, and no output appears.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB33047


Using REM $IGNORE ON/OFF Metacommand in Macintosh QuickBasic (33048)

Summary

The $IGNORE ON metacommand, in conjunction with $IGNORE OFF, instructs the Macintosh QuickBasic compiler to ignore the body of code between the two metacommands. This is useful when you have code that is specifically for the interpreter.

For example, the TRON statement is valid only in the interpreter and, if you compile a program that has a TRON statement, you will receive an "Unprintable ERROR" message from the compiler.

The following program will run in the interpreter in QuickBasic, and will also compile and run without error:
   REM $IGNORE ON
   TRON
   TROFF
   REM $IGNORE OFF
   PRINT "hello"
   END
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB33048


$OPTION Metacommand Is Similar to $Long and $OPTION (33049)

Summary

The $OPTION metacommand was introduced in Microsoft Basic Compiler Version 1.00 for the Apple Macintosh. For upward compatibility, $OPTION is also supported in QuickBasic 1.00 for the Apple Macintosh. The $OPTION metacommand instructs the compiler in the following ways:
   Metacommand Option       Description
   ------------------       -----------

   $OPTION A                Use long addressing mode

   $OPTION +A               Use long addressing mode

   $OPTION -A               Do not use long addressing mode

   $OPTION C                Check array boundaries, and overflow

   $OPTION +C               Check array boundaries, and overflow

   $OPTION -C               Do not check array boundaries, and overflow
The compiler in QuickBasic for the Apple Macintosh also provides the $Long metacommand to turn on and off long addressing and the $Check metacommand to turn on and off checking of array boundaries. Microsoft recommends using the new $Long and $Check metacommands, which are easier to remember than $OPTION.

One QuickBasic customer reported that he had selected "Use Long Addressing" in the Options dialog box but still received "Must use long addressing mode" error messages at compile time. The customer solved the problem by adding the metacommand REM $Long directly into the source code.

More information

QuickBasic allows you to set various options that affect compilation. Most options are set for the entire source file by checking the appropriate boxes in the dialog box for the Options command on the Run menu. However, the $OPTION, $Long, and $Check metacommands let you turn on or off the compiler option in specified parts of the source file.

The following two programs use equivalent metacommands to turn on checking of array boundaries and overflow conditions:

  1.    REM $OPTION C
   DIM ARR% (2, 2)
   ARR% (0, 0) = 1
   END

  2.    REM $Check ON
   DIM ARR% (2, 2)
   ARR% (0, 0) = 1
   END
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB33049


How to Make a Macintosh QuickBasic Program Run Faster (33050)

Summary

This article lists methods to make a QuickBasic or Basic program run faster. This information applies to Microsoft QuickBasic 1.00, Basic Compiler 1.00, and Basic Interpreter Version 3.00 for the Apple Macintosh.

More information

The following tips will increase the execution speed of programs:

  1. Use the DrawText routine instead of the PRINT statement. DrawText is faster than PRINT because it sends out a string of characters at a time instead of one character at a time. You will still need to use PRINT to start new lines. DrawText is faster to both a printer in graphics output and the screen.
  2. Using TextMode 0 (Copy) can increase screen text display speed by up to 20 percent compared to other text modes.
  3. The SELECT CASE statement is faster than executing a series of IF statements. (However, please note that Version 3.00 of the Basic Interpreter does not have a SELECT CASE statement.)
  4. In a compiled application, disable the Check Arrays & Overflow option after your program is debugged and tested.
  5. In a compiled application, disable Process Runtime Events if your program does not use features that depend on run-time events. Most applications can be rewritten to not use run-time events.
  6. In a compiled application, you may also enable the Ignore Breaks option. When this option is selected, Command+PERIOD is only detected at a major Input/Output operation such as a disk access or INPUT statement.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB33050


"Out of Memory" Using More than One CLEAR Statement (33051)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    Using multiple CLEAR statements can generate an "Out of Memory" error message in Macintosh QuickBasic programs. There should be only one CLEAR statement in a program and it should appear at the beginning of the program. Problems can arise if the program reallocates memory after large portions of the stack and heap are already being used by the program.

    This information applies to Microsoft QuickBasic 1.00, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh. Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB33051


"Can't Find File" OPENing New QuickBasic Random or APPEND File (33052)

Summary

The only way for an OPEN statement to automatically create a new file opened for random access (or APPEND access) in Macintosh QuickBasic is to compile the program with the "Disable File Not Found Dialog" option. This option also works correctly in the interpreter part of QuickBasic if you select the "Disable File Not Found Dialog" box in the Options... item (from QuickBasic's Run menu) before running the program.

Otherwise, to create a random file and avoid the "Can't Find: <file>" dialog when opening a new file with random access (or APPEND), you must first create an empty file with an OPEN FOR OUTPUT statement (i.e., sequential access), followed by CLOSE, after which you can open the file for random access (or for APPEND). This was not a requirement in earlier versions of the Basic compiler and interpreters for the Macintosh.

More information

If an OPEN statement for a random access file or sequential (INPUT or APPEND) access file in a Macintosh QuickBasic program cannot find a data file in the current folder, it will prompt you to look for the data file with the following statement:
"Can't find: <file>. Would you like to look for it?"

You can then click OK, change to the right folder, and open the needed file. If you don't find the random or sequential file through this dialog box, the program generates an error number 53 "File not Found" (or error number 74 "Unknown Volume" if you specified an OPEN path with a disk name that is not in the system).

In earlier versions of the Basic compiler and interpreters for the Macintosh, opening a new file for random access automatically creates the file. You can emulate this behavior in QuickBasic by selecting the "Disable File Not Found Dialog" option in the Options... from the Run menu.

You may disable the "Can't Find: <file>" processing by selecting the "Disable File Not Found Dialog" option in the Options... from the QuickBasic Run menu. If this option is selected, then a run-time error 53, "File Not Found", will directly occur on the OPEN when a file cannot be found in the current folder or with the specified full path.

Code Example 1

' OPEN FOR OUTPUT never gives you a "Can't Find: <file>" dialog
' prompt (regardless of QuickBasic's "Disable File Not Found Dialog"
' option):
NewFile$ = FILES$(0, "Name the new file:")
OPEN NewFile$ FOR OUTPUT AS #1
' Write to the file here if you wish.
CLOSE
END

Code Example 2

' This random access works in QuickBasic as is, regardless of
' the "Disable File Not Found Dialog" option:
NewFile$ = FILES$(0, "Name the new file")
OPEN NewFile$ FOR OUTPUT AS #1
CLOSE #1   ' First create and close file before opening with random
OPEN NewFile$ AS #1    ' or APPEND access.
' Write to the file here if you wish.
CLOSE
END

Code Example 3

' You must select the "Disable File Not Found Dialog" option
' before running this program in QuickBasic (interpreter or
' compiler). Works as is in earlier Basics for Macintosh.
NewFile$ = FILES$(0, "Name the new file")
OPEN NewFile$ AS #1    ' Opens new file for random access.
' Write to the file here if you wish.
CLOSE
END
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB33052


PRINT or BEEP "Error 11" in QuickBasic Compiled apl Program (33053)

Summary

A program compiled in Microsoft QuickBasic for Macintosh gives "Error 11" (which means "Division by Zero") at run time when it PRINTs to the screen if no window is defined and "Use Default Window" was not selected in the "Options..." dialog box at compile time. The BEEP statement also gives "Error 11" when not using the "Use Default window" option (because QuickBasic internally translates the BEEP statement into a series of PRINT statements).

If the "Use Default Window" is not selected when compiling, you are responsible for creating a window before using the BEEP or PRINT statement or other screen output.

More information

Note that the "Use Default Window" option is always "on" in the interpreter environment in QuickBasic, so Error 11 will not occur for BEEP or PRINT when run in the interpreter. This difference in behavior between interpreted and compiled programs may confuse some programmers who are not familiar with the cause of "Error 11" in the context of not using a default output window.

The "Use Default Window" option was provided only for compiled (" apl") programs so that they could smoothly initiate a windowless screen (without a default window flashing then disappearing with the first WindOW or WindOW CLOSE statement).

If you want to use the BEEP statement and also want to not compile with the "Use Default Window" option, create a window out of sight behind the menu bar, such as the following:
   WindOW 1,"Invisible",(1,1)-(15,15)
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB33053


Macintosh System Error, Hang/No Output; "Use Default Window" (33054)

Summary

If a program is compiled in Macintosh QuickBasic without the "Use Default Window" option selected from the Options... item on the Run menu, and the program does not create its own window, no output goes to the screen when the program is run.

Warning: The BEEP or INPUT statement, many ROM calls, and all types of graphics statements may result in one of the following symptoms if invoked before you have created a window in a compiled QuickBasic program:

  1. System hang (which requires you to reboot the Macintosh)
  2. System Error (bomb), such as ID=25, "Out of Heap Space" (which usually requires you to reboot the Macintosh)
  3. Other unpredictable results
If you need to use one of these statements, you must either compile with the "Use Default Window" option selected or make the program create its own window using the WindOW statement before sending output.

The ability to turn off the default window is provided in Macintosh QuickBasic to suppress the brief flashing appearance of the Untitled output window at the beginning of compiled programs that define their own windows with the WindOW statement. This feature helps software developers improve the polished appearance of programs.

More information

The following steps demonstrate this subject:

  1. Type the following program into QuickBasic 1.00:

    INPUT X

  2. Save the program.
  3. Turn off "Use Default Window" in the Options... in the Run menu.
  4. Select Compile from the Run menu (or press Command+K) to compile the program.
  5. When you run the compiled program you may get System Error (bomb) ID=25 (Out of Heap space).
To avoid this problem, compile with the "Use Default Window" option or define your own window in the program with the WindOW statement. For example, the following program works correctly whether or not you compile with the "Use Default Window" option:
   WindOW 1,"This goes in title bar",(50,110)-(430,240),1
   INPUT X
The problem does not occur in the QuickBasic interpreter because the interpreter uses its own output window, if one is not specified in the program.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB33054


QuickBasic's ToolBox Statement Can't Call Routines Not in ROM (33055)

Summary

Any ROM routine listed in "Inside Macintosh" (by Apple Computer and published by Addison-Wesley) that is marked "Not in ROM" cannot be called from Microsoft QuickBasic with the ToolBox statement. Some other high-level languages supply routine-specific "glue" code to make these calls, which the ToolBox statement in QuickBasic cannot provide.

You could use one of these other languages to create an MBPC (pure code) resource to provide the required interface to the routine you need. MBPC support files are provided in QuickBasic for LightSpeed C, MPW Assembler, C, and Pascal.

This article applies to Microsoft QuickBasic 1.00 for the Apple Macintosh. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB33055


ToolBox Calls to System Event Functions Fail in QuickBasic (33056)

Summary

Accessing the Macintosh system event queue with QuickBasic's ToolBox statement to make calls to GetNextEvent, WaitNextEvent, and EventAvail does not work. Basic traps all events from the system queue and handles them before your ToolBox call. An occasional event may slip through, but is not usable. This is a side effect of the way the event-handling feature of Basic is implemented. QuickBasic substitutes its own statements to handle most events that a program would need to trap.

More information

Because of this behavior of QuickBasic, you cannot use the ToolBox statement (which is an MBLC routine built into QuickBasic) to handle events associated with a "control" such as a scroll bar. ("Controls" are graphic objects that, when manipulated with the mouse, cause instant actions with visible results. This definition is taken from "Inside Macintosh," by Apple Computer, published by Addison-Wesley. Check boxes, buttons, and scroll bars are examples of "controls" on the Macintosh.) You may use the ToolBox statement to Create a scroll bar, but you will be unable to get the events for it, since Basic will intercept most events.

QuickBasic provides its own MBLC library routines (such as NewScroll and ScrollText) to emulate Macintosh scroll bars. QuickBasic's scroll bar routines are a simulation of the true Macintosh scroll bars. For more information about the scroll bar library routines, please refer to Pages 472 to 492 of the "QuickBasic for Macintosh: Basic Language Reference."
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB33056


Losing Characters with Com1: Communications in Macintosh Basic (33087)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    Macintosh Basic cannot detect input buffer overrun when receiving input from the Com1: communications device. As a consequence, at 1200 baud and faster, it is possible to lose input characters. The following are some methods to alleviate the problem of losing characters at 1200 baud or faster:

    1. Use a baud rate of 300.
    2. Increase the buffer size using the LEN=file-buffer-size argument in the OPEN Com1: statement.
    3. Do not perform much screen input and output while receiving input from the Com1: communications device.
    4. Make your program code as fast as possible in-between inputs from the Com1: communications device. The following should be done to increase the speed of the code:

      1. Use the DrawText library routine instead of the PRINT statement. DrawText is faster than PRINT because it sends out one string of characters at a time instead of one character at a time. (DrawText is not supported with Microsoft Basic Interpreter Versions 2.00 and 2.10.)
      2. Use textmode 0 (Copy mode). It can increase text display speed by up to 20 percent compared to other textmodes.
      3. Use the SELECT CASE statement instead of doing a series of IF THEN ELSE statements to increase the speed of the code. (SELECT CASE is not supported in the Microsoft Basic Interpreter Versions 1.x, 2.00, 2.10, or 3.00, but is supported in the QuickBasic 1.00 interpreter and compiler, and in Basic compiler Version 1.00 for Macintosh.)
    An example communications program called Terminal is provided on the release disk for Basic interpreter, compiler, and QuickBasic for the Macintosh. Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB33087 kbAudDeveloper


Offset for Jump To... Option Appears Incorrect after $INCLUDE (33142)

Summary

In the QuickBasic Interpreter, the Jump To... option goes to a physical line offset from the beginning of the file, excluding the extra lines in the compiler's $INCLUDE files (if any).

However, when an error occurs in a compiled program, the number of the line in error counts the lines in $INCLUDE files. This applies to error line numbers shown in the Program Listing File, or in the run-time error message "***** Error <n> at <line>" (which requires the "Process Runtime Events" compiler option to get a line number).

Thus, if the main source file contains REM $INCLUDE or '$INCLUDE statements, the Jump To... option in the interpreter will not show you the proper line in the main program where the error occurred. This is because the compiler counts the lines in the $INCLUDE files when figuring the offset, while the interpreter environment does not.

To calculate the correct offset, subtract the number of lines in the $INCLUDE files from the given error offset. Then select Jump To... from the Search menu and use the smaller offset.

More information

When a compile-time error occurs in a compiled program's $INCLUDE file itself, the interpreter improperly puts a box around a line in the main program. The number of lines that this box lies below the REM $INCLUDE statement is the number of the line in error in the $INCLUDE file.

Below is an example where the interpreter draws a box around the wrong line (in the main source file) if any error occurs in a compiled programs's $INCLUDE file. When you compile the following, the interpreter marks line 3 in the main program with a box and gives a "Syntax Error" message:
REM This is the Main program.
REM $INCLUDE "Junk"
PRINT "LINE 3"   ' The interpreter flags this line with "Syntax Error"
PRINT "LINE 4"

REM This is a separate $INCLUDE file called Junk, saved in Text format.
INPUT PRINT  ' This line is a deliberate Syntax Error.
Note: REM $INCLUDE statements are ignored when the program is run in the interpreter.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB33142


"Hardware Environment Conflict" If No 68881 or 68020 (33299)

Summary

A "Hardware environment conflict" error message displays at run time if an application is compiled with the "Generate 68020 Code" and/or "Generate 68881 Code" compile options and then run on a Macintosh other than a Macintosh II.

The "Generate 68020 Code" option produces instruction codes that are specific to the 68020 processor. The 68020 chip is the next- generation microprocessor in the 68000 family.

The 68881 chip is a math coprocessor. For programs that perform floating-point arithmetic, the "Generate 68881 Code" option will enhance the speed of execution. If the program primarily uses integer arithmetic, this option will not improve program performance. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB33299


"Illegal Function Call" When GetIcon of Wrong Icon ID (33300)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    An "Illegal function call" error is generated on a GetIcon statement if the specified icon ID does not match the actual icon ID that exists in the resource file.

    You can perform the following steps to view and/or change the ID number of an icon (where the icon is stored in the resource fork of a file):
    1. Run Resedit.
    2. Select the file that contains the icon.
    3. Display the icon.
    4. Select "Get Info" from the File menu (in Resedit).
    5. Change the value in the ID field.
    6. Close windows in Resedit and save the changes before exiting.
    This information applies to Microsoft QuickBasic 1.00, Basic Compiler 1.00, and Basic Interpreter Version 3.00 for the Apple Macintosh.

    More information

    The purpose of the GetIcon routine is to return a handle to a specified icon that is located in a resource file on disk. Once you have established a handle for the icon, you can use other routines to manipulate the icon as an object in the Macintosh heap.

    In QuickBasic, GetIcon is an MBLC routine built into QuickBasic itself.

    In the earlier Basic Compiler 1.00 and Basic Interpreter Version 3.00, GetIcon is a Code routine provided in the "ToolLib" Library file on the Basic Toolbox disk.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB33300


Using Predefined Standard Patterns with ROM Routines (33302)

Summary

For the built-in Macintosh ROM routines that use patterns (such as FillOval), you can use the standard patterns that are in Macintosh memory instead of defining and initializing an array.

More information

The standard Macintosh patterns are at fixed offsets from the address in register A5. This address is available in the Macintosh global variable "currentA5" at &H904. The area at negative offsets from A5 are the QuickDraw globals. Various useful information is kept in this area, including the following standard patterns:
   pattern       offset from A5
   -------------------------------
   0% white      -12
   25% light     -36
   50% medium    -28
   75% dark      -44
   100% black    -20
The following is a code example:

This program demonstrates using a pattern from Macintosh memory:
   FOR i%=0 TO 4
       Backpat PEEKL(&H904) -44 + 8*i%
       CLS             'fill screen with the pattern
       PRINT -44+8*i%  'show offset that was used for the pattern
       WHILE Mouse(0)<>1:WEND
   NEXT
The following is another example that draws a gray scale, and shows how to cache pointers safely:
   DIM r%(3)
   setrect r%(0),9,9,210,201
   FrameRect VARPTR(r%(0))  'draw frame
   setrect r%(0),10,10,50,200
   A5&=PEEKL(&H904)    'get value of currentA5.  This is a stable address

   '    The following is a dummy offsetrect so we can cache the rectangle
   '    address without worrying about the array moving in memory:
   offsetrect r%(0),0,0

   r&=VARPTR(r%(0))    'grab rectangle address
   FillRect r&,A5&-12  :offsetrect r%(0),40,0
   FillRect r&,A5&-36  :offsetrect r%(0),40,0
   FillRect r&,A5&-28  :offsetrect r%(0),40,0
   FillRect r&,A5&-44  :offsetrect r%(0),40,0
   FillRect r&,A5&-20  :offsetrect r%(0),40,0

   WHILE Mouse(0)<>1:WEND
Each of the FillRects above could be written in the following way and would eliminate the need to worry about variables moving in memory and invalidating the pointers. This is the preferred style for beginners:
   FillRect VARPTR(r%(0)),PEEKL(&H904)-44
Saving the pointers is more efficient than calculating addresses each time. The value of currentA5 may be cached safely in all Basic programs.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB33302


Toolbox Library Routine String Arguments Have 255-Byte Limit (33304)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    The Toolbox Library routines that utilize string variables are limited to strings of 255 characters or less. The Toolbox Library routines make ROM calls that use Pascal strings limited to 255 characters in length.

    For example, the MBLC Toolbox routine GetDialogText will only take the first 255 characters from an edit field, even if there are more than 255 characters of input. It does not give an error message; it just ignores anything past the 255th character.

    This information applies to Microsoft QuickBasic 1.00, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Version 3.00 for the Apple Macintosh.

    More information

    The following is an example that runs in the Basic interpreter Version 3.00 or in the Basic compiler Version 1.00 for the Macintosh (it will need to be modified for QuickBasic):
    'The following program uses a dialog box located in the resource fork
'of the DialogRes program on the "Basic Toolbox" disk (in Basic 3.00).
'The buttons on the left side of the dialog box can be ignored --
'The program will accept input into the edit field until the OK or
'the Cancel button is pressed.
Library "Basic Toolbox:ToolLib"
ref% = 0: D! = 0: item% = 0: t$ = ""
OpenResFile "Basic Toolbox:DialogRes", ref%
GetNewDialog ref%, 1, D!
WHILE item% <> 7 AND item% <> 1   'While OK or Cancel aren't pressed.
   ModalDialog D!, item%
   GetDialogText D!, 6, t$
   LOCATE 1, 1
   DrawText STR$(LEN(t$))     'Print length of string from GetDialogText.
WEND
DisposeDialog D!
'Any characters beyond the 255th have been ignored.
Print "The last 20 characters of the edit field are:"
PRINT RIGHT$(t$, 20)
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB33304


FIELD Variables Unavailable After Random File Is CLOSED (33305)

Summary

Programmers using the Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for Macintosh who are converting to Microsoft QuickBasic for Macintosh (which contains both an interpreter and compiler) must be aware of the following change in accessing variables declared in FIELD statements for use with random-access files:

Whenever a CLOSE, CLEAR, SYSTEM, STOP, END, RESET, or RUN is executed, the variables in a FIELD statement for a random access file are set to null, and are no longer available in the QuickBasic program. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB33305


PRINT Scrolls Truncated Text If Window Bottom Covered (33623)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    This information applies to Microsoft QuickBasic 1.00, Basic Compiler 1.00, and Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

    The PRINT and PRINT USING statements automatically scroll the contents of the output window upwards to make room for text that is printed at the very bottom of the output window. If the bottom of the output window is moved slightly off screen or covered partially by any window (such as the LIST window), the text scrolled upwards can be truncated or blank because Basic only scrolls the pixels that were initially visible when they were printed.

    The following program is an example (move the output window downward one-half of a line or more so that the bottom is obscured by the Macintosh screen border):
       FOR J=1 TO 400
   PRINT "XxxxXxxxXxxxXxxxXxxxXxxxXxxxXX"
   NEXT
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB33623


Edit FIELDs, Buttons Stop PRINT Scrolling in Mac QuickBasic (33624)

Summary

Edit FIELDs and Buttons prevent the PRINT, PRINT USING, LINE INPUT, or INPUT statements from scrolling the output window. Normally, PRINT and PRINT USING scroll the pixels on the window when they print at the bottom of the window. Similarly, INPUT or LINE INPUT statements executing at the bottom of the window scroll the image on the window up one line when you press RETURN.

Basic prevents the scrolling so that the Edit FIELDs and Buttons stay on the screen for user input. If Edit FIELDs or Buttons were scrolled away, you could not respond to them.

This information applies to Microsoft QuickBasic Compiler 1.00, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for Apple Macintosh.

More information

Note: You can set up an area of scrollable static text with the NewScroll and ScrollText statements (which are MBLC routines built into QuickBasic). (The ToolBoxSampler program on the release disk demonstrates them.) This type of specialized scrolling area can coexist next to Edit FIELDs or Buttons on a window and still scroll. A Toolbox-created scrolling area is useful only for displaying a given array of strings that can be selected with the mouse.

Listed below is an example of how to make a window, create an Edit FIELD, create a Button, and capture the input in the Edit FIELD. This example polls the value returned by DialoG(0) in a loop, waiting for you to press the Button or hit the RETURN key. You can input and edit text in the Edit FIELD while the program loops and waits for you to press the Button or press the RETURN key.

The following is a code example:
WindOW 2,"GET NAME",(70,70)-(430,320),1
PRINT "Enter Your NAME IN THE BOX"
PRINT "When Finished, Click OK."
Edit FIELD 1,"{{Enter Text HERE}}",(50,50)-(200,200),1,1
Button 1,1 "Done",(85,205)-(170,225)
Idle=1      ' 1 or non-zero is TRUE; zero is FALSE.
WHILE Idle  ' This loop polls DialoG(0) waiting for an event.
   ACT=DialoG(0)  ' Invoke DialoG(0) only once per loop iteration.
   IF (ACT=1 OR ACT=6) THEN  ' 1=Button clicked; 6=RETURN key pressed
   Title$=Edit$(1)
   Idle=0
   ELSE
   Idle=1
   END IF
WEND
WindOW CLOSE 2
PRINT "Hello! YOU Must BE";Title$;"."
PRINT:
PRINT "Click TO END"
WHILE Mouse(0)<>1 : WEND
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB33624


Handling ImageWriter LQ/LaserWriter Printing Problems in Basic (33630)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Heap-space memory limits may be exceeded when printing to the Apple ImageWriter LQ or the Apple LaserWriter printer from a Macintosh QuickBasic (or earlier Basic) interpreted or compiled program. Exceeding heap space can result in System Error 25, "Out of Heap Space," "Device I/O," or other memory-related errors.

    Below are techniques to work around this memory management limitation.

    More information

    The simplest way to increase the heap before printing to an Apple LaserWriter is to use the FRE(-1) function. FRE(-1) forces Basic to make the Macintosh's memory manager compact (and unfragment) heap-space memory. Invoke the FRE(-1) function before the OPEN of the printer device ("LPT1:" or "Lpt1:Prompt") as in the following example:
       PRINT FRE(-1)
    Also, the standard way to allocate more heap space for the printer is to execute a CLEAR,xxx statement once at the top of your program (where xxx is a data size as small as possible without getting an "Out of Memory" error).

    In some larger programs, the best way to avoid printing problems is to CHAIN or RUN to a small program that does all printing and then CHAIN or RUN back to the first program.

    For large memory-intensive programs, Microsoft recommends one of the following memory-management schemes for printing to the LaserWriter:

    1. The following technique CHAINs, then prints:

      1. Copy the variables to be printed to a disk file or resource (or put them in a COMMON block)
      2. CHAIN to a special program that prints the stored variables. If no data is passed in COMMON, the CHAINed-to program can execute a CLEAR,xxx statement (where xxx is a data size as small as possible without getting an "Out of Memory" error) to increase heap space before opening the printer. (CLEAR erases anything in COMMON.)
      3. OPEN "LPT1:" or "Lpt1:Prompt" FOR OUTPUT AS #n and send output with PRINT#n, WRITE#n, or WindOW OUTPUT#n. CLOSE sends the output to the printer.
      4. CHAIN back to the first program.
    2. The following technique stores variables, CLEARs, then prints:

      1. Copy the variables that you want preserved to a disk file or into a resource [since the CLEAR,xxx in step (b) erases all variables].
      2. Use CLEAR,xxx to shrink Basic's data space and increase heap.
      3. Open the "LPT1:" or "Lpt1:Prompt" device and send the data to the printer. Then CLOSE the printer device.
      4. Use another CLEAR,yyy to reallocate data space.
      5. Restore the data your program needs and continue.
    Programmers can also use the ToolBox interface to purge and compact memory before the OPEN. Programs that make heavy use of Macintosh features should try a couple of MoreMasters toolbox calls at the beginning of the program. (The start-up code in "apl" programs compiled in Macintosh QuickBasic currently does two MoreMasters traps.)
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB33630


255 Dimensions Per Array in Interpreter, 7 in Compiler (33735)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    The following information applies to Microsoft QuickBasic 1.00, Basic Compiler 1.00, and Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

    The maximum number of dimensions an array can have in the interpreter is 255, which may be more than you could ever use because memory is quickly used up by arrays with a large number of dimensions.

    The maximum number of array dimensions a compiled program can have is seven.

    The maximum number of array elements per dimension allowed in both the interpreter and compiler is 32,767.

    More information

    Please remember that base elements of arrays start with element number zero (OPTION BASE 0) by default. In other words, DIM X(20) dimensions X with 21 elements, X(0) through X(20). If you do not ever use element zero in any dimension, you should invoke OPTION BASE 1 at the top of your program to save memory. This process is especially important if you make an array with a large number of dimensions.

    The following array has seven dimensions with two elements per dimension, giving it a total of 128 (2 to the power of 7) elements:
       OPTION BASE 1
   DIM X(2,2,2,2,2,2,2)
    If you took out the OPTION BASE 1 statement, the default base element of the array would be "0", and the array would have three elements per dimension, giving a total of 2187 (3 to the power of 7) elements. Notice how the OPTION BASE greatly affects allocated memory if you have a multi-dimensional array.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB33735


Macromaker Menu Item May Appear in Middle of Menus (33737)

Summary

When Macromaker is installed as an Init resource in the System Folder, its menu icon may appear in the middle of the menus of a Macintosh QuickBasic application. Macromaker is an application that is included with Apple's System Version 6.0. The Macromaker icon usually occurs to the right of the menu items in most desktop applications.

Please note that if the menus are defined by the application from right to left, the Macromaker menu will appear next to the Apple menu. It will be to the left of the QuickBasic application's menus instead of to the right as it normally appears with desktop applications.

The following program will have the Macromaker menu in the middle of its own menus:
   FOR i = 1 TO 5
      Menu i,0,1,STR$(i)
   NEXT i
   WHILE Mouse(0)<>1: WEND
To get the Macromaker menu next to the Apple menu, use the following code:
   FOR i = 5 TO 1 STEP -1
      Menu i,0,1,STR$(i)
   NEXT i
   WHILE Mouse(0)<>1: WEND
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB33737


Copying Macintosh Basic Screen to Hercules Screen on IBM PC (33813)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    The following information provides an example of copying the screen memory from an Macintosh Plus computer (through a serial communications line) to an IBM PC with a Hercules Graphics Adapter installed.

    On the Macintosh side, this information applies to Microsoft QuickBasic 1.00, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

    On the IBM PC side, this information applies to Microsoft QuickBasic Compiler 4.00, 4.0B, and 4.50 for Ms-Dos, Microsoft Basic Compiler 6.00 and 6.0B for Ms-Dos, and Microsoft Basic PDS 7.00 for Ms-Dos.

    More information

    The following information is valid only for a Macintosh Plus, and may not work on other Apple Macintosh computers. The addresses supplied are based upon customer experimentation and Microsoft does not provide support for the following code. You may modify the program as you wish.

    Although both a Macintosh and a Hercules-compatible video display card use the same approach to storing an image (one pixel per bit starting with the upper-left corner of screen), there is a fundamental difference in layout of this memory.

    Macintosh screen memory is contiguous, whereas Hercules memory consists of four interlaced blocks of memory. The Macintosh uses 64 decimal bytes per line; a Hercules-compatible monochrome adapter uses 90 decimal bytes (5A Hex) per line.

    The following are the starting addresses for the first eight screen lines on the Macintosh Plus and on the Hercules Graphics Adapter:
       Line        Mac Plus     Hercules
   ----        --------     --------

   0           FA700        B000:0000
   1           FA740        B000:2000
   2           FA780        B000:4000
   3           FA7C0        B000:6000
   4           FA800        B000:005A
   5           FA840        B000:205A
   6           FA880        B000:405A
   7           FA8C0        B000:605A
    The following programs copy screen memory from an Apple Macintosh to a Hercules-equipped IBM PC through a null-modem serial port connection:
       'This program runs on the Macintosh in compiled or interpreted Basic:
   CLS
   OPEN "Com1:9600,n,8" FOR OUTPUT AS #1
   FOR row=0 to 341
     PRINT #1, row
     FOR col=0 to 63
        PRINT #1, PEEK(64*row+col+1025792)
     NEXT col
   NEXT row

   'This program, run in Microsoft QuickBasic on the IBM PC,
   'is started first:
   DEFINT A-Z
   OPEN "com1:9600,n,8,,cs0,ds0,cd0,bin,rb4048" FOR INPUT AS #1
   ON COM(1) GOSUB ReadALine
   COM(1) ON
   Screen 3
   CLS
   DEF SEG = &HB000
   WHILE INKEY$ = "": WEND
   END
   ReadALine:
        INPUT #1, MacRow
        PCRow = &H2000 * (MacRow MOD 4) + &H5A * (MacRow \ 4)
        FOR Column = 0 TO 63
                 INPUT #1, RowPixelCode
                 POKE PCRow + Column, RowPixelCode
        NEXT Column
        RETURN
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB33813


"Device Unavailable","Device I/O" Network ImageWriter Printing (34012)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    A "Device Unavailable" or "Device I/O" error will be generated when attempting to print with Lcopy, LLIST, LPRINT, or "Lpt1:Direct" (character mode output) to an Apple ImageWriter I, II, or LQ over the AppleTalk network. Lcopy, LLIST, LPRINT, or "Lpt1:Direct" requires a directly connected ImageWriter I or ImageWriter II. These statements are not supported on the ImageWriter LQ (which is a graphics-mode printer) or on a LaserWriter.

    To output to an ImageWriter I, II, or LQ over the AppleTalk network, you must OPEN the "LPT1:" or "Lpt1:Prompt" device name as device #n and send output with the PRINT#n, WRITE#n, or WindOW OUTPUT#n statement. You must also have the "AppleTalk ImageWriter" file (or "ImageWriter LQ" driver for the LQ) installed in the System folder and selected in the Chooser to print over the AppleTalk network to an ImageWriter. Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB34012


Problems Using ImageWriter Graphics Mode; "LPT1: BIN" (34013)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0

    • Summary

    When LPRINT or OPEN "Lpt1:Direct" is used to send control characters to the Apple ImageWriter to put the printer into graphics mode, the output may not appear as expected, due to the translation of certain characters. For example, TAB (ASCII 9) characters are translated to eight spaces during output. To get straight binary output without any translation, use "Lpt1:Bin" instead of "Lpt1:Direct". This will print all bytes without translation.

    The "Lpt1:Bin" device name may only be used with an Apple ImageWriter that is not on the AppleTalk Network. "Lpt1:Bin" will not work with the Apple LaserWriter.

    The above information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh and Microsoft Basic Interpreter Versions 2.10 and 3.00 for the Apple Macintosh.

    The following products DO NOT support the "Lpt1:Bin" device: Microsoft Basic Compiler 1.00 and Microsoft Basic Interpreter Version 2.00 for Apple Macintosh. Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB34013


"Cones" Demo Deliberately Has "Invalid Function Call" (34016)

Summary

The "Cones" demo program that is distributed with QuickBasic Version 1.00 gives the following error on the WindOW(20) statement at run time:
Invalid Function Call
Microsoft intentionally placed this error into the "Cones" demo program for use by the "Microsoft QuickBasic 1.00 for Apple Macintosh: User's Guide" as an exercise in debugging. The manual shows you how to find and correct programming problems in source code, using "Cones" as the example.

To correct the deliberate syntax error, change the WindOW(20) statement to WindOW(2). Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB34016


BUG: System Error/Hang w/ $Check ON Metacommand & SUB Program (34276)

Symptoms

If you use the in-line metacommand $Check ON (or $OPTION +C) and are calling a SUBprogram in a Basic source file, the compiled program can hang or give a system error (such as ID=2 or 3) at run time. If you pass no parameters to the subprogram, the compiled program may work on a Macintosh II but will fail on a Macintosh SE.

Microsoft has confirmed this to be a bug in the Microsoft QuickBasic Compiler 1.00 for the Macintosh . (This problem also occurs with $OPTION +C in the Microsoft Basic Compiler Version 1.00). We are researching this problem and will post new information as it becomes available.

The following are two workaround solutions:

  1. Compile with the Process Runtime Events option. $Check ON then works.
  2. Remove the $Check ON in-line metacommand, and use the equivalent Check Arrays & Overflow compiler option instead.
  3. This problem does not occur in the interpreter in QuickBasic or in Versions 3.00 and earlier of the Microsoft Basic interpreter.

More information

Note that the Microsoft Basic Compiler 1.00 uses $OPTION +C instead of $Check ON. QuickBasic 1.00 supports both $Check ON and $OPTION +C, which perform the same function, but $Check ON is a better mnemonic.

The following compiled programs hang at run time when compiled without the Process Runtime Events option:

Program 1:
   '$Check ON
   x=3
   CALL test(x)
   SUB test(x) STATIC
   PRINT x
   END SUB
Program 2:
   '$OPTION +C
   x=3
   CALL test(x)
   SUB test(x) STATIC
   PRINT x
   END SUB
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB34276


BUG: Pressing BackSPACE on Breakpoint Line Del Wrong Character (34281)

Symptoms

The following problem occurs when using breakpoints in the Listing window in QuickBasic 1.00 for the Macintosh . When there is a breakpoint on a line and the BackSPACE key (or DELETE on newer keyboards) is pressed, the breakpoint is deleted and the second character to the left of the insertion point is improperly deleted. (Normally, pressing BackSPACE removes the first character to the left of the insertion point.)

Breakpoints are useful debugging tools. However, to press BackSPACE (or DELETE) on a line with a breakpoint on it, you need to either turn the breakpoint off or move the insertion point an extra place to the right.

Microsoft has confirmed this to be a bug in Version 1.00. We are researching this problem and will post new information as it becomes available.

More information

A breakpoint can be set on a line by positioning the insertion point on a line and pressing Command+B, or by clicking the STOP symbol in the lower-left corner of the Listing window and then clicking the desired line.

A breakpoint can be removed in any of the following ways:

  1. If part of the breakpoint line is highlighted (i.e., selected in inverse video), pressing the BackSPACE (or DELETE) key correctly removes the breakpoint.
  2. Pressing Command+B on a line that contains the insertion point toggles the breakpoint off (or on).
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB34281


BUG: Highlighted Text Disappears When List Window Redisplayed (34282)

Symptoms

Selected text (which is highlighted in inverse video) in an active List window disappears when you press Command+L or choose the List option from the Windows menu. The text can be easily redisplayed by single clicking anywhere on the List window and then pressing Command+L or by choosing the List option from the Windows menu.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic Version 1.00 for the Macintosh and in the Microsoft Basic Interpreter Version 3.00 for the Macintosh (buglist3.00). We are researching this problem and will post new information as it becomes available.

Text can be highlighted (selected) by clicking the mouse at a desired starting point and holding down the button while dragging over the desired text. The mouse button is released when the desired text is highlighted.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB34282


Readme File for QuickBasic Compiler 1.00 for Apple Macintosh (34286)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The following article contains the complete contents of the Readme file distributed with Microsoft QuickBasic 1.00 for the Apple Macintosh.

    More information

       Readme File

              Release Notes for Microsoft QuickBasic for
                     Apple Macintosh Systems
                          Version 1.0

                Copyright Microsoft Corporation, 1988

This document contains information about version 1.0 of Microsoft
QuickBasic for the Macintosh and its associated libraries.

The information in this document is more up to date than that in the
manuals.

Microsoft updates its languages documentation at the time of
reprinting, so some of the information in this on-line file may
already be included in your manuals.

You may want to print this file to supplement your manual.

Requesting Assistance from Microsoft

If you need to contact Microsoft Technical Support for assistance, the
phone number is (425) 646-5101. [phone changed from original Readme]

Contents

This file has four parts.

Part        Note

1          Notes for the Microsoft QuickBasic Language Reference
2          Notes for the Microsoft QuickBasic User's Guide
3          Printing Graphics
4          Warnings and Notes

Part 1: Notes for the Microsoft QuickBasic Language Reference

Page   Note

184    LIST Command (Undocumented Command Feature)

       You can move to a specific numbered or labeled line by typing
       "LIST <line>" in the command window. The compiler does not
       allow this command in a program.

323    System Function (New SYSTEM(7) Function)

       SYSTEM(7) returns the file reference number of the resource
       fork of the program source file when the program is
       interpreted. It returns the file reference number of the
       application resource fork in a compiled application. SYSTEM(7)
       can be combined with the GetPathName subprogram to find your
       program's full path name. See the "GetPathNames" demo program
       on the Examples disk.

418    Using the Statement Mover Program

       Compile Statement Mover for speed. Unlike previous versions of
       Statement Mover, this one does not automatically move LIBinits.
       If your library requires LIBinits, you must copy it.

419    The Library Statement - Custom LIBinit and LIBterm

       These routines are called only with Library and Library CLOSE.
       If your custom libraries need LIBinit and LIBterm, you must
       explicitly call them, or use Library and Library CLOSE.

421    The Library Statement - Calling Library Routines

       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!"

483    Reference Guide for Toolbox Library Statements

       These new library routines were added after the manual was
       printed.

       Routine and Description

475    BackColor color
       color: see the description under the ToolBox ForeColor call for
       the values of "color." This routine is faster than the ToolBox
       version and the "color" argument more flexible.

475    BlockMove sourceAddr&,destAddr&,bytes&
       sourceAddr&: address to begin copying from
       destAddr&: address to begin copying to
       bytes&: number of bytes to copy
       BlockMove works even when the areas overlap.

477    CopyFile sourceFile$,destName$
       Copies the file with name sourceFile$ to destName$. Copies both
       the data and resource forks of the file.

479    Eject
       Ejects the disk in the internal drive. This is an MBPC resource.

480    Exists fileName$,flag%
       fileName$: full path of file, or simple name in current folder
       flag%: 0 = file does not exist, 1 = file exists

480    ForeColor color
       See BackColor

481    GetCatInfo IOPB%(0),FileName$[,DirID&][,VolRefNum%] [,DirIndex%]
       GetFCBInfo IOPB%(0),FileName$[,ioRef%][,VolRefNum%] [,FCBIndex%]
       DIM IOPB%(128)
       See the "GetPathName" demo on the Examples Disk or Inside
       Macintosh Vol. 4 for more details of these calls.

481    GetChanRefNum% Chan%,RefNum%
       Returns the file reference number of the file with QB channel
       number Chan%. Chan% is the file number you opened the file
       under (OPEN f$ AS #1).

482    GetHandleSize h&,size&
       Returns the size of a resource in bytes when given the
       resource's handle.

519    ScrollText H&,rec%(0),a$(0),top%,rows%[,num%[,delay%[,leading%]]]
       Scrolltext now has an additional optional parameter that
       specifies the leading (space between lines) in pixels. The
       default is 4 pixels.

523    SubLaunch appName$ [,fileName$] [,finderMsg%] [,fileType$]
       appName$: full path name of application to sublaunch
       fileName$: full path name of file to Open or Print.
       finderMsg%: 0 = Open, 1 = Print, 256 = Compile (QB only)
       fileType$: type of file fileName$.

527    Controlling Memory (Loading Files)

       Since QB initially allocates one third of the memory listed in
       the Size resource to the data area (about 100K), and QB reads
       your program into the data area, programs larger than 100K
       produce the "Out of memory" error. You can change the Size
       resource either with ResEdit or with "Get Info" for QB under
       MultiFinder, Finder 6.1 or later.

527    How Much Memory Do I Need?

       Most programs will never need to change memory allocations, but
       programs with huge data requirements may use the CLEAR
       statement to access more memory:

       '    Leave some heap for Desk Accessories and printer drivers.
       '    100K is a good starting point.
       heap&=100*1024&
       max&=FRE(0)+FRE(1)-heap&
       CLEAR ,max&

       You will seldom need CLEAR's stack argument. Since the stack
       uses very little memory, there is usually no need to reduce it.

       In programs with CHAINed modules, you may have to change the
       stack size for the compiled application if you get "error 7" at
       the CHAIN statement. Compile all the modules with the "Create
       Program List File" option on and look in the listings under
       Storage in the "Symbol and Label Tables for: Main." Your main
       module needs to clear enough stack space for the largest
       Storage entry with code similar to this:

       '   As above, heap& is the heap space. stack& is the stack space
       heap&=100*1024&    'fill in the actual heap& you want to leave
       stack&=10000&      'use value from 'lst' file for the largest module
       IF SYSTEM(4) THEN  'compiled
          CLEAR,FRE(0)+FRE(-1)-heap&-stack&,stack&
       ELSE    'interpreted
          CLEAR,FRE(0)+FRE(-1)-heap&
       END IF

544    Error Messages: Code Resources Conflict

       This new message indicates that you have used libraries from
       previous versions of Basic. Use the new library routines
       instead. For most programs, it is sufficient to comment out all
       the Library statements and compile with "Copy MBLCs and MBPCs"
       switch enabled. See also "Old Libraries" and "QB And Basic 3.0
       On The Same Disk" in Part 4, Notes and Warnings.

Part 2: Notes for the Microsoft QuickBasic User's Guide

16, 53  New Search Menu Features

        Microsoft QuickBasic has several new Search menu features to
        make navigating your programs much faster.

        Several of these features are token-based. A "token" is a
        Basic keyword, variable name, subprogram name, or label.
        Anything highlighted when you double click is also a token.
        The following list adds to or clarifies information about the
        Search menu.

17      Find Definition

        With the insertion point in a line or label reference,
        subprogram name, or FN function name, QB scrolls the list
        window to that name's definition. The insertion point does not
        move, so you can return to it by pressing an arrow key or
        choosing Find Insertion Point from the Search menu.

        For label references, QB shows the label. For a subprogram
        name, QB shows the SUBI statement. For an FN, QB shows the DEF
        FN statement.

        This does not work for other tokens. The search is much faster
        than Find.

        It is handy to keep a list of your important subprograms and
        labels in a comment at the start of the file so you can "Jump
        To" line 1, then "Find Definition."

17      Find Selected Text

        This has the same effect as typing the highlighted text in the
        Find dialog. After executing this command, the text appears in
        the Find dialog, which allows the Find Next command to
        continue searching.

18      Jump To

        Enter the source line offset number (not the Basic line
        number). The number displayed in a compiled application's run
        time error dialog is the source line offset number for that
        error. This command makes it easy to find the offending line.

        To jump to the beginning of a file, type Command-J, "1," and
        <RETURN>. To jump to the end of a file, type Command-J, enter
        any letters (just press your hand on the keyboard), and press
        <RETURN>.

18      Set Info

        If you Set Info on a new token, the 'info' is saved in the
        resource fork of your source file. You can move 'info' entries
        you define to QB by typing "MBUI" into the "other" dialog in
        the Statement Mover program, or by using ResEdit.

19      The Run Menu: Command-k

        As a compiling convenience, Command-k compiles the file with
        the last name you picked for the application. This saves
        reaffirming the application name every time you compile. The
        first time you compile (no matter which menu item you use), QB
        will ask for a name. Command-k is the same as choosing
        "Compile"; Option-Command-k is the same as "Compile As."

98      Setting Compiler Options: Save Before Compiling

        This new option in the Options dialog box automatically saves
        the source file before you compile, saving a step in the
        edit-compile process.

152     Creating Application Icons With ResEdit

        Summary:

        The following resources (located in a compiled QuickBasic
        application) can be modified with ResEdit to give an
        application and its documents their own customized icons:
        BNDL; Fref; ICN#; and the sample "signature" resource, "MBCB".
        The information in the Finder's Get Info dialog box for the
        application can also be specified.

        Procedure:

        You can create a compiled program with its own icon, and it
        can create document files with their own icons. A document
        file can be assigned its own icon by changing its file and
        creator types to correspond to resource information stored in
        the compiled application. The icon for a given document file
        type is taken from the resource fork of the compiled
        application and stored in the Finder's Desktop file.

        The default creator type is "Edit" and the default file type
        is "Text" for files created with the OPEN statement. The
        creator and file types of a document must be changed by your
        QuickBasic program after the file is created.

        1. Change the creator type of a document using the SetCreate
           MBLC library routine, as follows:

           SetCreate docfile$,"MyAp"

        2. Change the file type using the NAME statement, as follows:

           NAME docfile$ AS docfile$,"Myft"

        Double clicking a document icon runs the associated
        application. By PEEKing through a handle to the application
        parameters, your application can determine which file was
        selected. See "File Browser.source" on the Examples disk for
        sample code that does this.

        Here are step-by-step instructions for creating your own
        icons:

        1. Compile a program using Microsoft QuickBasic. For this
           example, assume the compiled program is called "MYProgRAM
           apl".

        2. Run ResEdit.

        3. Double click on the "MYProgRAM apl" application.

        4. Select New from the File menu, then do the following:

           a. Type a unique creator resource type, for example: "MyAp"
           b. The following window appears: "MyAp's from MYProgRAM apl"
           c. Select New from the File menu.
           d. Close the new resource window.
           e. Choose Get Info from the File menu and change the number
              which appears in the first "ID:" box to 0 (zero).
           f. Close the window.
           g. Perform the following steps if you wish to put a string in
              the file's Get Info box in the Finder:

              i. Select the new resource, and choose Open As from the
                 File menu.
             ii. Select type "STR " (NOT "STR#").
            iii. Type the text which you wish to appear in a Get Info
                 from the Finder.
             iv. Close windows.
                 If you do not want text to appear in the Get Info
                 window, then open the resource, and type three zeros.

        5. Double click on BNDL, then do the following:

           a. Double click on "BNDL=128"
           b. Change OwnerName to be the same as the unique,
              four-character, application resource type used in step
              4a ("MyAp").
           c. Close two windows.

        6. Perform this step if you want custom document icons:

           a. Double click on Fref.
           b. Double click on "Fref=129".
           c. Change the "File Type" to "Myft" This is the type used
              in the NAME statement in the "MYProgRAM apl" program.
           d. Close two windows.

           No other program will be able to open your documents. You
           do not need to change the file type if your application
           creates plain text files (type Text).

        7. Double click on ICN#.

           a. Edit the application icon and, if desired, the document
              icon. Then select "Data to Mask" from the ICN# menu.
           b. Close Three windows.
           c. Click YES to Save.

        8. While the "MYProgRAM apl" application is highlighted,
           select Get Info from the File menu.

           a. Change the Creator to the unique four character
              application creator resource name, used in step 4a:
              "MyAp"
           b. Close the window.
           c. Click YES to Save.

        9. Rebuild the Macintosh Desktop in either of the following
           ways:

           a. While holding down the Command and OPTION keys, select
              Quit from the File menu, and keep holding down the
              Command and OPTION keys until a dialog box appears.
              Click YES to rebuild the Desktop.
           b. Or, select the DeskTop file in ResEdit, and choose Clear
              from the Edit menu. Quitting ResEdit now rebuilds the
              DeskTop.

Additional Document Types

To add an icon for an additional file type that your application
creates, add another icon to the ICN#, another Fref, and entries for
the icon and Fref in the BNDL resource.

To add the Fref, open your application with ResEdit, and open the
Frefs. Select New to create a new Fref, then set the file type to your
new type, and set a new localID (3 for the first additional file
type). Close the Fref and select Get Info to change the resource ID to
the next in line (130 for the first additional file type).

To add an icon, open the ICN# in the application. Select New or
Duplicate to create a new icon. Alter as you like, close it, Get Info,
change the ID (again, 130 for the first additional).

Now open the application's BNDL. Find the line of dashes under the
ICN#. Click on the line and select New. Fill in the localID and
Resource ID to correspond with the icon and Fref you created. Do the
same with the line of dashes under Fref.

As before, you must rebuild the Desktop to see the new icons.

Part 3: Printing Graphics

Additional Information On Printing Graphics

Printing Graphics is the same as printing to the screen. Use WindOW
OUTPUT #n after opening the printer, and all graphic calls (except
Backpat) will go to the printer. LINE (0,0)-(551,729),,b will outline
the drawable area on a LaserWriter page when printed at 100%.

If you want to print the window contents, record a picture as you draw
the screen, then replay the picture to the printer. Follow this
general outline:

       Picture ON :ShowPen  'make drawing visible
       '
       '       draw the window contents
       '       (Picture and PUT work here, too!)
       '
       Picture OFF :HidePen
       windowPic$=Picture$
       '
       OPEN "lpt1:prompt" FOR OUTPUT AS #1
       WindOW OUTPUT #1
       Picture ,windowPic$
       CLOSE #1

You can also use the resulting picture to refresh the screen. Pictures
are usually more compact than GET arrays and preserve color in
addition to printing faster on a LaserWriter.

Screen Dumps

Use the "PrintScreen" subprogram in the "Utilities SUBs" file to send
a copy of your screen to a printer. Unlike Lcopy, this works for color
screens and LaserWriters. "PrintScreen" is in the "Utility SUBs"
folder on the Examples disk, along with a "PrintWindow" utility.

Examples

"Calendar" on the Examples disk contains sample graphics printing.

Part 4: Warnings and Notes

Warnings

Strange Error Messages

If you get an interpreter error message that does not make sense, try
compiling the program. If the error is reported by the compiler, run
the program in the interpreter. The interpreter and the compiler read
your program differently, so one may provide a better error message
than the other. When the highlighted text and error message do not
match, or when nothing is highlighted, turn on the "Create Error List
File" option in the Options dialog box and compile the program. The
'<filename> lst' file will show more precisely where the error
occurred. It can show more than one error at a time.

Compiled Application Run-Time Errors

Errors that occur at run time in a compiled application do not display
a message. Only the error number is displayed. The error message may
be discovered by typing "ERROR <#>" in the QuickBasic environment
command window.

Old Libraries

If your program mysteriously crashes, old Codes can be the cause. If
you need to use older custom libraries, make sure the ID numbers for
those Code resources are greater than 100. Compile and run the
"Renumber Codes" utility on the Examples disk in the "Tools" folder.

Tmon Users Beware

Single voice sound can crash if Tmon is active. To avoid this, insert
"Wave 0,SIN" at the beginning of your program.

Notes

QB and Basic 3.0 on the Same Disk

QB will give the files it creates or saves the same creator type as
QB, whatever it may be. The default is the same as Basic 3.0. If you
want QB to work on the same disk  with Basic 3.0, change its creator
type from "MSBB" to "msbb" with ResEdit (use Get Info). To make your
changes visible, delete the desktop file with ResEdit (select Clear
from the Edit menu), or restart while holding down the command and
option keys. QB includes an alternate BNDL resource for the "msbb"
type. For the decimal version, change the creator type from "MSBA" to
"msba."

Basic 3.0 files (creator=MSBB) will have the Basic document icon and
will start up Basic 3.0 when double clicked. QB files (creator=msbb)
will have the QB icon and start up QB when double clicked. QB can open
files created by QB or Basic 3.0. Basic can see QB files, but will
produce a "Bad file mode" error if you try to open a QB compressed
file.

Slow Printing

The PRINT command sends the screen or printer one character at a time.
Use the DrawText library routine to send an entire string at once.
This will speed text printing to the screen or graphics devices. You
still need to use PRINT for number formatting or carriage returns.

New Run-Time Names

If you want to keep the run time libraries separate and change the
names, you must change the application "STR" resources id=9300-9303
with ResEdit to the names you prefer. QB will look for them in the
folder named in the STR 9300 resource.

Resources in Your Source

The Ditl 128, Dlog 128, and STR 128 resources are for the About...
dialog box.

MBCO 0: compiler options
MBAN 0: compiled application name
MBPN: File path name

MBUI: MBUI resources are created when you use Set Info for a new word.

MBLC, MBPC: If you put any of these resources in the resource fork of
your source file, and the "Copy MBLCs and MBPCs" switch is enabled,
they will be automatically copied to the application each time it
compiles. A Library statement in your program is not required.

Resources in Your Application

   BNDL: application and document icon support
   Code: application code
   Ditl: 128 About
   Dlog: 128 About
   Fref: application and document icon support
   ICN#: sample application and document icons
   MBAV: application version (used to verify run time)
   MBCB: "signature" resource (application and document icon support)
   MBCI: compiler information
   MBLC: library code resources
   MBPC: pure code resources
   MBPN: File path name
   MBRL: 0 (binary), 1 (decimal), or 2 (68881) run time support code.
   Prec 0: Lpt1:Prompt page sizes
   Size -1: MultiFinder information
   STR  128: About 93xx run time path and file names
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB34286


MAC QB 1.00 Readme: Resources Stored in Source & Application (34287)

Summary

The following is a list of the resources that you will find in your source and application when using Resedit. This information was taken from the Readme file on the QuickBasic 1.00 distribution disks.

More information

Resources Stored in Your Source

  1. The Ditl 128, Dlog 128, and STR 128 resources are for the "About Application..." dialog box in the Apple menu.
  2. MBCO 0 -- compiler options
  3. MBAN 0 -- compiled application name
  4. MBPN -- File path name
  5. MBUI -- MBUI resources are created when you use Set Info for a new word.
  6. MBLC, MBPC -- If you put MBLC or MBPC resources in the resource fork of your source file, and the "Copy MBLCs and MBPCs" switch is enabled, they will be automatically copied to the application each time it compiles. A Library statement in your program is not required.

Resources Stored in Your Application

BNDL -- application and document icon support
Code -- application code
Ditl -- 128 About
Dlog -- 128 About
Fref -- application and document icon support
ICN# -- sample application and document icons
MBAV -- application version (used to verify run time)
MBCB -- "signature" resource (application and document icon support)
MBCI -- compiler information
MBLC -- library code resources
MBPC -- pure code resources
MBPN -- File path name
MBRL -- 0 (binary), 1 (decimal), or 2 (68881) run time support code.
Prec 0 -- Lpt1:Prompt page sizes
Size -1 -- MultiFinder information
STR 128 -- About 93xx run time path and file names

Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34287


LIST <Line> Moves to Specified Line in QuickBasic Editor (34288)

Summary

The LIST command (not documented in the manual) allows you to move to a specific numbered or labeled line by typing "LIST <line>" in the QuickBasic command window. The LIST command is not allowed in the source code of a program.

The LIST command is documented in the Readme file on the Macintosh QuickBasic distribution disk. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB34288


Negative Math/Overflow in Compiled Program; OK in Interpreter (34290)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    This information applies to Microsoft QuickBasic 1.00, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

    The compiler is more limited than the interpreter in handling numeric overflow and will, in certain circumstances, return negative or wrong values when intermediate calculations overflow. The compiler must decide at compile time which precision is appropriate for a given operation. The precision cannot be changed if it proves inadequate at run time. This difference is documented on Page 90 of the "Microsoft Basic Compiler for Apple Macintosh" manual and Page 70 of the "Microsoft QuickBasic for Apple Macintosh: User's Guide."

    More information

    The following example demonstrates the difference:
       M% = 30000 : N% = 30000
   X! = M% + N%
   PRINT X!
    Within the interpreter, this code produces the value 60000 for X!. The integer sum of the integer values M% and N% is automatically converted to the floating-point value X!.

    The compiler is not able to make the same conversion when it turns your program into an application. Since the expression in the last statement contains only integer variables, the compiler generates object code to perform integer addition. However, the result is too large (greater than 32,767) to be handled as an integer, so an incorrect value (-5536) is printed.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB34290


Using Same Source to CHAIN When Both Interpreted and Compiled (34291)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The following information applies to the Microsoft QuickBasic Compiler Version 1.00 for the Apple Macintosh.

    It is possible to write a QuickBasic program that CHAINs both in the interpreter environment and in a compiled application without changes to the source file. The first method uses the $IGNORE metacommand, while the second uses the SYSTEM(4) function. The REM $IGNORE ON metacommand instructs the compiler to ignore the following statements until a REM $IGNORE OFF is encountered. The SYSTEM(4) function returns 1 in a compiled program and 0 in an interpreted program.

    More information

    Let us assume that we have a program "proga" which CHAINs to "progb". The following is the listing for "progb":
       PRINT "inside progb"
   END
    When you compile the "progb" source file, the compiler names the compiled application "progb apl" by default.

    The following is the listing for "proga" using the first (REM $IGNORE ON/OFF) method:
      CLS
  PRINT "inside proga"
  ext$ = " Apl"
  nxtprog$ = "progb"
  REM $IGNORE ON
  ext$ = ""
  REM $IGNORE OFF
  nxtprog$ = nxtprog$ + ext$
  CHAIN nxtprog$
    The following is the listing for "proga" using the second [i.e., SYSTEM(4)] method:
      CLS
  PRINT "inside proga"
  ext$ = " Apl"   ' Compiler appends " Apl" to application names.
  nxtprog$ = "progb"
  ' When SYSTEM(4) returns 0, we're inside environment:
  IF SYSTEM(4) = 0 THEN ext$ = ""
  nxtprog$ = nxtprog$ + ext$
  CHAIN nxtprog$
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB34291


Understanding Floating-Point Differences in Mac QuickBasic (34292)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The following information applies to the Microsoft QuickBasic Compiler 1.00 for the Apple Macintosh.

    To increase efficiency, the compiler uses different floating-point arithmetic routines than the QuickBasic interpreter environment. As a result, equivalent floating-point expressions may produce slightly different values in a compiled application compared to running in the QuickBasic environment.

    More information

    The following examples show that although binary versions calculate to more decimal places, the decimal versions are more accurate. The following source code produces slightly different values, as shown in the four sets of output:
      s1! = 33 : s2! = 13 : s3! = 3
  s4! = SIN (s1!/s2!) * (TAN (s2! * s3!) ^ 3)
  d1# = 33 : d2# = 13 : d3# = 3
  d4# = SIN (d1#/d2#) * (TAN (d2# * d3#) ^ 3)
  PRINT "Single"; s4!, "Double "; d4#
  END
    Output from the QuickBasic environment (binary version):

    Single 26.78669 Double 26.78667677467639

    Output from compiled application (binary version):

    Single 26.78668 Double 26.78669793504293

    Output from QuickBasic environment (decimal version):

    Single 26.7867 Double 26.786676774842

    Output from compiled application (decimal version):

    Single 26.7866 Double 26.786578796841

    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB34292


MAC QB 1.00 Readme: SYSTEM(7) Returns Resource File Reference (34331)

Summary

The following feature needs to be added to the "Microsoft QuickBasic 1.00 Basic Language Reference." This information is taken from the Readme file from the release disk.

SYSTEM Function (New SYSTEM(7) Function)

SYSTEM(7) returns the file reference number of the resource fork of the program source file when the program is interpreted. It returns the file reference number of the application resource fork in a compiled application. SYSTEM(7) can be combined with the GetPathName subprogram to find your program's full path name. See the "GetPathNames" demo program on the Examples disk. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB34331


MAC QB 1.00 Readme: Compile Statement Mover Program for Speed (34332)

Summary

The following information needs to be added to Appendix E of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information was taken from the Readme file from the release disk.

E.1.2 Using the Statement Mover Program

Compile Statement Mover for speed. Unlike previous versions of Statement Mover, this one does not automatically move LIBinits. If your library requires LIBinits, you must copy it. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34332


MAC QB 1.00 Readme: Custom LIBinit and LIBterm; Library (34333)

Summary

The following information needs to be added to Appendix E of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information was taken from the Readme file from the release disk.
E.2 Using Library Routines
--------------------------

Custom LIBinit and LIBterm:

LIBinit and LIBterm are called only with Library and Library CLOSE.
If your custom libraries need LIBinit and LIBterm, you must explicitly
call them, or use Library and Library CLOSE.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB34333


CALLing Library Routines with ! Required Only for DEFSTR (34334)

Summary

The following addition and modification applies to Appendix E of the "Microsoft QuickBasic for Apple Macintosh: Language Reference." This article expands upon the information presented in the Readme file for QuickBasic 1.00.

E.2.2 Calling Library Routines

(Add this to Page 420.)

You need to append a type specification (%, &, !, or #) to a library routine name only if a DEFSTR statement affects the first letter of that name. When using DEFINT, DEFLNG, DEFSNG, or DEFDBL, an explicit type character is not required in the routine name when calling a library routine. [In contrast, the earlier Microsoft Basic Compiler 1.00 for the Apple Macintosh requires an exclamation point on the routine name if DEFINT, DEFDBL, or DEFSTR affects the first letter. An exclamation point (!) declares a single-precision type.]

The following example is accepted in QuickBasic but not in the older Basic compiler Version 1.00 for Apple Macintosh:
   DEFINT a-z
   DrawText "Must invoke DrawText! (! required) in older compiler"

E.10.3.5 Toolbox Programming Errors

The following correction, marked between chevrons (<< >>), applies to Page 524 for the "Type Mismatch" error:

"This error is generated when you use a variable in a library statement that has not been previously defined, when not enough variables follow the routine name, <<when a library statement name is incorrectly defined as a string type with the DEFSTR statement,>> or when a variable is of the wrong type."

In other words, a library routine name is allowed to have a type of short or long integer, or single or double precision. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34334


QuickBasic BackColor Routine Is Faster Than ROM BackColor (34335)

Summary

The following note needs to be added to Appendix E of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information expands on the Readme file on the QuickBasic 1.00 release disk.

E.10.2 Toolbox Library Statement Reference

The BackColor routine in the QuickBasic Toolbox Library is faster than the BackColor routine in the Macintosh ROM accessible through the ToolBox statement. Here is the syntax:
   BackColor color
The manual describes the color arguments. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB34335


MAC QB 1.00 Readme: BlockMove Works for Overlapped Memory (34336)

Summary

The following information needs to be added to Appendix E of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information was taken from the Readme file from the release disk.
E.10.2 Toolbox Library Statement Reference
------------------------------------------

BlockMove sourceAddr&,destAddr&,bytes&

   sourceAddr& -- address to begin copying from
   destAddr& -- address to begin copying to
   bytes& -- number of bytes to copy

   BlockMove works even when the areas overlap.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34336


MAC QB 1.00 Readme: CopyFile Moves Both Data and Resource Fork (34337)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The following statement needs to be added to Appendix E of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information was taken from the Readme file from the release disk.

    E.10.2 Toolbox Library Statement Reference

    The following new Toolbox Library statement was added after the manual was printed:
       CopyFile sourceFile$,destName$
    It copies the file with name sourceFile$ to destName$, and copies both the data and resource forks of the file. Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB34337


MAC QB 1.00 Readme: Eject Routine for Both Floppy Disk Drives (34338)

Summary

The Eject statement needs to be added to Appendix E of the "Microsoft QuickBasic 1.00 Basic Language Reference." The Eject routine ejects both the external and internal floppy drives at once. The following is an example:
PRINT "The floppy disk(s) are about to be ejected."
CALL Eject
PRINT "The disk(s) are now ejected."
In earlier versions of the Microsoft Basic Interpreter and Compiler for the Macintosh, you had to call your own machine language routine to eject disks.

More information

The following information is taken from the Readme file from the QuickBasic 1.00 release disk:

E.10.2 Toolbox Library Statement Reference

The following new Toolbox Library statement was added after the manual was printed:

Eject

Ejects the disk in the internal and external drive. This is an MBPC resource.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34338


MAC QB 1.00 Readme: "Exists" Routine Tests if File Exists (34339)

The information in this article applies to:
  • Microsoft QuickBasic 1.00

    • Summary

    The following statement needs to be added to Appendix E of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information was taken from the Readme file on the release disk.

    E.10.2 Toolbox Library Statement Reference

    The following new Toolbox Library statement was added after the manual was printed:
    Exists fileName$,flag%

fileName$ -- full path of file, or simple name in current folder
flag% -- 0 = file does not exist, -1 = file exists
    Note that the Readme needs to be corrected to say flag% returns -1 if the file exists (not 1). Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB34339


QuickBasic ForeColor Routine Is Faster Than ROM ForeColor (34340)

Summary

The following information needs to be added to Appendix E of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information expands on the Readme file on the QuickBasic 1.00 release disk.

E.10.2 Toolbox Library Statement Reference

The ForeColor routine in the QuickBasic Toolbox Library is faster than the ForeColor routine in the Macintosh ROM accessible through the ToolBox statement. The following is the syntax:

ForeColor color

The manual describes the color arguments.

Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34340


MAC QB 1.00 Readme: GetCatInfo & GetFCBInfo; GetPathName Demo (34341)

Summary

The following statements need to be added to Appendix E of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information was taken from the Readme file from the release disk.

E.10.2 Toolbox Library Statement Reference

   DIM IOPB%(128)
   GetCatInfo IOPB%(0),FileName$[,DirID&][,VolRefNum%] [,DirIndex%]
   GetFCBInfo IOPB%(0),FileName$[,ioRef%][,VolRefNum%] [,FCBIndex%]
For more details of these calls, please see the "GetPathName" demo on the Examples Disk or "Inside Macintosh" Volume 4 (written by Apple Computer, published by Addison-Wesley). Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB34341


MAC QB 1.00 Readme: GetChanRefNum; OPEN # -> File Reference # (34342)

Summary

The following statement needs to be added to Appendix E of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information as taken from the Readme file from the release disk.

E.10.2 Toolbox Library Statement Reference

GetChanRefNum% Chan%,RefNum%
This r eturns the file reference number of the file with QuickBasic channel number Chan%. Chan% is the file number used to open the file. For example, in the statement OPEN f$ AS #1 the Chan% number is 1. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34342


MAC QB 1.00 Readme: GetHandleSize Gives Size of a Resource (34343)

Summary

The following statement needs to be added to Appendix E of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information was taken from the Readme file from the release disk.

E.10.2 Toolbox Library Statement Reference

GetHandleSize h&,size&
This returns the size of a resource in bytes when given the resource's handle.

More information

The following is an additional related note not found in the Readme file. For the GetHandleSize statement, the variable Size& returns the number of bytes occupied by the actual data of the resource in memory. This does not include the size of additional information about the resource such as the name, attributes, and ID number. These are kept in the resource file.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB34343


ScrollText Example to Specify Leading Spacing in Scroll Bar (34344)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The following information needs to be added to the ScrollText statement on Page 492 of the "Microsoft QuickBasic for Macintosh: Basic Language Reference":

    E.10.2 Toolbox Library Statement Reference
    ------------------------------------------

    ScrollText H&,rec%(0),a$(0),top%,rows%[,num%[,delay%[,leading%]]]

    Scrolltext now has an additional optional parameter that specifies the leading (space between lines) in pixels. The default is 4 pixels.

    This information was taken from the Readme.Doc file from the Version 1.00 release disk, except the Readme.Doc incorrectly says the information applies to Page 519 rather than Page 492. A code example of using the leading% parameter is shown below.

    More information

    For more information, please see Section E.5, "Scrolling," on Pages 432, 433, and 434 of the "Microsoft QuickBasic for Macintosh: Basic Language Reference."

    The [optional] "leading" parameter determines the amount of space between items in the scroll area. The value for "leading" should be added to the calculation used to calculate the vertical position of the font being used:
       vertpos% =inf%(1)+inf%(2)+inf%(4)+leading%
    Below is an example of using the "leading" parameter:

    Code Example

    OPTION BASE 1
leading%=4         ' "leading" pixel parameter
dim inf(4)
REM    inf(1) = font ascent
REM    inf(2) = font descent
REM    inf(4) = vertical distance between descent line and
REM               the ascent line below it.

GetFontInfo inf%(1)
vertpos% =inf%(1)+inf%(2)+inf%(4)+leading%
linenum%=0
top%=0
s&=0
in%=0
DIM ref%,p!,p.id%,pt!,pat.id,reg!,d!,in%,s!
DIM top%,linenum%,curs%,inpic%,inscr%'
setrect scr%(1),3,6,114,111
setrect bar%(1),113,6,129,111
FrameRect VARPTR(scr%(1))
newscroll s&,bar%(1),1,1,10,1
FOR i=1 TO 10
 READ s$(i)
NEXT i
DATA one,two,three,four,five,six,seven,eight,nine,ten
REM *************Determine LINE Clicked***************
GetMouse pt%(1)
PtInRect pt%(1),irec%(1),inpic%
PtInRect pt%(1),scr%(1),inscr%
linenum%=(pt%(1)-6)\vertpos%+top%
REM **************************************************
REM *************SELECT LINE Clicked******************
ScrollText s&,scr%(1),s$(1),top%,10,linenum%,,leading%
REM **************************************************
    '****** main loop ******
    InitCursor
    WHILE 1
      ScrollText s&,scr%(1),s$(1),top%,10,linenum%,,leading%
      GetMouse pt%(1)
      PtInRect pt%(1),crec%(1),in%
      IF in% THEN ChangeCursor curs% ELSE InitCursor
        IF DialoG(0)=1 THEN
            GOSUB doButton
        ELSEIF Mouse(0)<>0 THEN
            GOSUB doMouse
        ELSEIF Menu(0)<>0 THEN
            IF Menu(1)=1 THEN :DisposeScroll s! :END
        END IF
    WEND

doButton:
    but=DialoG(1)
    SELECT CASE but
    CASE 1
        IF p.id%<>0 THEN ReleaseRes p!:EraseRect VARPTR(prec%(1))
        IF p.id%<7 THEN p.id%=p.id%+1 ELSE p.id%=1
        GetPicture ref%,p.id%,p!
        DrawPicture p!,,prec%(1)
    END SELECT
    RETURN

doMouse:
    GetMouse pt%(1)
    PtInRect pt%(1),irec%(1),inpic%
    PtInRect pt%(1),scr%(1),inscr%
      linenum%=(pt%(1)-6)\vertpos%+top%
      top%=0
      ScrollText s&,scr%(1),s$(1),top%,10,linenum%,,leading%
      WHILE Mouse(0)<>0:WEND
    RETURN
DisposeScroll s&
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB34344


MAC QB 1.0 Readme: Use SubLaunch to Run Any Mac Application (34345)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The following statement needs to be added to Appendix E of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information was taken from the Readme file from the release disk.
    E.10.2 Toolbox Library Statement Reference
------------------------------------------

SubLaunch appName$ [,fileName$] [,finderMsg%] [,fileType$]

appName$ -- full path name of application to sublaunch
fileName$ -- full path name of file to Open or Print.
finderMsg% -- 0 = Open, 1 = Print, 256 = Compile (QB only)
fileType$ -- type of file fileName$.
    This information applies to Microsoft QuickBasic for Macintosh version 1.0.

    More information

    SubLaunch can run any Macintosh application under the Finder. However, SubLaunch may not work correctly under the Apple MultiFinder. For more information, query on the following words in the Microsoft Knowledge Base:

    SubLaunch and MultiFinder

    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB34345


MAC QB 1.00 Readme: "Out of Memory"; Changing Size resource (34346)

Summary

The following information needs to be added to Appendix F of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information was taken from the Readme file from the release disk.

Controlling Memory (Loading Files)

Because QuickBasic initially allocates one third of the memory listed in the Size resource to the data area (about 100K), and QuickBasic reads your program into the data area, programs larger than 100K can produce the "Out of memory" error. You can change the Size resource either with ResEdit or with "Get Info" for QuickBasic under MultiFinder, Finder 6.1 or later. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34346


MAC QB 1.00 Readme: If CHAIN "Out of Memory," Change Stack (34347)

Summary

The following information needs to be added to Page 540 in Appendix F of the "Microsoft QuickBasic 1.00 Basic Language Reference." This information was taken from the Readme file from the release disk:

In programs with CHAINed modules, you may have to change the stack size for the compiled application if you get "error 7" at the CHAIN statement. Compile all the modules with the "Create Program List File" option on and look in the listings under Storage in the "Symbol and Label Tables for: Main." Your main module needs to clear enough stack space for the largest Storage entry with code similar to this:
  '   As above, heap& is the heap space. stack& is the stack space
  heap&=100*1024&    'fill in the actual heap& you want to leave
  stack&=10000&      'use value from 'lst' file for the largest module
  IF SYSTEM(4) THEN  'compiled
      CLEAR,FRE(0)+FRE(-1)-heap&-stack&,stack&
  ELSE    'interpreted
      CLEAR,FRE(0)+FRE(-1)-heap&
  END IF
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB34347


MAC QB 1.00 Readme: Search Menu Features Explained Further (34348)

Summary

The following supplementary information for the Search Menu Features needs to be added to the "Microsoft QuickBasic 1.00 User's Guide." This information was taken from the Readme file from the release disk.

More information

Pages 16, 53 New Search Menu Features

Microsoft QuickBasic has several new Search menu features to make navigating your programs much faster.

Several of these features are token-based. A "token" is a Basic keyword, variable name, subprogram name,or label. Anything highlighted when you double click is also a token. The following list adds to or clarifies information about the Search menu.

Page 17 Find Definition

With the insertion point in a line or label reference, subprogram name, or FN function name, QB scrolls the list window to that name's definition. The insertion point does not move, so you can return to it by pressing an arrow key or choosing "Find Insertion Point" from the Search menu.

For label references, QB shows the label. For a subprogram name, QB shows the SUBI statement. For an FN, QB shows the DEF FN statement. This does not work for other tokens. The search is much faster than Find.

It is handy to keep a list of your important subprograms and labels in a comment at the start of the file so you can "Jump To" line 1, then "Find Definition."

Page 17 Find Selected Text

This has the same effect as typing the highlighted text in the Find dialog. After executing this command, the text appears in the Find dialog, which allows the Find Next command to continue searching.

Page 18 Jump To

Enter the source line offset number (not the Basic line number). The number displayed in a compiled application's run time error dialog is the source line offset number for that error. This command makes it easy to find the offending line.

To jump to the beginning of a file, type Command-J, "1," and <RETURN>. To jump to the end of a file, type Command-J, enter any letters (just press your hand on the keyboard), and press <RETURN>.

Page 18 Set Info

If you Set Info on a new token, the 'info' is saved in the resource fork of your source file. You can move 'info' entries you define to QB by typing "MBUI" into the "other" dialog in the Statement Mover program, or by using ResEdit.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34348


MAC QB 1.00 Readme: Command-K, No Prompt if Application Exists (34349)

Summary

The following supplementary information for the Command-K feature in the Run menu needs to be added to Page 19 of the "Microsoft QuickBasic 1.00 User's Guide." This information was taken from the Readme file from the release disk.

Page 19 The Run Menu: Command-k

As a compiling convenience, Command-k compiles the file with the last name you picked for the application. This saves reaffirming the application name every time you compile. The first time you compile (no matter which menu item you use), QB will ask for a name. Command-k is the same as choosing "Compile"; Option-Command-k is the same as "Compile As." Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB34349


MAC QB 1.00 Readme: Options... Box Add "Save Before Compiling" (34350)

Summary

The Save Before Compiling option needs to be added under Compiler Options... on Page 98 of the "Microsoft QuickBasic 1.00 User's Guide." (Options... is in the QuickBasic Run menu.) This information was taken from the Readme file on the release disk.

98 Setting Compiler Options: Save Before Compiling

This new option in the Options dialog box automatically saves the source file before you compile, saving a step in the edit-compile process. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34350


Mac QB 1.00 Readme: Creating Application and Document Icons (34351)

Summary

The following is a replacement for the "Creating Application Icons with ICN#" discussion on Pages 152, 153, 154, 155, 156, and 157 of the "Microsoft QuickBasic for Apple Macintosh: User's Guide." The discussion in the manual is incomplete and incorrect. This information was taken from the Readme file on the release disk.

More information

Creating Application Icons With ResEdit

Summary

The following resources (located in a compiled QuickBasic application) can be modified with ResEdit to give an application and its documents their own customized icons: BNDL; Fref; ICN#; and the sample "signature" resource, "MBCB". The information in the Finder's Get Info dialog box for the application can also be specified.

Procedure

You can create a compiled program with its own icon, and it can create document files with their own icons. A document file can be assigned its own icon by changing its file and creator types to correspond to resource information stored in the compiled application. The icon for a given document file type is taken from the resource fork of the compiled application and stored in the Finder's Desktop file.

The default creator code is blank, and the default file type is "Text", for files created with the OPEN statement. The creator and file types of a document must be changed by your QuickBasic program after the file is created.
  1. Change the creator type of a document using the SetCreate MBLC library routine, as follows:

    SetCreate docfile$,"MyAp"

  2. Change the file type using the NAME statement, as follows:

    NAME docfile$ AS docfile$,"Myft"

Double-clicking a document icon runs the associated application. By PEEKing through a handle to the application parameters, your application can determine which file was selected. See "File Browser.source" on the Examples disk for sample code that does this.

Here are step-by-step instructions for creating your own icons:
  1. Compile a program using Microsoft QuickBasic. For this example, assume the compiled program is called "MYProgRAM apl".
  2. Run ResEdit.
  3. Double-click on the "MYProgRAM apl" application.
  4. Select New from the File menu, then do the following:

    1. Type a unique creator resource type, for example: "MyAp".
    2. The following window appears: "MyAp's from MYProgRAM apl".
    3. Select New from the File menu.
    4. Close the new resource window.
    5. Choose Get Info from the File menu and change the number that appears in the first "ID:" box to 0 (zero).
    6. Close the window.
    7. Perform the following steps if you wish to put a string in the file's Get Info box in the Finder:

      1. Select the new resource, and choose Open As from the File menu.
      2. Select type "STR " (NOT "STR#").
      3. Type the text that you want to appear in a Get Info from the Finder.
      4. Close windows. If you do not want text to appear in the Get Info window, then open the resource, and type three zeros.
  5. Double-click on BNDL, then do the following:

    1. Double-click on "BNDL=128".
    2. Change OwnerName to be the same as the unique, four-character, application resource type used in Step 4a ("MyAp").
    3. Close two windows.
  6. Perform this step if you want custom document icons:

    1. Double-click on Fref.
    2. Double-click on "Fref=129".
    3. Change the "File Type" to "Myft". This is the type used in the NAME statement in the "MYProgRAM apl" program.
    4. Close two windows. No other program will be able to open your documents. You do not need to change the file type if your application creates plain text files (type Text).
  7. Double-click on ICN#.

    1. Edit the application icon and, if desired, the document icon. Then select "Data to Mask" from the ICN# menu.
    2. Close three windows.
    3. Click YES to Save.
  8. While the "MYProgRAM apl" application is highlighted, select Get Info from the File menu.

    1. Change the Creator to the unique four-character application creator resource name used in Step 4a ("MyAp").
    2. Close the window.
    3. Click YES to Save.
  9. Rebuild the Macintosh Desktop in either of the following ways:

    1. While holding down the Command and OPTION keys, select Quit from the File menu, and keep holding down the Command and OPTION keys until a dialog box appears. Click YES to rebuild the Desktop.
    2. Or, select the Desktop file in ResEdit, and choose Clear from the Edit menu. Quitting ResEdit now rebuilds the Desktop.

Additional Document Types

To add an icon for an additional file type that your application creates, add another icon to the ICN#, another Fref, and entries for the icon and Fref in the BNDL resource.

To add the Fref, open your application with ResEdit, and open the Frefs. Select New to create a new Fref, then set the file type to your new type, and set a new localID (3 for the first additional file type). Close the Fref and select Get Info to change the resource ID to the next in line (130 for the first additional file type).

To add an icon, open the ICN# in the application. Select New or Duplicate to create a new icon. Alter as you like, close it, Get Info, change the ID (again, 130 for the first additional).

Now open the application's BNDL. Find the line of dashes under the ICN#. Click on the line and select New. Fill in the localID and Resource ID to correspond with the icon and Fref you created. Do the same with the line of dashes under Fref.

As before, you must rebuild the Desktop to see the new icons.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB34351


MAC QB 1.00 Readme: How to Send Screen Graphics to Printer (34352)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article describes how to send screen graphics to an Apple ImageWriter or LaserWriter printer. This information is taken from the Readme file on the release disk for Microsoft QuickBasic 1.00 for the Apple Macintosh. (The exception is that "Utility SUBs" in the "Screen Dumps" section of the original Readme is incorrect; the text should actually refer to the "Utility Subprograms" file. This correction has been added below.)

    More information

    Additional Information on Printing Graphics

    Printing Graphics is the same as printing to the screen. Use WindOW OUTPUT #n after opening the printer, and all graphic calls (except Backpat) will go to the printer. LINE (0,0)-(551,729),,b will outline the drawable area on a LaserWriter page when printed at 100%.

    If you want to print the window contents, record a picture as you draw the screen, then replay the picture to the printer. Follow this general outline:
           Picture ON :ShowPen  'make drawing visible
       '
       '       draw the window contents
       '       (Picture and PUT work here, too!)
       '
       Picture OFF :HidePen
       windowPic$=Picture$
       '
       OPEN "lpt1:prompt" FOR OUTPUT AS #1
       WindOW OUTPUT #1
       Picture ,windowPic$
       CLOSE #1
    You can also use the resulting picture to refresh the screen. Pictures are usually more compact than GET arrays and preserve color in addition to printing faster on a LaserWriter.

    Screen Dumps

    Use the "PrintScreen" subprogram in the "Utilities Subprograms" file to send a copy of your screen to a printer. Unlike Lcopy, this works for color screens and LaserWriters. "PrintScreen", along with a "PrintWindow" subprogram, is in the "Utility Subprograms" file in the "QB Demos" folder on the Examples disk.

    Examples

    "Calendar" on the Examples disk contains sample graphics printing.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB34352


MAC QB 1.00 Readme: How to Resolve Unknown Error Messages (34353)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The following information was taken from the Readme file on the release disk for Microsoft QuickBasic 1.00 for the Apple Macintosh.

    Compiled Application Run-Time Errors

    Errors that occur at run time in a compiled application do not display a message. Only the error number is displayed. The error message may be discovered by typing "ERROR <#>" in the QuickBasic environment command window.

    Strange Error Messages

    If you get an interpreter error message that does not make sense, try compiling the program. If the error is reported by the compiler, run the program in the interpreter. The interpreter and the compiler read your program differently, so one may provide a better error message than the other. When the highlighted text and error message do not match, or when nothing is highlighted, turn on the "Create Error List File" option in the Options dialog box and compile the program. The '<filename> lst' file will show more precisely where the error occurred. It can show more than one error at a time. Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB34353


MAC QB 1.00 Readme: Old Library Code Resources Can Hang (34354)

Summary

This information was taken from the Readme file on the release disk for Microsoft QuickBasic 1.00 for the Apple Macintosh.
Old Libraries
-------------

If your program mysteriously crashes, old Code resources can be the
cause. If you need to use older custom libraries, make sure the ID
numbers for those Code resources are greater than 100. Compile and run
the "Renumber Codes" utility on the Examples disk in the "Tools"
folder.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34354


MAC QB 1.00 Readme: Single-Voice Sound Hang if Tmon Active (34355)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The following information was taken from the Readme file on the release disk for Microsoft QuickBasic 1.00 for the Apple Macintosh.
    Tmon Users Beware
-----------------

Single voice sound can crash if Tmon is active. To avoid this,
insert "Wave 0,SIN" at the beginning of your program.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB34355


MAC QB 1.00 Readme: Changing Names of QB Run-Time Libraries (34356)

Summary

The following are the run-time libraries included with QuickBasic Version 1.00 for the Apple Macintosh:

Qb10.Bl = binary external run time
Qb10.Cl = 68881 coprocessor external run time
Qb10.Dl = decimal external run time

If you wish to change the names of these external run-time libraries, you must do the following (the following information was taken from the Readme file on the release disk for Microsoft QuickBasic 1.00 for the Apple Macintosh):

New Run-time Names

If you want to keep the run time libraries separate and change the names, you must change the application "STR" resources id=9300-9303 with ResEdit to the names you prefer. QuickBasic will look for them in the folder named in the STR 9300 resource. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34356


BUG: First PRINT after Resizing Output Window Is Lost (34606)

Symptoms

If you issue a sequence of PRINT commands so that the output starts scrolling and you resize the window smaller, the next PRINT statement does not appear. Subsequent PRINT statements appear correctly. Basic does not recognize the new window size until after the first PRINT statement has been executed on the newly sized window.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic Version 1.00, Basic Compiler 1.00, and Basic Interpreter Versions 2.00, 2.10, and 3.00 (buglist2.00, buglist2.10, buglist3.00) for the Macintosh .

We are researching this problem and will post new information as it becomes available.

More information

The following example demonstrates the problem:
FOR i = 1 TO 35
   PRINT "test"
NEXT i
PRINT "Now resize output window vertically smaller, then click window"
WHILE Mouse(0)<>1 : WEND
PRINT "This line will not appear"
PRINT "Second line does appear after window resized"
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB34606


Adding More Lines of Statement Help in QuickBasic "Set Info.." (34607)

Summary

The Set Info... option on the Macintosh QuickBasic Search menu allows you to add additional help information for any statement. As you add a complete line of help information, it automatically wraps to the next line; however, you cannot insert a carriage return. To insert some carriage returns to better format the help information, you can use ResEdit as shown under "More Information" below.

To retrieve information from the help system in Macintosh QuickBasic, position the insertion pointer on any keyword in the List window and press Command+I (or select the Get Info... option on the Search menu). Command+I displays the proper syntax for any selected QuickBasic statement or MBLC Toolbox Library routine.

More information

To embed extra carriage returns in the help box for a given statement, you can run ResEdit, as shown in the following steps:

  1. Run ResEdit.
  2. Do one of the following:

    1. Open the MBTI or MBKI resource of Microsoft QuickBasic (b) or (d).

      [An MBTI (Macintosh Basic Toolbox Info) resource contains help on all Toolbox library statements, which are stored in QuickBasic as MBLC resources. An MBKI (Macintosh Basic Keyword Info) resource contains help on all statements that are built into the QuickBasic language.]
    2. Or, you can open the MBUI (Macintosh Basic User Info) resource, if any, in the source file of a program.

      [An MBUI contains help information for user-defined keywords. An MBUI resource can be created by pressing OPTION+Command+I in QuickBasic on a selected token (a symbolic name in the List window) that QuickBasic does not find as the name of an MBKI or MBTI resource. MBUI resources are saved in the resource fork of the program source file, not in QuickBasic. You can optionally move MBUI resources into QuickBasic with Statement Mover if you wish that help available for all programs.]
  3. Highlight the statement you wish to add help information for.
  4. Select the Open As... option from the File menu.
  5. Select "STR " for the New Type Name.
  6. You can now add more than one line of help information in the box labeled "theStr" by pressing the Enter key after typing each line.
  7. Back out of Resedit by closing windows and saving the changes.
  8. The new information and added lines will be displayed when a Get Info... is done on the selected statement in the QuickBasic interpreter. You can edit the text on the added lines by clicking the mouse on the desired line. Pressing Enter exits the Get Info... option.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB34607


BUG: Syntax Error Loop Using Option Characters in Interpreter (34608)

Symptoms

Option characters typed on a line can seem to trap you in an unending "Syntax Error" loop in the Macintosh QuickBasic 1.00 interpreter or the Macintosh Basic interpreter Version 3.00. Anytime you click on other lines in the program, a "Syntax Error" message is given. The only way to resolve the problem is to highlight the error line with the mouse and delete it.

Microsoft has confirmed this to be a bug in QuickBasic 1.00 for the Macintosh and in the Microsoft Basic Interpreter Version 3.00 for the Macintosh (buglist3.00). We are researching this problem and will post new information as it becomes available.

More information

Option characters are special characters created by holding down the OPTION key while pressing another key.

To duplicate the problem, type in the following program by pressing OPTION-P (which creates a Greek letter pi) wherever you see an "x":
PRINT "xxx"
xxx:
It is okay to put option characters into quoted strings; however, they cannot be used for labels or variable names in QuickBasic.

To eliminate the "Syntax Error" loop, triple-click on the second line (or highlight it with the mouse), and press BackSPACE to delete it. Triple-clicking to select a line is a feature in QuickBasic not found in the Basic Interpreter Versions 3.00 and earlier.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB34608


BUG: "Device I/O" Error When Save w/ MS Mail & Not on Network (34609)

Symptoms

The QuickBasic environment periodically displays a "Device I/O" error message when attempting to save a program if Microsoft Mail is active but the Macintosh is not connected to the AppleTalk network. To work around the problem, connect the Macintosh to the network or deactivate Microsoft Mail.

Microsoft has confirmed this to be a bug in Version 1.00. We are researching this problem and will post new information as it becomes available.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB34609


How to Make QuickBasic Smaller to Fit on Bootable Floppy Disk (34812)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    QuickBasic for Macintosh is not shipped on a bootable disk. On a hard disk, there is room to put both the System Folder and QuickBasic on the same drive. With no hard disk, first boot the Macintosh from an Apple System disk in one floppy drive, and then run QuickBasic from another floppy drive.

    QuickBasic is fairly large, and you may have difficulty putting it onto a single bootable floppy disk. The binary (b) version of QuickBasic is too large to fit on an 800K disk with System 6.0 and Finder 6.1. The decimal (d) version is smaller because it only has one MBRL resource, whereas the binary version has two. You can use Resedit to make QuickBasic smaller by removing resources you do not need, as explained below. Before using Resedit to remove the resources, be sure you are working on a backup version of QuickBasic. Never use Resedit on files located on the original distribution disks.

    More information

    If you do not need support for the 68881 (the math coprocessor chip available on the Apple Macintosh II), you can remove the MBRL id=2 resource from the binary version of QuickBasic. This will free up 42K. This should be sufficient to put Microsoft QuickBasic (b), System 6.00, and Finder 6.10 all on one 800K disk. Alternatively, you could make a 68881-only version by deleting the MBRL id=0 resource from Microsoft QuickBasic (b).

    If you do not need the online help features of QuickBasic, you can remove the MBKI resource that contains help information on reserved words (10K) and the MBTI resource that has information on library routines (12K). If you are really desperate for disk space, you can remove the MBLC library routines you do not plan on using (22K).
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB34812


BUG: Extra Insertion Point on List Window (34959)

Symptoms

If you press the UP Arrow key immediately after single-step scrolling the program listing, the trace box is shown incorrectly one line above the actual current trace line. Then, either of the following gives slightly unexpected behavior:

  1. Typing text into the line now leaves a spurious insertion point on the screen.
  2. Pressing Command-T (or selecting Step from the Run menu) leaves two trace boxes on the screen.
To make the List window appear normal again, select List from the Windows menu (or press Command-L).

This problem occurs in Microsoft QuickBasic 1.00 for Apple Macintosh. Microsoft is researching this problem and will post new information as it becomes available.

More information

The following steps demonstrate the problem in more detail:

  1. Enter the following program:
       PRINT "Long      LINE"
   PRINT "Short"
   PRINT "Long      LINE"
   PRINT "Short"
   PRINT "Long      LINE"
   PRINT "Short"
   PRINT "Long      LINE"
   PRINT "Short"
  2. Size the List window so only a few lines are visible.
  3. Single-step through the program with Step from the Run menu (or Command-T) until QuickBasic scrolls the listing, leaving the trace box at the top of the window.
  4. Press the UP Arrow key. The text scrolls down correctly, but the trace box is redrawn in its previous size and position, now incorrectly one line above the current trace line.
  5. Typing text into the line now leaves a spurious insertion point on the screen. To make the screen appear normal again, select List from the Windows menu (or press Command-L).
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB34959


FIX: Window 1 or 7 Size Box Looks Incorrect in Compiled App (35324)

Symptoms

In compiled programs, resizeable types of windows have incorrectly drawn "size boxes" in their lower-right corner. (The following window types have size (or "grow") boxes: 1, -1, 7, and -7, where 1 is the default type.) However, the problem is only cosmetic. The size boxes behave normally and successfully resize the windows.

Microsoft has confirmed this to be a bug in applications compiled with Microsoft QuickBasic 1.00 and Basic Compiler 1.00 for the Macintosh . The problem does not occur in the interpreter in QuickBasic 1.00.

This problem is corrected in QuickBasic 1.00b.

The size-box icon normally appears as a small box overlaying a bigger box; however, in a compiled application, the small box is a few pixels larger than the standard.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB35324


BUG: $ Not Bold in Edit$, FILES$, INPUT$, Picture$ (35325)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    Tokens that have special meaning should normally be bold-faced in the List window in the Macintosh Basic or QuickBasic Interpreter. However, the interpreter fails to make the dollar sign character ($) bold-faced in the following reserved words:

    Edit$, FILES$, INPUT$, Picture$, and TIME$

    This is a cosmetic problem that does not affect product performance.

    More information

    Microsoft has confirmed this to be a bug in the following products:

    1. Microsoft QuickBasic 1.00 for the Macintosh
    2. The Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Macintosh (buglist2.00, buglist2.10, buglist3.00)
    We are researching this problem and will post new information as it becomes available.

    The Basic interpreter correctly makes the dollar sign bold-faced for reserved words (such as RIGHT$, MID$, etc.) that do not also have a form without the dollar sign. If a given Basic reserved word has a form both with and without a $, the $ is not properly made bold. Please refer to an appendix in the manual for a list of reserved words.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB35325


FIX: Syntax Error TIME$ to TIME$$ Loading Compressed 2.00 File (35326)

Symptoms

QuickBasic mistakenly expands the TIME$ statement to TIME$$ when it loads source files that were saved in Microsoft Basic Interpreter version 2.00 Compressed format. For example, PRINT TIME$ becomes PRINT TIME$$ at load time. PRINT TIME$$ then gives a "Syntax Error" at run time. You may do either of the following to work around the problem:

  1. Save the program in Text format in the Microsoft Basic Interpreter versions 2.00, 2.10, or 3.00 before loading it into QuickBasic. -or-

  2. After loading it into QuickBasic, select Change from the Search menu and do a Find on TIME$$ and Replace it with TIME$. Resave.
Microsoft has confirmed this to be a bug in Microsoft QuickBasic version 1.00 for the Macintosh . This problem is corrected in QuickBasic 1.00b.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB35326


FIX: Shift+Double-Click Selects Vertical Box Wrong InsertPoint (35328)

Symptoms

The editor (List window) in QuickBasic 1.00 and the Microsoft Basic Interpreter version 3.00 for Macintosh does not support selecting text by holding down the Shift key and double-clicking the mouse button. Using Shift+double-click can cause a highlighted block of text to appear in the middle of a vertical section of lines. After Shift+double-clicking, the flashing insertion point may be separated from the typed text. To eliminate this unusual editor behavior, click on any line except the line that contains the flashing insertion point.

Double-clicking can be used for highlighting a word only when the Shift key is not held down.

When using the Shift key with the mouse, the QuickBasic editor supports only Shift+single-clicking, which extends a selected (highlighted) range from the insertion point, or from a previously selected range, to the clicked location.

Microsoft has confirmed this to be an editor problem in Microsoft QuickBasic 1.00 and the Microsoft Basic Interpreter version 3.00 for the Macintosh . The editor needs to be changed so that Shift+double-click behaves like Shift+single-click to extend a text selection. This problem is corrected in QuickBasic 1.00b for Macintosh .

More information

The supported methods for selecting text are described on page 50 of the "Microsoft QuickBasic for Macintosh : User's Guide."

The following steps cause the insertion point to be separated from the place where entered text is inserted:

  1. Run QuickBasic 1.00 or the Basic 3.00 interpreter and load a program.
  2. Single-click on any word near the bottom of the List window.
  3. While holding down the Shift key, double-click on any line above the word where the insertion point lies. If you Shift+double-click directly above the word with the insertion point, a highlighted vertical box (an inverse-video block of text) displays, with a width equal to the word where the insertion point was located.
  4. Now type some text. The text is inserted where the insertion point was before the double-click; however, the insertion point now flashes on the line where you double-clicked and moves as you enter text below.
To work around the problem, click once on the List window on any line except the one that has the flashing insertion point. The List window now looks correct and the insertion point is correctly located.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB35328


BUG: Decimal Math QuickBasic, PRINT USING <Long Int> Gives 0 (35329)

Symptoms

In Microsoft QuickBasic (d) (decimal-math version) Version 1.00, when a variable of long integer type is printed with a PRINT USING statement, incorrect (or zero) values are printed. This problem occurs only in the decimal-math interpreter.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic (d) Version 1.00. We are researching this problem and will post new information as it becomes available.

This problem does not occur in a compiled decimal-math program or in the binary-math QuickBasic (b) compiler or interpreter.

More information

The following program incorrectly prints the long-integer variable (a&) as 0 (zero) in Microsoft QuickBasic (d) interpreter, but correctly prints "123456789" when compiled:
   a& = 123456789&
   PRINT USING "##########";a&
(Appending ampersand (&) to a variable name makes it a long integer.)

To work around the problem in decimal math QuickBasic interpreter, you can assign the long integer variable to a single- or double-precision temporary variable, which can be successfully printed with the PRINT USING statement, as follows:
   a& = 123456789&
   temp# = a&
   PRINT USING "##########";temp#
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB35329


BUG: CINT <Long> Bad Value or Run Error 6 Compiled for 68020 (35330)

Symptoms

Taking the CINT of a variable of type long will give Error 6 ("Overflow") at run time if the program is compiled with both the Generate 68020 Code and Check Arrays & Overflow compiler options. If the program is compiled without the Check Arrays & Overflow option, an incorrect (often negative) value will be returned. If the program is run in the interpreter or is compiled without the Generate 68020 Code option, the CINT function works correctly.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic Version 1.00 for the Macintosh . We are researching this problem and will post new information as it becomes available.

The following program statement demonstrates the problem:
PRINT CINT(1&amp;)
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB35330


FIX: Mac QuickBasic "Line Too Long" Pasting on Breakpoint Line (35358)

Symptoms

In the List window, a "Line Too Long" error can occur after you paste one or more complete lines onto the end of a line that has a breakpoint (stop sign) set. If you attempt to paste two or more lines, only the first line is successfully pasted. To avoid the problem, turn off the breakpoint (with Command+B) before pasting onto a line.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic version 1.00 for the Macintosh . This problem is corrected in QuickBasic 1.00b for Macintosh .

More information

You can add or remove a breakpoint by positioning the insertion point on a line and pressing Command+B.

To duplicate the problem, perform the following steps in Macintosh QuickBasic 1.00:

  1. Run QuickBasic (b) or (d) and load in any program.
  2. Highlight at least one entire line (so that the inverse video box extends to the farthest right area of the List window).
  3. Choose either Cut or Copy from the Edit menu.
  4. Click any line where you want to place a breakpoint (a stop sign).
  5. Press Command+B to set a breakpoint (stop sign) on the current line.
  6. Click the end of the breakpoint line.
  7. Select Paste from the Edit menu (or press Command+V).
  8. A "Line Too Long" error now occurs, and only the first line in the clipboard will have been pasted onto the breakpoint line. (Note that the stop sign correctly disappears as a result of adding to the line.)
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB35358


QuickBasic Incompatible with Radius, Prodigy Accelerator Board (35439)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Microsoft has not tested QuickBasic 1.0 with any of the Macintosh accelerator boards on the market. Several customers have reported incompatibility problems associated with the Radius, Prodigy, and Dove (such the Dove Marathon model) accelerator cards for the Apple Macintosh. Microsoft has not tested the reported problems and does not guarantee or support compatibility with Macintosh accelerator boards.

    More information

    According to unconfirmed customer reports, the Radius accelerator board reportedly does not allow QuickBasic to operate normally, and varied results may occur if a floating-point chip is present. If you have a floating-point chip (for example, a Motorola 68881) on your accelerator board and do not use the Generate 68020 Code option in the QuickBasic compiler, a compiled QuickBasic program reportedly runs correctly.

    However, if you do not have a floating-point chip on the accelerator, or if you use the Generate 68020 Code option and run on an accelerator that has a floating-point chip, the compiled QuickBasic program may return a hardware interrupt, "System Error 11."

    The Radius and Prodigy accelerator cards also reportedly do not work when using the SOUND statement in single-voice mode. A system hang may result.

    One customer with a Radius accelerator board reported "Out of memory" errors when loading a program into the QuickBasic editor. He also reported "Subscript out of range" errors for correctly dimensioned arrays. He reported fewer problems occurred using System version 6.0.2. This information may not be accurate, and Microsoft has not confirmed this information.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB35439


Macintosh Directory List & File Search Across Folders/Drives (35509)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Macintosh QuickBasic 1.00 includes library routines (MBLC resources) called GetCatInfo and HFSDispatch that let you do the following:

    1. Search for filenames through all the folders (directories) on all currently mounted disk (drive) volumes
    2. Produce a listing of the files in a given folder
    However, to effectively use GetCatInfo and HFSDispatch takes careful scrutiny of "Inside Macintosh," by Apple Computer, Inc. (published by Addison-Wesley). HFSDispatch is described in Volume 4 of "Inside Macintosh" and should be used only by advanced Macintosh Toolbox programmers.

    The sample program "Find File" below shows how to use the GetCatInfo and HFSDispatch library routines. For another example of using GetCatInfo, please see the GetPathName subprogram in the Utility Subprograms source file on the Macintosh QuickBasic 1.00 Examples disk in the QB Demos folder.

    More information

    '    "Find File"
'    File search example program.
'    Copyright 1988-1991 Microsoft Corp.
'    Written in Microsoft QuickBasic 1.00 for Apple Macintosh.
'    Microsoft makes no claims about support for or performance of
'    this example program.
'    [4/23/91 Program corrected in three places per SR# S890831-4, and
'             should now work ok.]

    '    globals
    DIM ShareD TRUE, FALSE
    FALSE = 0 :TRUE = NOT FALSE
        '       i/o parameter block (see Inside Macintosh Vol. 4)
    DIM ShareD IOPB%(60)
    '    stack globals
    DIM ShareD stack$(20), dS&(20), iS%(20), top%
    '    globals for refresh
    DIM ShareD nr%(3)    'file name rectangle

'--------------------------------------------------------
    '   set up variables and draw window
    w% = 395 : h% = 80    'window width & height
    SetRect nr%(0),10,30,w%-10,h%-10
    l% = (SYSTEM(5)-w%)\2 :t% = (SYSTEM(6)-h%)\4
    WindOW 1,"Find File",(l%,t%)-(l%+w%,t%+h%),6
    refresh
    TextFont 3 :Edit FIELD 1,"",(54,7)-(w%-70,21),5

'--------------------------------------------------------
    WHILE 1    'main event loop
        d% = DialoG(0)
        SELECT CASE d%
        CASE 0 'do nothing
        CASE 4 :END    'window closed: quit
        CASE 5 :refresh    'refresh
        CASE 6 'carriage return pressed in edit field
            Tedeactivate WindOW(6)    'disable the edit field
            t$ = Edit$(1)    'get file name to look for
            TextBox "", nr%(0), 0
            find t$,found%
            IF found% THEN BEEP ELSE BEEP:BEEP:t$ = t$ + " Not Found"
            TextBox t$, nr%(0), 0
            Teactivate WindOW(6)    'enable the edit field
            TeSetSelect 0,32767,WindOW(6)    'select all
        CASE ELSE   'ignore anything else
        END SELECT
    WEND
    END

'--------------------------------------------------------
'    refresh
'    Draw window contents
'
SUB refresh STATIC
    LINE (54,6)-(WindOW(2)-69,22),,b
    InsetRect nr%(0), -2,-2
    FrameRect VARPTR(nr%(0))
    InsetRect nr%(0), 2,2
    TextFont 0 :TextFace 0
    MoveTo 10,18 :drawText "Find:"
    TextFont 3
END SUB

'--------------------------------------------------------
'    Find
'
'    Find first file with simple name s$.
'    returns found% = -1 if found, else 0.
'        s$ = full path name if found
'
'    This program searches alphabetically through the
'    file system, descending each directory as it is
'    encountered until a case-insensitive match is found.
'    Searching stops at the first match.
'
SUB Find( s$, found% ) STATIC
    ChangeCursor 4 :ShowCursor
    ptr& = &H352    'pointer to default Volume Control Block
    vol& = PEEKL(ptr&)
    found% = FALSE
    WHILE vol&<>0 AND NOT found%

        '    follow pointers through list of mounted volumes
        vol& = PEEKL(ptr&) :ptr& = vol&
        IF vol&<>0 THEN    'null pointer at end of list

            '    get volume name and initialize IOPB%
            dirID& = 0
            n$ = ""
            vRefNum% = PEEKW(vol& + 78)
            GetCatInfo IOPB%(0), n$, dirID&, vRefNum%

            '    search volume
            initStack
            push n$, dirID&, 1

            WHILE top% >= 0 AND NOT found%
                dir ok%,iS%(top%),dS&(top%),n$,directory%
                IF ok% THEN
                    iS%(top%) = iS%(top%) + 1
                    IF directory% THEN
                        dirID& = PEEKL(VARPTR(IOPB%(24)))
                        push n$, dirID&, 1
                    ELSE
                        IF UCASE$(n$) = UCASE$(s$) THEN
                            s$ = n$ :getPath s$
                            found% = TRUE
                        END IF
                    END IF
                ELSE    'finished searching this directory
                    pop    'go back to where we left off
                END IF
            WEND

        END IF    'vol& <> 0
    WEND    'vol& <> 0
    InitCursor
END SUB

'--------------------------------------------------------
'    dir
'
'    Produces a listing of the directory specified by dirID&.
'
'    Start repeated calls to dir, starting with index% = 1.
'    Repeat calls to dir (incrementing index% each time) until
'    dir returns 0 (False) in ok%.
'    For each call, dir returns the name of the file or directory in
'    n$.
'
'    ok% = -1 if more files/directories, 0 if no more
'    index% = index
'    dirID& = directory ID number
'    n$ = file/directory name
'    directory% = -1 if directory, 0 if a file
'
'    Could be modified to return more information about the file
'    such as the creator and file type. See Inside Macintosh Vol. 4
'
SUB dir( ok%, index%, dirID&, n$, directory% ) STATIC
    n$ = String$(32,0)    'maximum simple file name
    POKEL VARPTR(IOPB%(9)), SADD(n$)    'init string pointer
    IOPB%(14) = index%    'set index
    POKEL VARPTR(IOPB%(24)),dirID&    'set directory ID
    HFSDispatch 9,IOPB%(0)    'GetCatInfo

    ok% = IOPB%(8) = 0    'check result code ( 0 = noErr )
    IF ok% THEN
        n$ = MID$( n$, 2, ASC(n$) )    '-> Basic string
        '    set directory flag (attributes, bit 4)
        directory% = ( PEEK(VARPTR(IOPB%(15))) AND 16 ) = 16
    END IF
END SUB

'--------------------------------------------------------
'    stack utilities
'    assume OPTION BASE 0
'
SUB initStack STATIC
    top% = -1
END SUB

SUB push( x$, l&, i% ) STATIC
    IF top%>UBOUND(stack$) THEN BEEP :PRINT "Stack overflow" :END
    top% = top% + 1
    stack$(top%) = x$
    dS&(top%) = l&
    iS%(top%) = i%
END SUB

'        We never need popped contents in this program, so pop just
'        decrements the stack pointer.
SUB pop STATIC
    IF top% < 0 THEN BEEP :PRINT "StringStack underflow" :END
    top% = top% - 1
END SUB

'--------------------------------------------------------
'    getPath
'    Prepend colon-separated stack contents to p$
'    without changing the stack.
'
SUB getPath( p$ ) STATIC
    FOR j% = top% TO 0 STEP -1 :p$ =  stack$(j%) + ":" + p$ :NEXT
END SUB
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB35509


BUG: Binary QuickBasic Default Compiled Exponent (^) Bad (35516)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    In programs compiled with Microsoft QuickBasic (b) (binary math) Version 1.00, a constant that is the object of the exponential operator (^) does not assume double precision when assigned to a double-precision variable. As a result, the exponential calculation is only accurate to single precision.

    To work around the problem, you can append an explicit type symbol of &, #, or ! onto the exponential constant, as shown below, or compile with Microsoft QuickBasic (d) (decimal math). The problem does not exist in the interpreter or in the Microsoft Basic Compiler 1.00 for the Macintosh .

    Microsoft has confirmed this to be a bug in the Microsoft QuickBasic Compiler (b) Version 1.00 for the Macintosh . We are researching this problem and will post new information as it becomes available.

    More information

    The following program correctly returns 1.52399025D-20 in the interpreter but gives 1.52399094076451D-20 when compiled, which is only accurate to single precision. However, if an exponent of 2&, 2#, or 2! is used, the compiled program correctly returns 1.52399025D-20, which is accurate to double precision.
    DEFDBL a-z
i = .00000000012345#
PRINT i^2
REM  As a workaround, you may use PRINT i^2#
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: kbbug KB35516


Memory Map Correction for Mac QuickBasic Compiled Applications (35626)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article provides a corrected and more detailed memory map for applications compiled by Microsoft QuickBasic 1.00 for the Apple Macintosh.

    This update/correction applies to Appendix F, "Memory Usage," on Pages 527-529 of the "Microsoft QuickBasic for Apple Macintosh: Basic Language Reference" manual.

    More information

    If you are having trouble using the CLEAR statement to enlarge the stack or data areas to eliminate "Out of Memory" messages or other memory problems, you should base the arguments for the CLEAR statement on the values returned by the FRE(n) function (at run time), instead of specifying absolute numbers. There should only be one CLEAR statement per program.

    Note that you should not assume that the screen and sound buffers will be in any specific location, since this may change in future implementations of the Macintosh hardware or operating system. In addition, you should not assume that the memory for the buffers is contiguous with the application space, the stack, and the application heap. In the future, the stack may move as well.

    The following is the revised Macintosh memory map:
           *******  Overall Macintosh Memory Map  *******

OS-dependent--> +----------------------------+
                |  Screen and Sound Buffers  |
                +----------------------------+

High Memory --> +-----------------------------+
                |      ROM Support            |
                |   Segment jump table        |
                +-----------------------------+
                |      Quickdraw Globals      |
register(a5)--> +-----------------------------+
                |    Application Globals      |
                +-----------------------------+
                |                             |
                |       Stack                 |
                :                             :
                :.............................:
                :                             :
                |       Heap                  |
                |                             |
Low Memory--->  +-----------------------------+

***** Memory Map for a Macintosh QuickBasic Compiled Application ****
    The stack is stored in high memory, as shown in the memory map below. The stack in highest memory is set at compile time, and contains main program variables, variables in ShareD statements, variables in COMMON, and array descriptors. The remainder of stack is used dynamically at run time for GOSUB statements and subprogram calls.

    The statement CLEAR,,<StackSize> changes StackLimit (StackLimit is shown in the map below). The stack grows downward in memory. If the stack pointer goes below StackLimit, an "Out of Memory" error should be reported; however, the stack overflow can go undetected if you compile without the "Check Arrays and Overflow" option.

    FRE(-2) returns the value of CurrStack minus StackLimit, where CurrStack is the current value of the dynamic stack at the time FRE(-2) is invoked. The value returned by FRE(-2) is only an estimate, since the stack changes from moment to moment.

    When dynamic subprograms are active, there is another link frame for each active invocation of a dynamic subprogram below the one link frame for the main program. Each additional link frame contains the local variables for the dynamic subprogram.
    High--------->  +-------------------------------+  <----+
Memory          |   Common Variables            |       |
                |                               |       |
       +----->  |...............................|    Main/ShareD
       |        | Other main program variables: |      program
    one link    |  All simple variable data,    |     variables
     frame      |    static arrays, string      |     in fixed
       |        |   descriptors, and array      |   block in Stack
       |        |        descriptors.           |       |
       |        |                               |       |
       +----->  +-------------------------------+  <----+
                :                               :
                :    ---- Dynamic Stack ----    :
                :                               :
CurrStack---->  :...............................:
                :                               :
StackLimit  --> :...............................:
                :                               :
    The heap comes next in memory, as shown below. A number of blocks are allocated out of the heap. The relative location of one block to another in the heap is unpredictable since they are allocated by the Macintosh Memory Manager, but the ordering of the blocks tends to be as shown:
                    :                               :
 Top (End)      :                               :
  of Heap  ---->:...............................:
                :                               :
                :    ----- Free Heap -----      :
                :                               :
    The statement CLEAR ,<Data> changes the size of the compiled program's Data block (shown below). You get an "Out of Memory" message at run time if the value for <Data> would deallocate some of the compiled program's machine code. The area that remains over after Data and Stack space are allocated is available for heap space.
                    :                               :
                +-------------------------------+  <--+
                |    String space & DATA        |     |
                |...............................|     |  Compiled
                | File Buffers & Array Contents |     |   Basic
                |...............................|     |-- Data
                |       Machine code for        |     |   block
                |       compiled program        |     |
                +-------------------------------+  <--+
                :                               :
    Note that the Static Subprogram Storage and Basic Run-time Library Private Storage blocks (shown below) are just one block in the earlier Microsoft Basic Compiler 1.00. In QuickBasic compiled programs, they are split for better memory management during CHAIN and RUN:
                    :                               :
                +-------------------------------+
                |   Static Subprogram Storage   |
                |        block                  |
                +-------------------------------+
                :                               :
                +-------------------------------+
                |  Block for Basic Run-time     |
                |  library private variables    |
                +-------------------------------+
                :                               :
    The Run-time Library block (shown below) is allocated by a GetResource(MBRL) call from the program's initialization code during startup before the program starts executing:
                    :                               :
                +-------------------------------+
                |   Run-time Library            |
                |   machine code block          |
                +-------------------------------+
                :                               :
    The Initialization block (below) is loaded when the compiled application is launched. The code that handles the MBPN (File Not Found) processing is also in this block:
                    :                               :
                +-------------------------------+
                |  Initialization machine code  |
                |  block (Code resource ID = 1) |
                +-------------------------------+
                :                               :
Bottom of  ---> +-------------------------------+
(start of)
Application Heap. Low memory.
    Libraries, MBPC resources, Code resources, MBLC resources, and other Macintosh objects (resources and toolbox data structures) are allocated as necessary in any portion of the heap that is free. In the above memory map, free memory could be in any of the areas not marked as a "block."

    FRE(-1) returns the total number of bytes not being used by these blocks and not used by other Macintosh objects. You Cannot assume that there is one big block of size FRE(-1) because the free memory can be interleaved with locked blocks. FRE(-1) will cause the Memory Manager to compact the heap as much as possible before returning the total available memory. See Inside Macintosh for more information about the Macintosh Memory Manager.

    FRE(n), where n is not equal to 0 or 1, returns the number of unused bytes in the Basic data block. Of course, the machine-code portion of the block is never free. FRE(n) accurately reflects the amount of space available for new strings, dynamic arrays, and file buffers.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB35626


"Out of Data"; Incorrect CALL Example Mac QuickBasic Page 61 (35657)

Summary

The example for the CALL statement on Page 61 of the "Microsoft QuickBasic for Apple Macintosh: Basic Language Reference" manual is incorrect. The example produces an "Out of data" error because the condition for the WHILE... WEND loop is "A <> -1"; however, there is not a data statement that sets A equal to -1. The following additional line needs to be added at the end of the code:

DATA -1

More information

The example is still not a very good one even with the "DATA -1" statement, because you cannot substitute machine-language code that contains a literal value of -1. The machine-language routine would only be read in up to the first "-1", and the resulting partial machine-language routine would probably hang (crash) when invoked.

The example should be rewritten to read the machine code as strings first, since there is no number that cannot appear in machine code. That way, we can signal the end with the string "END", and the same Basic statements can be used to read any machine language.

The following is a code example:
DIM code%(50)    'big enough to hold all our machine code

'    this loop can be used to read in ANY machine code
REStore myCodeData
i% = 0 : a$ = ""
WHILE a$ <> "END"
    READ a$
    IF a$ <> "END" THEN code%(i%) = VAL(a$) :i% = i% + 1
WEND

myCodeData:
DATA ...
     ... machine code defined as hex constants
     ...
DATA "END"    :'**   End of machine-language routine   **
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB35657


QuickBasic "Device I/O Error" Using CloseResFile on Source (35659)

Summary

There is a correction for the "Note" in Section E.6.2, "Resource Files," on Page 435 of the manual "Microsoft QuickBasic for Apple Macintosh: Basic Language Reference." The "Note" should be changed to read as follows:

"It is dangerous to close the resource fork of a currently running program."

This means that you should Never perform CloseResFile on the file reference number of a currently running program; otherwise, you can get "Device I/O Error" in the QuickBasic environment and/or eventually lose your interpreted source file. If you need to write resource changes to the resource fork of a currently running (or loaded) program, perform UpdateResFile instead of CloseResFile.

More information

Note that you can open external resource files with the OpenResFile statement, and close them with the CloseResFile statement. However, you should never need to perform OpenResFile on the currently running program, since it is already open, and the SYSTEM(7) function returns its file reference number.

The SYSTEM(7) function returns the file reference number of the resource fork of the program source file when the program is interpreted. SYSTEM(7) returns the file reference number of the application resource fork in a compiled application. A common programming practice is to store user-defined resources in their own resource fork instead of in a separate resource file.

You are allowed to perform CloseResFile on any resource file other than a currently running program. However, UpdateResFile must be used instead of CloseResFile to write resources to currently running (or loaded) program files.

You should Never perform a CloseResFile statement using the number returned by SYSTEM(7). In interpreted programs, you can cause a "Device I/O Error" at save time if you previously did a CloseResFile on the resource fork of the source file or of QuickBasic itself. This can put garbage in the "QuickBasic Settings" file in your System Folder. To clean up the QuickBasic settings, drag the "QuickBasic Settings" file into the trash on the desktop.

It is also possible to hang QuickBasic with a program that closes QuickBasic's or its own resource fork. If in doubt, use UpdateResFile instead of CloseResFile to write resource changes to disk.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB35659


DO LOOP and EXIT WHILE Not Supported in Macintosh QuickBasic (35660)

Summary

This article describes two corrections to the "Microsoft QuickBasic for Apple Macintosh: Basic Language Reference" manual, Pages 154-155.

  1. The example for the IF ... THEN ... ELSE statement on Page 154 incorrectly contains a DO ... LOOP, which is not supported in QuickBasic for the Macintosh (or in previous versions of Basic for the Macintosh). EXIT DO also is not supported. The example program gives a "Syntax Error" for the unsupported statements.

    You can substitute a WHILE ... WEND statement for the DO ... LOOP statement, as follows:
       X=-1
   WHILE X<=0 OR X >= 10000
   INPUT "Enter a number greater than 0 and less than 10,000:",X
   IF X<=0 OR X >= 10000 THEN PRINT "Out of range."
   WEND
  2. The example on Page 155 mistakenly uses an EXIT WHILE statement, which is not supported. This program gives a "Syntax Error" on the EXIT WHILE statement.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB35660


@, ], and [ Do Not Have Special Meanings in Mac QuickBasic (35661)

Summary

Page 8 of the "Microsoft QuickBasic for Apple Macintosh: Basic Language Reference" manual incorrectly states that the following characters have special meanings in Basic statements and expressions:

@
[
]

These characters do not have any special meaning for QuickBasic (or previous versions of Microsoft Basic) for the Macintosh and should not be included in the list. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB35661


"Clip: " Clipboard Contents Not Available Across MultiFinder (35712)

Summary

When you OPEN and write to the "Clip:" device in a QuickBasic program, the contents of the clipboard may not be carried over when you switch to another application under Apple MultiFinder.

To ensure that the contents of the clipboard are available across a context switch in MultiFinder, you need to call the ROM trap SystemEdit with the appropriate argument after every Edit operation (including Undo, Cut, Copy, Paste, Clear, or output to the "Clip:" device name):
   Operation   Argument

   Undo        0
   Cut         2
   Copy        3
   Paste       4
   Clear       5

More information

The program below calls the SystemEdit ROM trap after copying a sentence into the clipboard. This ensures that the contents of the clipboard are available to other applications when you switch to them under MultiFinder.

The program is as follows:
    ToolBox "i"         'initialize ToolBox
    SystemEdit% = &H9C2    'SystemEdit trap word
    b% = 0    'SystemEdit returns a boolean (b%) that's useless to a
              'Basic program but a dummy value needs to be passed
    OPEN "clip:" FOR OUTPUT AS #1
    PRINT #1, "This goes in the clipboard"
    CLOSE #1
    ToolBox "BQ", SystemEdit%, 3, b%
    IF OSerr& THEN
       BEEP
       PRINT "Couldn't Update System Clipboard"
    ELSE
       PRINT "System Clipboard updated."
       PRINT "You may now switch applications in MultiFinder."
    END IF
The need to call the SystemEdit ROM trap for applications (such as QuickBasic) that do not accept suspend/resume events from MultiFinder is documented in "Macintosh Technical Note #180: MultiFinder Miscellanea." This Note is available from Apple Computer.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB35712


SubLaunch May Not Work in MultiFinder, but Works in Finder (35717)

Summary

Under the Apple Finder, the SubLaunch routine will remove the launching program from memory before loading the launched application.

Under Apple MultiFinder, the SubLaunch routine keeps the launching program in memory in addition to the launched application.

Therefore, invoking SubLaunch under MultiFinder can require a lot of memory because both the launched and launching applications will be in memory at the same time. If there is not enough memory to load the SubLaunched application, the launching program will continue at the next statement and the specified application will not be launched.

More information

SubLaunch is an MBLC library routine in QuickBasic that transfers control to another specified application. When the launched application terminates, it returns to the launching program.

We recommend that you use the FILES$(1,"Appl") function to select the application to SubLaunch to be sure that the path and file type are correct.

Warning: SubLaunch does NOT verify that the program exists, or is actually an application. If the name specified is not a type Appl file or does not exist in the specified location, you will get a system bomb. SubLaunch does NOT automatically flush file buffers or close open files. We recommend that you perform a CLOSE or RESET before invoking SubLaunch. You also should make sure any open resource files are closed.

Microsoft also recommends using SubLaunch instead of the Transfer ROM routine because Apple no longer supports the Transfer routine. Transfer may not work correctly under versions of the Macintosh System from Apple later than Version 4.20. Transfer is being replaced by SubLaunch.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB35717


FOR with Conditional IF...Then NEXT Causes Problems (35718)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Executing an isolated NEXT statement within a block IF...END IF statement produces an error in the Macintosh QuickBasic interpreter; however, it will compile and run.

    Executing the NEXT statement without the matching FOR in the same IF statement is a bad programming practice because it may cause problems with the stack. This practice can cause the stack to overflow and generate a memory error, or cause the program's flow of control to branch incorrectly. (In the interpreter, the stack keeps track of where to return when a loop is finished.)

    The NEXT statement should never be executed conditionally in a single-line or block IF...END IF statement. It is easy to find an alternative flow-of-control structure that performs the same logic.

    More information

    The following are error messages you are likely to encounter in the interpreter when attempting to conditionally execute a NEXT statement.
    IF without END IF
    WHILE without WEND
    FOR without Next
    CASE without SELECT CASE
    ELSE/ELSEIF/END IF without IF
    The following is a code example that will give an "IF without END IF" error message in the interpreter, but will successfully compile and execute:
    '    **** This is an example of BAD ProgRAMMING ****
FOR loopme = 1 to 2
    '    conditionally begin inner loop
    IF loopme = 1 THEN FOR i = 1 TO 5

    PRINT loopme; i; "Hi there."

    '    conditionally end inner loop
    IF loopme = 1 THEN    '(interpreter error here)
        NEXT i
    END IF
NEXT loopme
    This example works in both environments if both IF statements are single-line IF statements. However, this unstructured programming practice may not be supported in future versions of Macintosh Basic.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB35718


Macintosh QuickBasic May Load Wrong or Unexpected File (35719)

Summary

In a certain situation, QuickBasic may open an unexpected file.

If you sublaunch a compiled program with the "Launch After Compiling" option in QuickBasic and the compiled program crashes with a system error or you restart the machine before the program quits, QuickBasic will load the source file of the interrupted compiled program the next time you run QuickBasic. The crashed program's source is loaded even if you double-click a different source file, or you just start QuickBasic from the Finder. This process is surprising but harmless.

Before a compiled application is sublaunched, a file called "QuickBasic Resume" is created in the System folder to remember which source file QuickBasic was working with. When QuickBasic is started (whether returning from a sublaunch or being launched from the finder), it looks for the "QuickBasic Resume" file in the system folder. If the file is there, QuickBasic opens the specified source file and deletes the "QuickBasic Resume" file. If QuickBasic can't find the "QuickBasic Resume" file, it looks to see if a file was double-clicked in the Finder.

More information

If the source file of the sublaunched, compiled, and crashed program was saved in Text format, it will load the next time you run either Microsoft QuickBasic (b) or (d). Each version of QuickBasic can read only it's own compressed format (binary or decimal). Thus, if you start the other version of QuickBasic after the crash of a sublaunched program, and the file was saved as compressed, the file will not be loaded.

The "QuickBasic Resume" file is created only when automatically sublaunching a newly compiled application. It is not created when you use the Sublaunch library routine in a program or the command window.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB35719


Changing QuickBasic's Size Resource to Help "Out of Memory" (35720)

Summary

QuickBasic will produce an "Out of Memory" error if you attempt to open a very large source file.

As mentioned in the Readme.Doc file, Macintosh QuickBasic initially allocates about one-third of the memory listed in its Size resource to the data area (default data area is about 100K). Because the QuickBasic interpreter loads your program into the data area, programs larger than about 100K can produce an "Out of memory" error.

To correct this problem, change the Size resource of Microsoft QuickBasic (b) or (d) with either of the following:
  1. ResEdit
  2. "Get Info" (Command-I) from the File menu in the desktop of Apple MultiFinder, or System Version 6.00 or later

More information

For the data area, QuickBasic sets aside about one-third of the value specified for the application size in the QuickBasic Size resource. The amount of memory QuickBasic allocates can be changed by altering the Size resource. The Size resource is in the resource fork of Microsoft QuickBasic (b) or (d).

If you use Apple Multifinder, or Finder Version 6.1.0 or later, the application memory size can be set by selecting QuickBasic and executing a "Get Info" (Command-I) from the desktop File menu.

You also may make this change with ResEdit. Open QuickBasic, and double click Size in the resource list. If there is a Size id = 0, open it, otherwise there will only be a Size id = -1. The memory size information is at the very bottom of this resource, so scroll all the way to the end. The units are in bytes, rather than 1024 bytes (k) as displayed in the Get Info window.

To estimate the size required, multiply the size of your source file by three and add 100k.

Under MultiFinder, this is the size of the memory partition the application resides in and can access. If there is not enough free memory to allocate the amount specified in Application Memory Size, the Suggested Memory Size is used. If there is not enough free memory to satisfy this process, MultiFinder will not start the application. The Finder does not use the Size resource.

Warning: If you change the size to something larger than the memory on your machine, you may get a system error when you start QuickBasic. If this error occurs, change the memory size to something smaller.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB35720


Explanation of Resources Stored in Macintosh QuickBasic 1.00 (35762)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article explains the resources that are stored in the resource fork of Microsoft QuickBasic (b) or (d) Version 1.00 for Apple Macintosh.

    When you run ResEdit and open Microsoft QuickBasic (b) or (d), you will see a list of resource types. You can change some of these resources to customize QuickBasic. Please note that customizing QuickBasic can be risky because it requires modifying QuickBasic itself. The following are some possible changes:

    1. Define or change Command-key equivalents for QuickBasic's menu items.
    2. Change run-time error messages.
    3. Define new page sizes for the printer.
    4. Change the creator type of QuickBasic so the Finder can distinguish the desktop icons of QuickBasic's files from the icons of earlier versions of the Basic Interpreter (2.00, 2.10, and 3.00). For a separate article describing the change, search on the following words:

      icon and MSBB and MSBA

    More information

    Note that the Finder uses the BNDL, ICN#, Fref, MSBB (or the lowercase msbb), and MSBA (or the lowercase msba) resources to give appropriate icons to QuickBasic and the files created by QuickBasic.

    The following is an alphabetically-ordered list of the resources that are stored in the resource fork of Microsoft QuickBasic (b) and (d) Version 1.00 for Apple Macintosh:
      Name     Description
   ----     -----------

   BNDL    Bundle resource.
           id# 128 standard bundle.
           id# 129 alternate bundle.
           The alternate bundle is automatically used if the creator
           type of QuickBasic is changed to msbb (for binary
           QuickBasic) or msba (for decimal QuickBasic) (lower case is
           required). You may wish to change QuickBasic's creator type
           if you plan to use both QuickBasic and an older version of
           Microsoft Basic Interpreter on the same disk.

   Code    QuickBasic Interpreter Code.

   Curs    Stopsign Cursor used in QuickBasic interpreter breakpoints.

   Ditl    Dialog ITem Lists.

   Dlog    DiaLOG. The Ditl and Dlogs are used together for
           QuickBasic's various dialogs.

   Fref    File REFerence.

   ICN#    ICoN list. Icons for QuickBasic's files and the QuickBasic
           application.

   Icon    Icons used in QuickBasic's animated dialog that displays
           whenever you compile a program.

   MBAB    Application BNDL.

   MBAF    Application Fref.

   MBAI    Application ICN#.

   MBCB    Application signature resource. The MBAB, MBAF, MBAI, and
           MBCB resources are copied to the resource fork of the
           compiled application, and their type is changed to BNDL,
           Fref, ICN#, and MBCB, respectively.

   MBCC    Compiler Code.

   MBCO    Default Compiler Options.

   MBCS    Compiler extenSions. Filename extensions for compiler
           output files: lst, sym, and apl. Warning: these are NOT
           Pascal strings, and your computer may hang if you Open
           As... STR in ResEdit. Instead, just double-click to open
           the desired extension resource, then click in the text area
           of the dump. You may simply type the desired extension.

   MBCV    Compiler number.

   MBKI    Keyword Information. Resources of type MBKI are named
           resources that contain the information that is displayed
           when you select Get Info... from the Search menu in
           QuickBasic for help concerning a QuickBasic statement. To
           edit one, select Open As... in ResEdit, and select STR.
           This allows you to add multiple lines to the information.
           Since these are Pascal strings, they are limited to 255
           characters.

   MBLC    Library Code. This resource contains library routines (for
           example, the ToolBox and DrawText statements). These are
           automatically copied to the resource fork of a compiled
           application if the "Include MBPCs & MBLCs" compiler option
           is selected in the Options... dialog box in the QuickBasic
           Run menu.

   MBNC    Null Code. MBNC resources become the Code resources of an
           application that did not compile successfully. This code
           quits as soon as it starts.

   MBPC    Pure Code. There is just one Pure Code resource shipped
           with QuickBasic: the Eject routine. MBPC executable
           resources may be created with other high-level languages.
           These are automatically copied to the compiled application
           if the "Include MBPCs & MBLCs" compiler option is selected
           in the Options... dialog box in the QuickBasic Run menu.

   MBRL    Run-time Library, which contains support code necessary to
           make a compiled QuickBasic program run. The appropriate
           QuickBasic run-time library is automatically copied to the
           resource fork of the application if the "Include The
           Runtime Code" compiler option is selected in the Options...
           dialog box in the QuickBasic Run menu. There are three
           different run-time libraries: Decimal Math; Binary Math;
           and 68881 Coprocessor Binary Math.

   MBSC    Startup Code.

   MBTI    Toolbox Information. Named resources with a type of MBTI
           contain the information that is displayed when you select
           Get Info... from the Search menu in QuickBasic for help
           concerning the toolbox library and ROM routines. You may
           edit these the same way you do MBKI resources, selecting
           Open As... STR in ResEdit.

   MBTS    ToolBox Syntax. This is the type-checking resource used by
           the ToolBox statement. (Note that the "ToolBox" statement
           is a routine of type MBLC). The QuickBasic User's Guide
           contains instructions on editing the MBTS resource to
           provide type checking for more ROM traps.

   Menu    QuickBasic's menu templates. You may edit this resource to
           add or change command key equivalents for QuickBasic's
           menus. You cannot change the hidden command keys like
           OPTION+Command+I and OPTION+Command+K, you can only change
           the ones where a command key is listed in the menu item.
           The following are some additions that you may find useful:

           Command Key  Menu item
           -----------  ---------

           N            New
           OPTION+F     Find Next (appears as a script 'f')
           P            Print...
           =            Find Selected text (find equivalent text)
           A            Save As...
           \            Options... (or use - or / which are traditional
                                   option symbols in other environments)

           The ID numbers for QuickBasic's menus are as follows:

           Menu           Menu ID
           ----           -------

           Apple          256
           File           262
           Edit           258
           Search         259
           Windows        260
           Run            261
           File (runtime) 257

   MSBB    Microsoft Basic signature resource for binary math version.
           This resource contains a Pascal string that is displayed
           when you highlight Microsoft QuickBasic (b) on the desktop
           and choose Get Info... from Finder's File menu.

   msbb    Alternate signature resource for binary math version. This
           is automatically used when the creator type of QuickBasic
           (b) is changed to lowercase msbb.

   MSBA    Microsoft Basic signature resource for decimal math
           version. This resource contains a Pascal string that is
           displayed when you highlight Microsoft QuickBasic (d) on
           the desktop and choose Get Info... from Finder's File menu.

   msba    Alternate signature resource for decimal math version. This
           is automatically used when the creator type of QuickBasic
           (d) is changed to lowercase msba.

   Prec    PRint RECord. This resource may be edited to define
           different page sizes. This lets you print mailing labels or
           checks more easily. This resource is automatically copied
           to the resource fork of your compiled application. The
           QuickBasic user's guide contains more information about
           changing this resource.

   Size    MultiFinder memory allocation information. This may be
           changed to enable QuickBasic to load larger source files.
           The Readme file on the distribution disks contains more
           information about changing this resource.

   STR     STRing resources, such as error messages, etc. Note that
           the type "STR " has a space character after the R. These
           are Pascal strings.

   vers    QuickBasic number. (Note that "vers" is lowercase.)

   Wind    Default Window templates.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB35762


Basic Can't Make Desk Accessory, Pure Code, or XCMD Resource (35810)

Summary

Because of the internal architecture of Microsoft QuickBasic 1.00 and the earlier Microsoft Basic Compiler 1.00 for the Macintosh, the compiler cannot create XCMD, XFCN, or other types of executable code resources; or Desk Accessories, Pure Code resources, Inits, CDEVs, or device drivers.

XCMD and XFCN are executable resource types that may be used to extend the functionality of Apple's HyperCard product.

As an analogy, note that MBPC executable resources can be used to extend the functionality of the QuickBasic language; however, the Basic and QuickBasic compilers themselves cannot create MBPC resources.

The MBPC, XCMD, XFCN, and Init resource types may be created with languages such as Assembly, C, and Pascal, but not with the Microsoft QuickBasic or Basic compilers. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB35810


SOUND WAIT Fails Without Multivoice Mode in Macintosh Basic (35829)

Summary

The SOUND WAIT and SOUND RESUME statements only work with multivoice mode. If SOUND WAIT and SOUND RESUME are used with single-voice sound mode in a compiled application, the system will hang when the sound queue overflows. In the interpreter, your program will stop, but you can press Command-PERIOD to return to the environment. The sound queue is limited by the Macintosh to 12 elements.

The easiest way to invoke multivoice mode is to use a Wave 0,SIN statement, or replace a Wave 0 statement with the Wave 0,SIN statement. The SOUND WAIT and SOUND RESUME statements will now work correctly, and the timbre or tone of the sound will be different.

More information

The above information should be added to the SOUND statement documentation in the "Basic Language Reference" manual in the following products:

  1. Microsoft QuickBasic 1.00 for Apple Macintosh
  2. Microsoft Basic Compiler 1.00 for Apple Macintosh
  3. Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for Apple Macintosh
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB35829


How to Obtain Names and Sizes of All Current Macintosh Fonts (35875)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    The program below shows how to list the names and sizes of all the fonts that are available in the current Macintosh System file. Note that you can add, remove, or also list the fonts in the System file by using Apple's "Font/DA Mover" program. Additional fonts are provided in files on Apple Macintosh System software disks.

    More information

    Microsoft Basic and QuickBasic for the Macintosh can access the fonts that are available in the System file by calling the TextFont ROM routine. PRINT statements will use the font number last specified by the TextFont routine as in the following example:
    TextFont 4 : TextSize 9 : PRINT "This is Monaco font."
    Apple Computer, Inc., has assigned numbers to all standard Macintosh fonts. Please refer to Page I-219 of "Inside Macintosh" Volume 1 (Addison-Wesley Publishing, 1985) for a list of fonts and their assigned numbers. For a complete list of fonts, you may contact Macintosh Technical Support at the following address:

    Macintosh Technical Support
    Mail Stop 3-T
    Apple Computer, Inc.
    20520 Mariani Ave.
    Cupertino, CA 95014

    The following is a code example that displays the current System fonts:
    ' Show Fonts.
' This program indexes through all the Fond (Font Description) resources
' which are installed in the current Macintosh System file, showing the
' name, family id, and unscaled sizes. This program runs as is in
' Macintosh QuickBasic. To run in the earlier Basic Compiler
' 1.00 or Interpreter Version 3.00, you will need to open the ToolLib
' library as follows:
' Library "Basic ToolBox:ToolLib"
DIM c%,h,t$,real%,id%,fontn$
Countres "Fond",c%   ' Count the number of Fond resources in System.
FOR i% = 1 TO c%
  '   Get font information:
  GetIndRes "Fond",i%,h
  GetResInfo h,id%,t$,fontn$
  ReleaseRes h
  MoveTo 5,WindOW(5)+20     'line spacing independent of font
  TextFont id%
  PRINT "Font ";fontn$;" id";id%;"Size";
  '   Find all unscaled sizes of this font:
  FOR j% = 1 TO 128
    RealFont id%,j%,real%
    IF real% THEN PRINT i%;
  NEXT
NEXT
WHILE Mouse(0)<>1:WEND    'wait for mouse click to end
    The following QuickBasic program also displays all the fonts, in their native (nonscaled) sizes, which are available in the current Macintosh System file. This program is not as simple as the above program, but it is provided as an example of using QuickBasic's ToolBox routine, which is not found in the earlier Basic Interpreter Version 3.00 or Basic Compiler 1.00:
    real% = 0
n$=""
FontName%=&HA8FF
ToolBox "I"
last%=0
maxSize%=24
maxFnum%=30000
WindOW 1,"Real Fonts",,1
TextFont 0:TextSize 12
PRINT USING "TextFont####] ";i%;
FOR i%=0 TO maxFnum%
     FOR j%=maxSize% TO 5 STEP -1
         realFont i%,j%,real%
         IF real% THEN
              ToolBox "P",FontName%,(i%),n$
              TextFont i%
              IF last%<>i% THEN
                    last%=i%
                    TextSize maxSize%
                    PRINT
                    TextSize 12 :PRINT USING "TextFont####] ";i%;
              END IF
              TextSize j%
              PRINT n$;J%;
              IF WindOW(4) > WindOW(2)-150 THEN PRINT
         END IF
     NEXT
NEXT
WHILE Mouse(0)<>1:WEND    ' Waits for mouse click to end.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB35875


Complete QuickBasic Program to Browse & Expand Get Info.. Help (35898)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    The "Help Edit" program further below lets you browse or modify the help information available in the Macintosh QuickBasic 1.00, 1.00a, or 1.00b environment. Unlike the Set Info... feature in the Search menu in QuickBasic, this program lets you embed carriage returns and Cut and Paste in the help box for a keyword. It also lets you conveniently add help information for all keywords at once. This program works either interpreted or compiled.

    This article was previously Pssonly because it exceeded the now-defunct 200- line practical limit for online services.

    This information applies to Microsoft QuickBasic 1.00, 1.00a, and 1.00b for Apple Macintosh Systems.

    More information

    This program, called "Help Edit", is a good demonstration of the following:

    1. Resource management
    2. Text editing
    3. Writing for both interpreted and compiled environments
    4. Handling refresh events
    To use the help feature of Macintosh QuickBasic, position the insertion pointer on any keyword in the List window and press Command+I (or select the Get Info... option on the Search menu). Command+I (or Get Info...) gives you the proper syntax for any selected QuickBasic statement or Toolbox call.

    The Set Info... option on QuickBasic's Search menu allows you to add additional help information for a Macintosh QuickBasic statement. However, Set Info... will not allow you to embed carriage returns, it only wraps to the next line after you have typed a complete line.

    The "Help Edit" program lets you easily expand QuickBasic's help information for any Basic statement, Toolbox call, or user-defined keyword. The "Help Edit" program lets you embed carriage returns in the help text. In "Help Edit", you may open Microsoft QuickBasic (b) or (d) (binary or decimal). The program lets you browse or modify the help information stored in the MBKI and MBTI resources in QuickBasic.

    The "Help Edit" program also lets you open a source file, if you have previously used Set Info... from the Search menu in QuickBasic to define help information for a user-defined keyword in a particular source file. In other words, the program lets you browse or modify the help information stored in MBUI resources (if any) stored in the source file.

    The following is the "Help Edit" program:
    '----------------------------------------------------------------
'    Help Edit
'    Copyright 1988 Microsoft Corp.
'
'    Microsoft does not make any warranty or claims for the
'    performance of this program. This program is for personal
'    use only, and may not be distributed in any form, electronic
'    or mechanical, for any purpose without the written permission
'    of Microsoft.
'
'    Warning:
'    This program may make changes to the resource fork of the
'    QuickBasic application. Use strictly at your own risk. Make
'    backups of your originals before using this program.
'
'----------------------------------------------------------------
'
'    Help Edit is useful to browse the available online help, as
'    well as make changes Set Info... (in Search menu) does not allow.
'
'    Open, or Command+O from the File menu allows you to open the
'    other QuickBasic or a QuickBasic source file so you can edit user
'    information.
'
'    A simple addition to make would be a Print option to print the
'    contents of a particular help item, or all the online help.
'
'----------------------------------------------------------------
ToolBox "i"

'    Global variables
DIM ShareD ref%     'current file reference number (usually QuickBasic)
DIM ShareD info$(300,1),ids%(300)    'info name,text & resource id
DIM ShareD r%(3)    'scratch rectangle
DIM ShareD max%     'number of info resources
DIM ShareD hit%     'selected info resource
DIM ShareD curType$ 'current res type, one of MBKI,MBTI,or MBUI
DIM ShareD sb%(3,1),sh&    'scrolling rectangles and scrollbar handle

'    Main level variables
DIM h&    'scratch resource handle
'    variables for hit testing: point, font info, and flag
DIM mousePt%(1),fi%(3),inRect%
Menu 1,0,1,"File"
Menu 1,1,1,"Open" :CmdKey 1,1,"O"
Menu 1,2,0,"-"
Menu 1,3,1,"Quit" :CmdKey 1,3,"Q"

IF SYSTEM(4) THEN
    '    compiled, so get user to find QuickBasic
    GetFile ff$, "Appl", "Please find QuickBasic for me"
    IF ff$ = "" THEN BEEP : END
    '    Use ToolBox OpenResFile to enable us to open another
    '    application, something the library OpenResFile forbids
    '    to protect programs from Code resource conflicts.
    ToolBox "WQ", &H997, f$, ref%
ELSE
    '    we're in the interpreter, so get CurApRefNum global
    ref% = PEEKW(&H900)
END IF

h% = 220 :w% = 400
l% = (SYSTEM(5)-w%)\2 :t% = (SYSTEM(6)-h%)\3
WindOW 1,"QuickBasic Help Editor",(l%,t%)-(l%+w%,t%+h%),5
TextSize 9 :TextFont 4 :GetFontInfo fi%(0)

r% = 32 * fi%(2)    'allow room for 32 char name
SetRect sb%(0,0),10,10,r%,h%-10
SetRect sb%(0,1),sb%(3,0)-1,sb%(0,0),sb%(3,0)+15,sb%(2,0)
l% = r%+25

Button 1,1,"Keyword Info",(l%,15)-(l%+110,30),3
Button 2,1,"Toolbox Info",(l%,35)-(l%+110,50),3
Button 3,1,"User Info",(l%,55)-(l%+110,70),3
Button 4,0,"Edit",(l%,h%-30)-(l%+100,h%-10),1
Button 6,1,"Quit",(w%-75,h%-30)-(w%-15,h%-10),1

'    turn on dialog and menu event trapping
ON DialoG GOSUB doDialog :DialoG ON
ON Menu GOSUB doMenu :Menu ON

NewScroll sh&,sb%(0,1),1,1,max%,0
FrameRect VARPTR(sb%(0,0))
top%=0
WHILE 1
    m% = Mouse(0) :IF m% THEN GOSUB doMouse
    ScrollText sh&,sb%(0,0),info$(1,0),top%,max%,hit%,0,0
WEND

'----------------------------------------------------------------
Quit:
    WindOW CLOSE 1
    DisposeScroll sh&    'always clean up heap entries
    '    Make sure just the right resource forks are closed
    '    before we quit--very important in the environment.
    IF ref%<>SYSTEM(7) AND ref%<>PEEKW(&H900) THEN CloseResFile ref%
    END

'----------------------------------------------------------------
doMenu:
    IF Menu(0) = 1 THEN
        SELECT CASE Menu(1)
        CASE 1    'Open
            f$ = FILES$(1,"TextMSBBMSBCAppl")
            IF f$ <> "" THEN
                '    if current resource file not the currently
                '    running program, close it
                IF ref% <> SYSTEM(7) AND ref% <> PEEKW(&H900) THEN
                    CloseResFile ref%
                END IF
                '    Use ToolBox OpenResFile so we can open Appls.
                ToolBox "WQ", &H997, f$, ref%
                IF curType$ <> "" THEN LoadInfo curType$
            END IF
        CASE 3    'Quit
            GOTO Quit
        CASE ELSE :BEEP
        END SELECT
    END IF
    Menu
    RETURN

'----------------------------------------------------------------
'    doMouse
'    Mouse click handler
'
doMouse:
    '    handle only single or double click
    IF m% = 1 OR m% = 2 THEN
        GetMouse mousePt%(0)
        PtInRect mousePt%(0),sb%(0,0),inRect%    'in text area?
        IF inRect% THEN
            '    calculate clicked row
            hit% = (mousePt%(0)-sb%(0,0))\(fi%(0)+fi%(1)) + top%
            IF hit% > max% THEN hit% = max%    'check if past end
            top% = 0     'force redraw at next ScrollText
            Button 4,1   'enable "Edit" button
        END IF
        IF m% = 2 THEN CALL EditInfo    'Edit info if double clicked
    END IF
    RETURN

'----------------------------------------------------------------
'    doDialog
'    dialog event handler
'
doDialog:
    SELECT CASE DialoG(0)
    CASE 1    'button clicked
        SELECT CASE DialoG(1)
        CASE 1    'KeyWord Info
            Button 1,2 :Button 2,1 :Button 3,1
            curType$ = "MBKI" :LoadInfo curType$
        CASE 2    'Toolbox Info
            Button 1,1 :Button 2,2 :Button 3,1
            curType$ =  "MBTI" :LoadInfo curType$
        CASE 3    'User Info
            Button 1,1 :Button 2,1 :Button 3,2
            curType$ =  "MBUI" :LoadInfo curType$
        CASE 4 :EditInfo    'Edit button
        CASE 6 :GOTO Quit   'Quit button
        END SELECT
    CASE 5    'refresh
        FrameRect VARPTR(sb%(0,0)) :top% = 0
    CASE ELSE
    END SELECT
    RETURN

'----------------------------------------------------------------
'    LoadInfo
'    Scan the resource file for tt$ type resources, loading the
'    names into array info$(i,0), the text of the info into
'    info$(i,1), and the resource id number into ids%(i). The number
'    of resources loaded is set in max%. LoadInfo loads Copies of the
'    resources, not the actual resources.
'
SUB LoadInfo(tt$) STATIC
    h& = 0 :type$ = "" :max% = 0
    ChangeCursor 4
    '    load the info
    CountRes tt$, max%
    FOR i% = 1 TO max%
        GetIndRes tt$, i%, h&
        GetResInfo h&, ids%(i%), type$, info$(i%,0)
        HandleToString h&, info$(i%,1)
        ReleaseRes h&
    NEXT
    '    erase the scroll area
    InSetRect sb%(0,0),1,1
    EraseRect VARPTR(sb%(0,0))
    InSetRect sb%(0,0),-1,-1
    '    define scroll bar with the new maximum
    DisposeScroll sh&
    NewScroll sh&, sb%(0,1), 1, 1, max%, 0
    InitCursor
END SUB

'----------------------------------------------------------------
'    EditInfo
'    Displays a dialog with the same dimensions as the information
'    dialog in QuickBasic.
'
'    Unlike Set Info... in QuickBasic's Search menu, EditInfo
'    allows carriage returns, and Cut, Copy, and Paste. EditInfo
'    does not allow you to enter more than 255 characters.
'
'    If the information has been changed, the resource is updated on
'    disk when the dialog is terminated.
'
SUB EditInfo STATIC
    wp& = 0 :pict& = 0
    DialoG OFF
    WindOW 2,info$(hit%,0),(41,70)-(471,282),5
    GetWindow wp&

    SetRect r%(0),41,70,471,282    'init refresh picture rect
    OpenPicture r%(0), pict& : ShowPen    'record refresh pict
    TextFont 0
    SetRect r%(0),38,176,100,197  : TextBox "Info for",r%(0),0
    SetRect r%(0),100,176,271,197 : TextBox info$(hit%,0),r%(0),0
    LINE (8,7)-(417,169),,b
    Button 1,1,"OK",(360,176)-(416,197),1
    Button 2,1,"Cancel",(280,176)-(340,197),1
    ClosePicture : HidePen    'stop recording refresh picture
    SetWindowPic wp&,pict&    'attach refresh picture to window

    Edit FIELD 1,info$(hit%,1),(10,8)-(416,168),6
    ef& = WindOW(6)    'cache edit field handle

    d% = DialoG(0)
    WHILE d% <> 1    'wait for button click
        '    Monitor length of text:
        '    If length of text overflows a Pascal string, then cut the
        '    extra just before the insertion point.  This will be the
        '    text just typed.
        TElength% = PEEKW( PEEKL(ef&)+60 )
        IF  TElength% > 255 THEN
            BEEP
            c% = PEEKW( PEEKL(ef&)+32 )    'current Insertion Point
            TeSetSelect c%-(TElength%-255), c%, ef&    'extra text
            Tedelete ef&    'clear extra text
        END IF

        d% =  DialoG(0)
        IF d% = 5 THEN        'refresh
            TeUpdate PEEKL(ef&),ef&
            LINE (8,7)-(417,169),,b
        END IF
    WEND

    IF DialoG(1) = 1 THEN    'ok button clicked
        t$ = Edit$(1)
        IF t$ <> info$(hit%,1) THEN    'Update info if changed
            ChangeCursor 4
            info$(hit%,1) = t$
            DeleteRes ref%, ids%(hit%), curType$
            StringToHandle t$, h&
            AddRes ref%, h&, curType$, ids%(hit%), info$(hit%,0)
            UpdateResFile ref%
            ReleaseRes h&
            InitCursor
        END IF
    END IF

    '    clean up refresh picture
    SetWindowPic wp&,0&
    DisposePicture pict&

    DialoG ON
    WindOW CLOSE 2
END SUB

'----------------------------------------------------------------
'    GetFile
'    Display a window over the standard FILES$(1) dialog
'    containing the one-line message m$.
'
'    f$ = value returned by FILES$
'    t$ = type of file to get (e.g. "Text")
'    m$ = one-line message displayed over FILES$ dialog.
'
SUB GetFile(f$,t$,m$) STATIC
    '    Open window offscreen first, so the size calculations
    '    don't disturb a current window.
    WindOW 10,"",(-20001,-20001)-(-20000,-20000),3
    TextFont 0
    '    window width is w% or WIDTH(m$)+10, whichever is larger
    w%=300 : x% = WIDTH(m$)
    IF x% > w%-10 THEN w% = x% + 10

    mBar%=PEEKW(&HBAA) : l%=(SYSTEM(5)-w%)\2
    WindOW 10,"",(l%,mBar%+11)-(l%+w%,mBar%+30),2
    TextFont 0 : TextSize 12
    SetRect r%(0), 2,2,w%-2,CINT(WindOW(3)-2)
    TextBox m$, r%(0),1
    f$ = FILES$( 1, t$ )
    WindOW CLOSE 10
END SUB

'================================================================
'        Resource Utilities
'================================================================

'----------------------------------------------------------------
'    DeleteRes
'    Delete the resource id = idn% and type restype$ from the
'    resource file with file reference number r%.
'
SUB DeleteRes( r%, idn%, resType$ ) STATIC
    h& = 0
    GetRes r%, resType$, idn%, h&
    RemoveRes r%, h&
    UpdateResFile me%
    ReleaseRes h&
END SUB

'----------------------------------------------------------------
'    HandleToString
'    Convert Pascal string in a handle to Basic string
'
SUB HandleToString( h&, x$ ) STATIC
    size& = 0
    GetHandleSize h&, size&
    x$ = String$(size&,0)
    BlockMove PEEKL(h&), SADD(x$), size&
    x$ = MID$( x$, 2, ASC(x$) )    'Pascal to Basic string
END SUB

'----------------------------------------------------------------
'    StringToHandle
'    Convert Basic string to Pascal string in a handle.
'
SUB StringToHandle( a$, h& ) STATIC
        x$ = ""
        ReleaseRes h& :h& = 0    'make sure handle is empty
        B2PStr a$, x$
        size& = ASC(x$) + 1    'string length + length byte
        NewHandle size&, h&
        BlockMove SADD(x$), PEEKL(h&), size&
        x$ = ""
END SUB
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB35898


How to Make PostScript Escape Font for QuickBasic Application (36027)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    To send PostScript commands to a PostScript printer (such as the Apple LaserWriter), either you must have a font named "PostScript Escape" on your system or in your application, or you must change the "STR ID -8188" of the LaserWriter driver to a font that exists either in your application or in the system. Because the latter would require every user of your application to change his or her LaserWriter driver, it is advantageous to install a PostScript Escape font in your application, as described below.

    This information applies to Microsoft QuickBasic 1.00 and the Microsoft Basic Compiler 1.00 for Apple Macintosh.

    You may also install the PostScript Escape font into your System file for use with programs run in the Microsoft Basic Interpreter Version 3.00 for Apple Macintosh.

    Note: Rather than defining a PostScript Escape font, an easier alternative to send PostScript to the LaserWriter from QuickBasic (but not earlier Basics) is described in a separate article found by querying on the keyword PicComment.

    More information

    Perform the following steps to use ResEdit to install a PostScript Escape font in your Macintosh QuickBasic compiled application:
    1. To create a font in your application, do the following:

      1. Compile your QuickBasic program to an "apl" file.
      2. From the desktop, launch ResEdit.
      3. Open your "apl" application and set the window aside.
      4. Open another application, the SYSTEM file from the startup disk or any file with fonts installed in it.
      5. From the new window, open Fond. (Fond is a resource that contains a description of a family of fonts. A family of a given name, such as Geneva, contains family members, each of which are the different sizes of that font.)
      6. Select a font. To keep the size of your application down, it is a good idea to select a font that has the smallest point size, e.g. Geneva 9. Here, only the names of the fonts are shown -- to determine which font has the smallest point size, open Font first. (Font is a resource containing the actual image data for a font.) Note: If the PostScript Escape font exists in another application, select that font. Then, since the font is already named "PostScript Escape," you can skip Step 2 below.
      7. Copy the file (i.e., select Copy from the Edit menu).
      8. Click your application window and select Paste (from the File menu).
      9. Open Font (from the original application or system).
      10. Select the smallest point size of the font name that you selected in Step f and Copy it.
      11. Click your application window and select Paste.
    2. To change the new font to "PostScript Escape", do the following:

      1. Open Fond (from your application).
      2. Select the font that you copied and select Get Info from the File menu.
      3. Change the name to "PostScript Escape".
      4. Change the ID number to 160.
      5. Close the window.
      6. Close the Fonds window.
      7. Open Font (from your application).
      8. Select the font that you copied, and do a Get Info.
      9. Change the ID number to 20480 plus the font's point size.
      10. Close the window.
      11. Close the Font's window.
      12. Close your application (click "Yes" to save).
      13. Quit ResEdit.
    Your application should use TextFont 160 to access the new PostScript Escape font. If a Fond family number 160 already exists in your application, change the ID number to another number. The Fond ID number can range from 0 to 255, and the Font ID number is found by multiplying the Fond ID number by 128 and adding the font size.

    Code Example

    OPEN "LPT1:" FOR OUTPUT AS #1
WindOW OUTPUT #1
PRINT "This should have a box around it."
Textfont 160
DrawText "initclip  clippath  stroke"
CLOSE #1

' Note that you cannot use PRINT to send the PostScript commands.
' DrawText or DrawString Must be used, since this method sends the
' entire string at once, whereas PRINT sends the characters one at
' a time, which results in a PostScript error.
' For the Basic interpreter Version 3.00 and Basic compiler Version
' 1.00, you need to add the following Library statement at the top of
' the program to access the DrawText or DrawString routine:
'
'    Library "ToolLib"
'
' However, this Library statement is not needed for QuickBasic programs.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB36027 kbAudDeveloper


Remline Mac Basic program removes unused line numbers (36047)

The information in this article applies to:
- Microsoft QuickBasic 1.00, on Macintosh OS version (ALL)

Summary
Below is a Macintosh QuickBasic 1.00 program for removing line numbers that are not referenced. This process can be an aid for analyzing, porting, or improving older Basic programs with unused line numbers on many lines.

When only referenced line numbers are in the file, the flow of execution control is much easier to trace. This may reveal 'dead' code (code that is not executed), or flaws in logic.

This program is simple but reliable; however, some care needs to be used. See the warnings in the program header. (This program is adapted from the Remline.Bas program that comes with the Microsoft QuickBasic Compiler 4.00 for the IBM PC.)

More information
The following file is available for download from the Microsoft Software Library:

Remline.Exe
(http://support.microsoft.com/download/support/mslfiles/Remline.Exe)

For more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:

Q119591 How to Obtain Microsoft Support Files from Online Services

'----------------------------------------------------------------
'Remline
'Copyright 1988 Microsoft Corp.
'
'This program is for personal use only. It may not be
'redistributed in any form, electronic or mechanical, for any
'purpose, without the written permission of Microsoft Corp.
'Microsoft makes no warranty or claim for the performance of this
'program.
'
'----------------------------------------------------------------
'Compiler switches:
'May be compiled with static arrays
'Requires a few library routines
'Does not require run-time events
'Does not use the default window
'
'Warning:
'Does not recognize a line number of zero (which is a bad idea to
'have in a program)
'File must be a correct Basic program.
'The program may break if ERL is used in relational expressions
'that are not for strict equivalence (e.g. <, <= , >, >= ) or line
'numbers appear before ERL (e.g. IF 100 = ERL ... ).
'
'This program was written in a style designed for clarity. Some
'changes for speed are possible:
'Most usages of MID$() return only one character, and are used
'repeatedly on the same string. These uses may be replaced by
'saving the address of the string using string.address&=SADD(s$)
'and using PEEK(string.address&+char.offset).
'In the compiler, the ASC() function is much slower than the
'equivalent PEEK(SADD(s$)).
'
'----------------------------------------------------------------
w% = 300 : h% = 80
l% = (SYSTEM(5)-w%)\2 : t% = (SYSTEM(6)-h%)\3
WindOW 1,"Remove Line Numbers",(l%,t%)-(l%+w%,t%+h%),5
TextFont 0

'----------------------------------------------------------------
'global variables
'
DIM STATIC ShareD r%(3) 'scratch rectangle
DIM STATIC ShareD ln&(10000), maxLine% 'referenced line table
DIM ShareD sep$ 'token separator characters
sep$ = " := <>(),;/*/\"+CHR$(34)+CHR$(9)

'output file name extension and creator
DIM ShareD outFileCreator$, outFileExt$
outFileCreator$ = "Edit" 'other possibilities: "QED1","Word","MWRT"
outFileExt$ = ".rlo" 'appended to input file name for output name

'keys$
'Global table of Basic keywords that reference line numbers
'Contents are in approximate order of frequency in Basic programs,
'since this table is searched with a linear search.
DIM STATIC ShareD keys$(10), maxKey%
keydata:
DATA GOTO,GOSUB,THEN,ELSE,ERL,RESUME,REStore,RETURN,RUN, ""
REStore keydata
maxKey% = 0 : a$ = "."

WHILE a$ <> ""
READ a$
IF a$ <> "" THEN keys$(maxKey%) = a$ : maxKey% = maxKey% + 1
WEND

maxKey% = maxKey% - 1

'----------------------------------------------------------------
Menu 1,0,1,"File"
Menu 1,1,1,"Open" : CmdKey 1,1,"O"
Menu 1,2,1,"Open List" : CmdKey 1,2,"L"
Menu 1,3,0,"-"
Menu 1,4,1,"Quit" : CmdKey 1,4,"Q"

WHILE 1

menuID% = Menu(0)
IF menuID% = 1 THEN

SELECT CASE Menu(1)
CASE 1
GetFile f$,"Text","Program Source: Must be a Text File"
IF f$ <> "" THEN parse f$,p$ : CHDIR p$ : StripFile f$
CASE 2
GetFile f$,"Text","Program File List: Must be a Text File"
IF f$ <> "" THEN parse f$,p$ : CHDIR p$ : StripList f$
CASE 4 : GOTO quit
CASE ELSE : BEEP
END SELECT

Menu
END IF

WEND

quit:
END

'----------------------------------------------------------------
'StripFile
'
SUB StripFile(f$) STATIC
CLS
LOCATE 1,1 : DrawText "Reading : "+f$
LOCATE 2,1 : DrawText "Line : "

'pass one: build referenced line number table
curLine& = 0 : maxLine% = 0
OPEN f$ FOR INPUT AS #1 LEN = 4096
WHILE NOT EOF(1)
LINE INPUT #1,l$
curLine& = curLine& + 1
LOCATE 2,5 : DrawText STR$(curLine&)+" "
scanLine l$
WEND
CLOSE #1

'pass two: delete unreferenced line numbers
LOCATE 3,1 : DrawText "Line : "
LOCATE 1,1 : DrawText "Writing : "+f$+outFileExt$

curLine& = 0
OPEN f$ + outFileExt$ FOR OUTPUT AS #3 LEN = 4096
OPEN f$ FOR INPUT AS #1 LEN = 4096

WHILE NOT EOF(1)
LINE INPUT #1,l$
curLine& = curLine& + 1
LOCATE 3,5 : DrawText STR$(curLine&)+" "

IF l$ = "" THEN
PRINT #3,
ELSE
nn& = VAL(l$) 'VAL() automatically skips leading blanks
IF nn& > 0 THEN 'there's a line number
FindLine nn&, found%, dd%

IF NOT found% THEN
i% = 0 : t$ = " "
WHILE t$ = " " AND i% < LEN(l$) 'skip blanks
i% = i% +1 : t$ = MID$(l$,i%,1)
WEND

WHILE t$ >= "0" AND t$ <= "9" AND i% < LEN(l$)
i% = i% +1 : t$ = MID$(l$,i%,1)
WEND

MID$(l$,1,i%) = String$(i%," ")
END IF
END IF
PRINT #3,l$
END IF

WEND

CLOSE #1,#3
SetCreate f$+outFileExt$,outFileCreator$
END SUB

'----------------------------------------------------------------
'StripList
'Read list of files to strip, stripping each one.
'
'Skips blank lines
'A line beginning with a semicolon is skipped as a comment.
'Note that this program does not parse out switches, so this
'is not 100% compatible with the program list files used by
'the Microsoft Basic Compiler 1.0. To implementthis, change
'the ParseFileName subprogram.
'
SUB StripList(listf$) STATIC
OPEN listf$ FOR INPUT AS #2
WHILE NOT EOF(2)
LINE INPUT#2, l$
Ltrim l$
IF l$ <> "" AND ASC(l$) <> 59 THEN 'skip blanks or comments
ParseFileName l$,f$
e% = 0 : exists f$,e%
IF e% THEN
StripFile f$
ELSE
BEEP : PRINT : PRINT f$;" Not found"
END IF
END IF
WEND
CLOSE #2
END SUB

'----------------------------------------------------------------
'scanLine
'Scans l$ for line number references, entering them into the
'table as they are encountered.
'
'building% is a boolean:
'TRUE = we're adding line numbers to referenced line table
'FALSE = we're scanning for keywords
'
SUB scanLine( l$ ) STATIC
ltrim l$ : dequote l$
i% = INSTR( l$,"'") : IF i% THEN l$ = LEFT$(l$,i%)
building% = 0
GetToken l$,sep$,t$
WHILE t$<>"" AND t$ <> "REM"
IF building% THEN
IF ASC(t$) >= 48 AND ASC(t$) <= 57 THEN
Insert CLNG(VAL(t$))
ELSE
FindKey t$,building%
END IF
ELSE
FindKey t$,building%
END IF
GetToken "",sep$,t$
WEND
END SUB

'----------------------------------------------------------------
'GetToken
'Extract a token from a string.
'
'Usage:
'First call should specify the search string (search$).
'Subsequent calls should pass a null string (""), and GetToken
'will return successive tokens in the search string until the
'string is exhausted, when it will return a null token string.

'token$ = upper case token (null if no more on line)
'delim$ = the set of characters that delimit a token
'
SUB GetToken ( search$, delim$, token$ ) STATIC
IF search$ = "" THEN
search$ = src$
ELSE
scan% = 1
src$ = search$
smax% = LEN(search$)
END IF

'return null if at end of search string
IF scan% >= smax% THEN token$ = "" : EXIT SUB

'find token start: skip delimiters
WHILE scan% <= smax% AND INSTR(delim$,MID$(search$,scan%,1)) <> 0
scan% = scan% +1
WEND
start% = scan% 'mark start of token
scan% = scan% + 1

'scan for next delimiter
WHILE scan% <= smax% AND INSTR(delim$,MID$(search$,scan%,1)) = 0
scan% = scan% +1
WEND

'cut out token, convert to upper case
token$ = UCASE$(MID$(search$,start%,scan% - start%))
END SUB

'----------------------------------------------------------------
'FindKey
'look up t$ in keys$
'
SUB FindKey ( t$, found% ) STATIC
found% = 0 : k% = 0
WHILE k% <= maxKey% AND NOT found%
found% = t$ = keys$(k%)
k% = k% + 1
WEND
END SUB

'----------------------------------------------------------------
'FindLine
'Search for nn& in the referenced line number table.
'binary search

SUB FindLine ( nn&, found% , i%) STATIC
found% = 0
IF maxLine% = 0 THEN
i% = 0
ELSE
top% = maxLine% -1
i% = top%\2
bottom% = 0
WHILE bottom% <= top%
SELECT CASE SGN(nn&-ln&(i%))
CASE -1 :top% = i% - 1
CASE 1 :bottom% = i% + 1
CASE 0 :found% = -1 : EXIT SUB
END SELECT
i% = (top%-bottom%)\2 + bottom%
WEND
END IF
END SUB

'----------------------------------------------------------------
'Insert
'Insert nn& into the ordered list of numbers
'
SUB Insert(nn&) STATIC
IF maxLine% = 0 THEN
maxLine% = 1
ln&(0) = nn&
ELSE
FindLine nn&,found%,i%
IF NOT found% THEN
s& = (maxLine%-i%)*4
BlockMove CLNG(VARPTR(ln&(i%))),CLNG(VARPTR(ln&(i%))+4),s&
maxLine% = maxLine% + 1
ln&(i%) = nn&
END IF
END IF
END SUB

'----------------------------------------------------------------
'dequote
'Remove quoted strings from target$, leaving just the quotes.
'
SUB dequote(target$)STATIC
i% = INSTR(target$,CHR$(34))
IF i% THEN
result$ = LEFT$(target$,i%)
intext% = 0
FOR i% = i% + 1 TO LEN(target$)
ch$ = MID$(target$,i%,1)
IF ch$ = CHR$(34) THEN
result$ = result$ + ch$
intext% = NOT intext%
ELSEIF intext% THEN
result$ = result$ + ch$
END IF
NEXT
target$ = result$
END IF
END SUB

'----------------------------------------------------------------
'ltrim
'Remove leading spaces and control characters from string
'
SUB ltrim(s$) STATIC
IF s$ <> "" THEN
i% = 1
WHILE MID$(s$,i%,1) <= " " AND i% <= LEN(s$)
i% = i%+1
WEND
s$ = RIGHT$(s$,LEN(s$)-i%+1)
END IF
END SUB

'----------------------------------------------------------------
'ParseFileName
'extract file name from line
'
'This is currently a minimal function that simply assumes the
'filename is correct verbatim in the argument, x$, including
'leading or trailing spaces.
'
'This could be expanded to handle an optional switch
'specification to be compatible with other tools, or Microsoft
'Basic Compiler 1.0.
'
SUB ParseFileName ( x$, f$ ) STATIC
f$ = x$
END SUB

'----------------------------------------------------------------
'GetFile
'Display a window over the standard FILES$(1) dialog
'containing the one-line message m$.
'
'f$ = value returned by FILES$
't$ = type of file to get (e.g. "Text")
'm$ = one-line message displayed over FILES$ dialog.
'
SUB GetFile(f$,t$,m$) STATIC
'Open window offscreen first, so the size calculations
'don't disturb a current window.
WindOW 10,"",(-20001,-20001)-(-20000,-20000),3
TextFont 0
'window width is w% or m$ width +10, whichever is larger
w% = 300 : x% = WIDTH(m$)
IF x% > w%-10 THEN w% = x% + 10
mBar% = PEEKW(&HBAA)
l% = (SYSTEM(5)-w%)\2
WindOW 10,"",(l%,mBar%+11)-(l%+w%,mBar%+30),2
SetRect r%(0),2,2,CINT(WindOW(2)-2),CINT(WindOW(3)-2)
TextFont 0 : TextSize 12
textbox m$,r%(0),1
f$ = FILES$(1,t$)
WindOW CLOSE 10
END SUB

'----------------------------------------------------------------
'parse
'separate simple filename from full path name
'
SUB parse(f$,path$) STATIC
index% = 1
WHILE index%
last% = index%
index% = INSTR(index%+1,f$,":")
WEND
IF last% = 1 THEN
path$ = ""
ELSE
path$ = LEFT$(f$,last%)
f$ = RIGHT$(f$,LEN(f$)-last%)
END IF
END SUB

Additional query words: MQuickB softlib kbfile
Technology: kbHWMAC kbOSMAC
Version: 1.00


Macintosh QuickBasic Can't Compile in MultiFinder's Background (36079)

Summary

QuickBasic 1.00 for Macintosh cannot compile in the background under Apple MultiFinder. QuickBasic can compile in the foreground under MultiFinder; however, compilation will be slower than in the Finder due to the time slicing between foreground and background processes.

Applications compiled in QuickBasic can be run in the background of Apple MultiFinder. Those applications that do minimal screen refreshing will run the best in the background of MultiFinder. The processes running in the background will receive small amounts of time from the system. However, this small amount of time may not be enough to refresh the screen. The background process may jump into the foreground and try to process the screen refresh commands. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB36079


SYSTEM(7) or OpenResFile Gives Resource File Reference Number (36080)

Summary

A "resource file reference number" is a number that allows you to access the resource fork (area) of a file. Many of QuickBasic's MBLC routines use this number to access stored resources. This number is neither an index nor a pointer -- it only has meaning to the Macintosh System.

You can obtain a resource file reference number using the following two methods in Macintosh QuickBasic:
  1. Use the QuickBasic SYSTEM(7) function. The SYSTEM(7) function returns the file reference number (ref%) of the currently-running compiled application or the currently-running interpreted source file:
       ref% = SYSTEM(7)
    Never use CloseResFile on the number returned by SYSTEM(7).
  2. Use the OpenResFile Toolbox library routine to open external resource files. In the following example, the OpenResFile statement returns the file reference number of the "Demo Resources" file in the variable ref%:
       ref% = 0      '  must initialize ref% before calling OpenResFile
   OpenResFile "Examples:QB Demos:Demo Resources",ref%
   ' ... put the body of your program here ...
   ' In the interpreter, the program must always CloseResFile at end:
   IF ref% <> SYSTEM(7) AND ref% <> PEEKW(&H900) THEN
      CloseResFile ref%
   END IF
   END

More information

Warning: Never use CloseResFile to close the resource fork of a currently running source file, application, or QuickBasic itself, or else a "Device I/O Error" or System bomb may occur. You should only use CloseResFile on external resource files (that were opened with OpenResFile).

For an example of how an interpreted program can use SYSTEM(7) to get the file reference number of its own resource area, please see the "Icon Example" program (located in the "Demo Resources" folder of the QuickBasic 1.00 "Examples" disk). When run in the QuickBasic interpreter, "Icon Example" displays icon resources that are stored in its own resource fork.

When "Icon Example" is compiled, the program automatically looks in the external "Demo Resources" file for the needed resource. (The SYSTEM(4) routine decides if the program is currently being run interpreted or compiled.) If you want, you can use ResEdit or Statement Mover to move the icon resources into the compiled application "Icon Example apl", and then use SYSTEM(7) in the compiled version instead of OpenResFile.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB36080


How to Compile a Batch of Files with Macintosh QuickBasic (36333)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This program demonstrates how to compile more than one file at a time with Macintosh QuickBasic. It also demonstrates how to save window positions between invocations of a program.

    More information

    '----------------------------------------------------------------
'    Batch Compile
'    Copyright 1988 Microsoft Corp.
'    Written in QuickBasic 1.00 for the Apple Macintosh
'
'    This program is for demonstration purposes. Microsoft does
'    not make any warranty or claims for the performance of this
'    program.
'
'    This program is for personal use only. It may not be
'    redistributed in any form, electronic or mechanical, for any
'    purpose, without the written permission of Microsoft Corp.
'
'----------------------------------------------------------------
'    Batch Compile reads a list of file names and sublaunches
'    QuickBasic so QB will compile each file.
'
'    This uses a default name for the compiled application:
'
'    sourceName + " apl"
'
'    It does not use a name that was set in the Compile As...
'    dialog. If you want this program to use whatever was set
'    instead of the default, you should change the "SetAplName"
'    subprogram.
'
'    This program does not handle switch specifications, so it
'    is not 100% compatible with the program list files used by
'    Microsoft Basic Compiler 1.00. This program could be
'    modified to parse out the switches.
'    Code to parse switch information would be inserted in the
'    "DoNextFile" subprogram.
'
'----------------------------------------------------------------
'    STR  1000 = Name of QuickBasic
'    STR  1001 = Name of program list file
'    BCFG 1000 = configuration info
'
'----------------------------------------------------------------
WindOW 1,"",(0,0)-(1,1),3

'    Global variables
DIM ShareD QBName$, programList$

'    config%(0 to 3) = window coordinates
'    config%(4) =
'        2 = deleting apl files before compile,
'        1 = not deleting
'    config%(5) =
'        -1 = not currently compiling a list
'        else current line index into program list
DIM ShareD config%(5)

'    dirty flags:
'    0 = config%() changed
'    1 = QBName$ changed
'    2 = programList$ changed
DIM ShareD dirty%(2)

'scratch variables
DIM ShareD r1%(3),r2%(3),r3%(3),x%

'    list of resource handles to delete
DIM ShareD zList&(10)

'    Get resources
ON ERROR GOTO BadRes
me% = SYSTEM(7)
LoadString me%, 1000, QBName$
LoadString me%, 1001, programList$
LoadArray me%, 1000, config%(0), "BCFG"
ON ERROR GOTO 0

'    range check value of apl deletion
IF config%(4)<1 OR config%(4)>2 THEN config%(4)=2

'    make sure saved window will be visible
mBar% = PEEKW(&HBAA)
h% = config%(2)-config%(0)
w% = (config%(3)-config%(1))/2
SetRect r1%(0),w%,mBar%+h%+19,CINT(SYSTEM(5)-w%),CINT(SYSTEM(6)-h%)
'    do rectangles intersect ?
SectRect r1%(0),config%(0),r1%(0),x%
IF x% = 0 THEN CALL DefaultWindow : dirty%(0) = -1

t$ = "QB Batch Compile"
WindOW 1,t$,(config%(1),config%(0))-(config%(3),config%(2)),6
WHILE 1
    IF config%(5) <= 0 THEN    'starting new compilation
        ui
    ELSE    'in compilation sequence
        DoNextFile
    END IF
WEND

'----------------------------------------------------------------
'    BadRes
'    Configuration resource loading error handler.
'
'    Something is wrong with the resource fork: probably missing
'    a resource. This will happen the first time the program is
'    run after compiling.
'    This code is paranoid: it deletes all existing resources
'    of the types we're concerned with (if any). It assumes that
'    there may be duplicates of any given resource, which is a very
'    abnormal condition. This can usually happen only while
'    debugging, but we'll leave in the protective code to be sure.
'
BadRes:
    h& = 0 : id% = 0 : t$ = "" : n$ = ""
    me% = SYSTEM(7)
    '    make list of existing special string resources
    c% = 0 : tref% = me%
    i% = 1 : k% = 0
    CountRes "STR ",c%
    WHILE i% <= c% AND tref% = me%
        GetIndRes "STR ",i%,h&
        GetResInfo h&,id%,t$,n$
        HomeResFile h&,tref%
        IF tref% = me% AND (id% = 1000 OR id% = 1001) THEN
            zList&(k%) = h& : k% = k% + 1
        ELSE
            ReleaseRes h&
        END IF
        i% = i% + 1
    WEND
    '    make list of existing configuration resource(s)
    i% = 1 : tref% = me%
    CountRes "BCFG",c%
    WHILE i% <= c% AND tref% = me%
        GetIndRes "BCFG",i%,h&
        GetResInfo h&,id%,t$,n$
        HomeResFile h&,tref%
        IF tref% = me% AND (id% =1000) THEN
            zList&(k%) = h& : k% = k% + 1
        ELSE
            ReleaseRes h&
        END IF
        i% = i% + 1
    WEND

    '    delete all resources in the list
    FOR i% = 0 TO k% -1 : RemoveRes me%,zList&(i%) : NEXT
    UpdateResFile me%
    FOR i% = 0 TO k% -1 : ReleaseRes zList&(i%) : NEXT

    '    Save default configuration
    DefaultWindow
    config%(4) =  2    'Delete before compile enabled
    config%(5) = -1    'Not compiling a list
    SaveArray me%, config%(0), 12, 1000, "Config Info", "BCFG"

    '    Save default names (all null)
    QBName$ = "" : programList$ = ""
    SaveString me%,1000,"","QuickBasic"
    SaveString me%,1001,"","Program List"

    UpdateResFile me%
    RESUME NEXT

'----------------------------------------------------------------
'    Quit
'    Clean up and terminate this program
'
SUB Quit STATIC
    SaveInfo
    END
END SUB

'----------------------------------------------------------------
'    DefaultWindow
'    Initialize the default window configuration
'
SUB DefaultWindow STATIC
    h%=120 : w%=400
    t% = (SYSTEM(6)-h%)\3 : l% = (SYSTEM(5)-w%)\2
    SetRect config%(0),l%,t%,l%+w%,t%+h%
END SUB

'----------------------------------------------------------------
'    ui
'    The user interface for this program
'
SUB ui STATIC
    CLS
    SetRect r1%(0),110,10,390,40 : SetRect r2%(0),110,50,390,80
    Button 1,1,"QB Name",(8,9)-(100,34),1
    Button 2,1,"Program List",(8,50)-(100,75),1
    Button 3,1,"Quit",(150,90)-(250,110),1
    Button 4,0,"Compile",(280,90)-(380,110),1
    Button 5,config%(4),"Delete apl first",(10,90)-(130,105),2

    d%=0
    WHILE d%<>4
        d%=DialoG(0)
        SELECT CASE d%
        CASE 1
            SELECT CASE DialoG(1)
            CASE 1    'QB Name
                GetFile z$,"Appl","Please find QuickBasic."
                IF LEN(z$) > 250 THEN    'path too long
                    BEEP
                ELSEIF z$ <> "" THEN
                    QBName$ = z$ : dirty%(0) = -1
                    config%(5) = -1 : dirty%(1) = -1
                END IF
            CASE 2
                GetFile z$,"Text","Program List file?"
                IF LEN(z$) > 250 THEN    'path too long
                    BEEP
                ELSEIF z$ <> "" THEN
                    programList$ = z$ : dirty%(0) = -1
                    config%(5) = -1 : dirty%(2) = -1
                END IF
            CASE 3 : Quit
            CASE 4    'compile
                config%(5) = 0 : dirty%(0) = -1
                Button CLOSE 0 : CLS
                DoNextFile
            CASE 5    'toggle 'delete apls' switch
                Button 5,(Button(5) = 2) + 2
                config%(4) = Button(5) : dirty%(0) = -1
            END SELECT
        CASE 4 : Quit    'close box on window clicked
        CASE 5 : WHILE DialoG(0)=5:WEND : GOSUB redraw
        CASE ELSE    'ignore anything else
        END SELECT
        IF QBName$<>"" AND programList$<>"" THEN
            Button 4,1
        ELSE
            Button 4,0
        END IF
    WEND
    Quit

redraw:    'window refresh routine
    TextFont 4
    TextBox QBName$,r1%(0),1
    TextBox programList$,r2%(0),1
    Penpat PEEKL(&H904)-28
    InsetRect r1%(0),-2,-2 : FrameRect VARPTR(r1%(0))
    InsetRect r1%(0), 2, 2
    InsetRect r2%(0),-2,-2 : FrameRect VARPTR(r2%(0))
    InsetRect r2%(0), 2, 2
    PenNormal
    RETURN

END SUB

'----------------------------------------------------------------
'    DoNextFile
'    Compile the next file in the list
'
'    List file may contain blank and comment lines.
'    A line with a semicolon as the first nonblank is a comment line.
'
SUB DoNextFile STATIC
    w% = WindOW(2) : h% = WindOW(3)
    SetRect r1%(0),2,2,w%-2,h%-2

    f$ = programList$
    Parse f$,plPath$
    CHDIR plPath$
    Exists programList$,x%
    IF x% THEN
        OPEN programList$ FOR INPUT AS #1
        '    synchronize with last offset
        i% = 0
        WHILE NOT EOF(1) AND i% < config%(5)
            LINE INPUT #1, l$ : i% = i% + 1
        WEND

        WHILE config%(5) > -1
            '    look for next file in list
            found% = 0
            WHILE NOT EOF(1) AND NOT found%
                LINE INPUT #1, l$ : i% = i% + 1
                Ltrim l$
                '    skip blank lines and comments
                '    59 = ASC(";")
                '    l$ may be null (illegal for ASC) so we PEEK
                IF l$ <> "" AND PEEK(SADD(l$)) <> 59 THEN found% = -1
                '    extension: parse switch info here
            WEND
            IF found% THEN
                config%(5) = i% : dirty%(0) = -1
                fullName$ = plPath$+l$
                Exists fullName$,x%
                IF x% THEN
                    '    Set MBAN to default name
                    SetAplName fullName$, fullName$ + " apl"
                    IF config%(4) = 2 THEN
                        Exists fullName$ + " apl", x%
                        IF x% THEN KILL fullName$ + " apl"
                    END IF
                    SaveInfo    'Remember where we were
                    '    echo name of file we're about to compile
                    m$ = "Compiling"+CHR$(13)+plPath$+":"+CHR$(13)+l$
                    TextBox m$,r1%(0),1
                    SubLaunch QBName$, fullName$, 256    'compile file
                    '    here if SubLaunch failed: stop processing
                    config%(5) = -1 : dirty%(0) = -1
                    BEEP : EXIT SUB
                ELSE    'file not found
                    m$ = plPath$+":"+CHR$(13)+l$+CHR$(13)+"not found"
                    BEEP : TextBox m$,r1%(0),1
                END IF
            ELSE    'no more files to compile
                m$ = "Done"
                TextFont 0 : TextBox m$, r1%(0), 1
                config%(5) = -1 : dirty%(0) = -1    'stop processing
            END IF
        WEND
        CLOSE #1
        SaveInfo
    ELSE    'program list not found
        m$ = plPath$+":"+CHR$(13)+f$+CHR$(13)+"not found"
        BEEP : TextFont 0 : TextBox m$,r1%(0),1
    END IF
END SUB

'----------------------------------------------------------------
'    SetAplName
'    Make sure there's a valid MBAN resource.  Remove any existing
'    MBAN(s), and use a default.
'
'    n$ = name of source file
'    cn$ = compiled application name
'
'----------------------------------------------------------------
'    This could be changed to use an existing MBAN as follows:
'    IF no MBAN (count for this file = 0) THEN
'        use default
'    ELSEIF 1 MBAN (count for this file = 1) THEN
'        use MBAN
'    ELSE (more than 1: file is damaged) THEN
'        either delete all and use default, or have user select.
'        Always remove the extras: there should only be 1 MBAN.
'
SUB SetAplName( n$, cn$ ) STATIC
    c% = 0 : fr% = 0 : h1& = 0

    '    delete all existing MBANs
    CountRes "MBAN",c%
    OpenResFile n$, fr% : UpdateResFile fr%
    CountRes "MBAN",x%
    x% = x% - c%
    FOR k% = 1 TO x%
        GetIndRes "MBAN",k%,h1&
        RemoveRes fr%,h1&
        ReleaseRes h1&
    NEXT
    UpdateResFile fr%

    '    save our default MBAN
    StringToHandle cn$,h1&
    AddRes fr%, h1&, "MBAN", 0
    CloseResFile fr%
    ReleaseRes h1&
END SUB

'----------------------------------------------------------------
'    SaveInfo
'    Flush information to the resource fork if it's been changed.
'
'    dirty%() contains a list of changed resources:
'    0 = config%() changed
'    1 = QBName$ changed
'    2 = programList$ changed
'
SUB SaveInfo STATIC
    me% = SYSTEM(7)

    '    delete changed resources
    FOR i% = 0 TO 2 : zList&(i%)= 0 : NEXT
    IF dirty%(0) THEN GetRes me%,"BCFG",1000,zList&(0)
    IF dirty%(1) THEN GetRes me%,"STR ",1000,zList&(1)
    IF dirty%(2) THEN GetRes me%,"STR ",1001,zList&(2)
    FOR i% = 0 TO 2
        IF dirty%(i%) THEN RemoveRes me%, zList&(i%)
    NEXT
    UpdateResFile me%

    '    Save new resources
    IF dirty%(0) THEN
        SetRect config%(0),0,0,400,120
        LocalToGlobal config%(0) :LocalToGlobal config%(2)
        SaveArray me%,config%(0),12,1000,"Config Info","BCFG"
    END IF
    IF dirty%(1) THEN SaveString me%,1000,QBName$,"QuickBasic"
    IF dirty%(2) THEN SaveString me%,1001,programList$,"Program List"
    UpdateResFile me%
END SUB

'-------------------------------------------------------------------
'        Utilities
'-------------------------------------------------------------------

'-------------------------------------------------------------------
'    StringToHandle
'    Convert Basic string to Pascal string in a handle.
'
SUB StringToHandle(a$,h&) STATIC
    x$ = ""
    ReleaseRes h& :h& = 0    'make sure handle is empty
    B2PStr a$,x$
    size& = ASC(x$)+1    'string length + length byte
    NewHandle size&,h&
    BlockMove SADD(x$),PEEKL(h&),size&
    x$ = ""
END SUB

'---------------------------------------------------------------
'    GetFile
'    Display a message above the standard file dialog.
'    m$ = message to display
'    t$ = types displayed
'    f$ = result from FILES$()
'
SUB GetFile(f$,t$,m$) STATIC
    TextFont 0
    w%=300 : x% = WIDTH(m$)
    IF x% > w%-10 THEN w% = x% + 10
    mBar%=PEEKW(&HBAA) :l%=(SYSTEM(5)-w%)\2
    WindOW 10,"",(l%,mBar%+11)-(l%+w%,mBar%+30),2
    SetRect r3%(0),2,2,CINT(WindOW(2)-2),CINT(WindOW(3)-2)
    TextFont 0 :TextSize 12
    TextBox m$,r3%(0),1
    f$=FILES$(1,t$)
    WindOW CLOSE 10
    TextFont 4
END SUB

'----------------------------------------------------------------
'    Parse
'    Separate filename from path
'
SUB Parse(f$,p$) STATIC
    i%=1 : WHILE i% : l%=i% : i%=INSTR(i%+1,f$,":") : WEND
    IF l%=1 THEN p$="" ELSE p$=LEFT$(f$,l%) : f$=RIGHT$(f$,LEN(f$)-l%)
END SUB

'----------------------------------------------------------------
'    Ltrim
'    Remove leading spaces and control characters from string
'
SUB Ltrim(s$) STATIC
    IF s$ <> "" THEN
        i% = 1
        a& = SADD(s$)
        WHILE PEEK(a&+i%-1) <= 32 AND i% <= LEN(s$)
            i% = i%+1
        WEND
        s$ = RIGHT$(s$,LEN(s$)-i%+1)
    END IF
END SUB
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB36333


When Macintosh QuickBasic 1.00 Might Forget Compiler Options (36334)

Summary

You can change the default compiler options under Options... in the Run menu of Microsoft QuickBasic 1.00 for Apple Macintosh. QuickBasic saves the compiler options in the MBCO resource in each source file.

QuickBasic may not remember a program's compiler options correctly under one of the following conditions:

  1. If there is more than one MBCO resource in the resource fork of either the program source file or QuickBasic
  2. If there is an MBCO resource in the "QuickBasic Settings" file (the "QuickBasic Settings" file may be found in the System folder)
These may be determined by opening the file in question with ResEdit, which is on the Examples disk in the Tools folder. To see if there is more than one MBCO, double click on MBCO.

To correct situation 1, do the following:

If there are extra MBCOs in the source file, use ResEdit to delete all of the MBCO resources in the file. If there are extras in QuickBasic, delete all but one.

To correct situation 2, do the following:

Drag the "QuickBasic Settings" file from the System folder into the desktop trash can.

More information

Situation 1 or 2 may occur when you are developing a program in the environment that opens external resource files with OpenResFile, the ToolBox statement or the Library statement. Situation 1 or 2 may also occur if your program closes its own resource fork.

In general, Never close the resource fork of any file you did not open yourself. Never close the resource fork of a currently running application, whether that application is QuickBasic or your own application. Always close external resource files you have opened before you END, STOP, RUN, CHAIN, or SubLaunch.

When you are developing a program that works with resources files, you should include an ON Break statement. The ON Break handler and the normal termination code for your program should include code similar to the following:
ON Break GOSUB breakTrap : Break ON
' Program code goes here ...
' ...
IF timeToQuit THEN GOTO BreakTrap
END
BreakTrap:
    '    close open libraries:
    Library CLOSE

    ' Do the following for every resource file you have opened.
    ' This code checks to make sure the given resource file is
    ' NOT the program source file or the currently running
    ' application, then closes the resource file.
    ' ref% is the number returned by OpenResFile.
    ' PEEKW(&H900) gets the file reference number of the currently
    ' running application from the Macintosh global variable
    ' CurApRefNum.
    IF ref% <> SYSTEM(7) AND ref% <> PEEKW(&H900) THEN
        CloseResFile ref%
    END IF
    STOP
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB36334


How to Avoid "String Too Long" Using Picture$ Function (36349)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article applies to Macintosh QuickBasic 1.00 for the Apple Macintosh.

    When collecting a large picture with the Picture ON...Picture OFF statements, the size of the picture may grow beyond the 32K maximum size allowed for a string variable. When the picture is assigned to a string variable with p$ = Picture$, a "String too long", error 15 message will appear if the recorded picture has exceeded 32,767 bytes.

    The subprogram below allows you to monitor the current size of the picture that is being recorded. This allows you to stop recording and start a new picture when the size of the current picture approaches the limit for a Basic string.

    More information

    In the 64K ROM Macintoshes, QuickDraw pictures were limited to 32,767 bytes, but in the newer, 128K ROM (enhanced) Macintoshes, they are no longer restricted in size.

    The following is a code example:
    Picture ON  ' Turn on recording of the picture in heap space.
size& = 0
WHILE size& < 32700    'leave some margin
    PSET(RND*400+100,RND*400+100)  ' Draw a pixel at a random location.
    GetPictureSize size&  ' SUBprogram returns current picture size.
WEND
Picture OFF  ' Turn off recording of the picture in heap space.
p$ = Picture$    'get picture into a Basic string
Picture ,p$      'draw the recorded picture
WHILE Mouse(0) <> 1 : WEND    'wait for mouse click
END
' This SUBprogram returns the size of the picture currently recording:
SUB GetPictureSize( Size& ) STATIC
    hPic& = PEEKL( PEEKL(PEEKL(PEEKL(&H904))) + &H5C )
    IF hPic& <> 0 THEN    'return size of picture
        size& = PEEKW(PEEKL(PEEKL(PEEKL(hPic&))))
    ELSE    'no picture being recorded
        size& = 0
    END IF
END SUB
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB36349


Why Imported Color/Gray Scale Picture Fails to Draw in Basic (36350)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    This information applies to Microsoft QuickBasic 1.00, Basic Compiler 1.00, and Basic Interpreter Version 3.00 for the Apple Macintosh.

    Gray scale or color pictures imported from other programs will not appear when drawn in Basic with the Picture statement or the DrawPicture library routine. No error message occurs.

    On newer Macintosh systems (such as the Macintosh II), pictures may be created in full color or gray scale by some graphics applications. Apple calls these "version 2" Macintosh pictures. Version 2 pictures appear only when drawn into a color window. Although Basic creates windows that can display eight colors, they are not full-color windows. Basic does this so your program works correctly on any supported Macintosh, not just a color or gray scale Macintosh.

    More information

    A "version 1" Macintosh picture contains hexadecimal 1101 in bytes 10 and 11 of the picture. A "version 2" picture contains hexadecimal 00 11 02 FF in bytes 10 to 13. Version 1 pictures are documented in "Inside Macintosh" Volume 1 and Macintosh Technical Note #21. Version 2 pictures are documented in "Inside Macintosh" Volume 5. The internal format of pictures are subject to change by Apple.

    "Inside Macintosh" by Apple Computer, Inc. is a set of books published by Addison-Wesley Publishing Company, Inc.

    Macintosh Technical Notes are published by Apple Computer.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB36350


How to Load Programs Faster for Compilation in Mac QuickBasic (36359)

Summary

When you have a program loaded into the Macintosh QuickBasic environment, it is kept in memory in a compressed (tokenized) format, even when the program is a Text file on disk.

A program takes longer to load into the QuickBasic environment when saved as Text because QuickBasic must convert it into compressed format. In compressed format, the QuickBasic reserved words have been recognized and converted into special tokens, and numbers have been converted into their internal representation.

When you compile a program that is in memory, Basic converts the interpreter's compressed format into plain ASCII text a line at a time, passing each line to the compiler. This decompressing process can be slow.

To save a little time when compiling files saved in Text format, you can circumvent the initial QuickBasic environment loading wait as described in methods 1 and 2 below.

More information

The following are two methods to speed the compiling of large programs in Macintosh QuickBasic:

  1. If your program does not use '$INCLUDE files (because nesting of '$INCLUDE metacommands is not supported), you can create a dummy source file that contains the following:
       '$INCLUDE "my real program"
    where "my real program" must be saved in Text format. You can set the compiler options for the program in the Options... item in the Run menu, and then compile it. This method saves the time it would have taken to initially load the program into the QuickBasic environment.
  2. Another trick is to write an application that sublaunches QuickBasic, passing it the name of the file and an Apple Finder message of 256. This method saves the time it would have taken to initially load the program into the QuickBasic environment and then manually invoke the compiler. The following is an example:
       QBName$="Microsoft QuickBasic (b)"
   FileName$="my program"
   Sublaunch QBName$, FileName$, 256
    Note that both of these names must be full pathnames or valid for the current directory. If QuickBasic is in a different folder or has a different name, you may hang the system, thereby forcing a system restart.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB36359


How to Use HFSDispatch to Create a Macintosh Folder (36392)

Summary

This article contains a sample program that demonstrates how to use HFSDispatch to create a folder with Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

The program below will create a new folder. If no volume or path is specified, the folder is placed in the current folder on the current volume. If a path is specified, it must be a full pathname, including volume name and parent folder names. The last folder name in the path specification is the one that will be created; all others in the path must already exist.

If there is an error creating the folder, the error code will be returned in the variable ErrCode%. The error codes are as follows:
0       No error, folder was created

1       Volume specified is not currently mounted

Other   Error in creating the folder. This is the error code returned
        by the PBDirCreate ROM routine. See "Inside Macintosh," Volume
        4 for more information about these error codes.
This program creates the folder by properly establishing a parameter block (stored here in IOPB%()), and making a call to HFSDispatch, call number 6. For more information regarding the I/O Parameter Block (IOPB), see "Inside Macintosh", Volume 4.

The following is a code example:
'--------------------------------------------------------
'    DirCreate
'    Copyright 1988 Microsoft Corp.
'
'    This program is for personal use only.  It may not be
'    redistributed in any form, electronic or mechanical, for any
'    purpose, without the written permission of Microsoft Corp.
'
'--------------------------------------------------------
'
'    Subprogram which will create the specified folder name on
'    either the current volume (in the current folder) or on the
'    specified volume (in the specified folder).
'
'--------------------------------------------------------

INPUT "Please enter the folder to create:",fld$
DirCreate fld$, ECode%
WHILE Mouse(0)<>1:WEND
END

SUB DirCreate (FolderName$, ErrCode%) STATIC
    DIM IOPB%(120)
    IF INSTR(FolderName$,":") = 0 THEN
        '    Set up for current volume/folder
        Ptr& = &H352        'pointer to default VCB
        Vol& = PEEKL(Ptr&)    'Default VCB
        vRefNum% = PEEKW(Vol& + 78)    'Volume reference number
        path$ = ""
        GetDirName vRefNum%, path$
        NewFolder$ = path$ + ":"+FolderName$
    ELSE    'Entire volume:path specified
        Vol$ = LEFT$(FolderName$, INSTR(FolderName$,":")-1)
        Ptr& = &H358    'first VCB
        Vol& = PEEKL(Ptr&)
        Found% = 0
        WHILE Vol& <> 0 AND Found% = 0
            Vol& = PEEKL(Ptr&)
            Ptr& = Vol&
            IF Vol& <> 0 THEN
                DirID& = 0 : n$ = ""
                vRefNum% = PEEKW(Vol& + 78)
                GetCatInfo IOPB%(0),n$,DirID&, vRefNum%
                IF UCASE$(n$) = UCASE$(Vol$) THEN Found% = 1
            END IF
        WEND
        IF Found% = 0 THEN
            PRINT "Volume not mounted!"
            ErrCode% = 1
            EXIT SUB
        END IF
        NewFolder$ = FolderName$
    END IF
    pasFolder$ = ""
    B2PStr NewFolder$, pasFolder$
    POKEW VARPTR(IOPB%(0))+22, vRefNum%
    POKEL VARPTR(IOPB%(0))+18, SADD(pasFolder$)
    HFSDispatch 6,IOPB%(0)
    ErrCode% = PEEKW(VARPTR(IOPB%(0))+16)
END SUB
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB36392


How the Macintosh QuickBasic GetPathNames Program Works (36394)

Summary

The GetPathNames program shows how to find the full pathname of a program, the startup system folder, any open Basic file, or any open resource file.

The GetPathNames program is located on the Macintosh QuickBasic Version 1.00 Examples disk in the QuickBasic Demos folder.

More information

The GetPathNames program takes the file reference number of a file, and returns the full path name of the file. The file reference number may be obtained by several methods, depending on the file in question.

The SYSTEM(7) function returns the file reference number of the program source file if the program is running under the interpreter, and the file reference number of the the application when the program is compiled.

The System file's file reference number is in the system global variable SysMap at address &HA58. Using this, we can find the name of the "blessed" folder where many applications keep special configuration files. A file in this folder will always be found, no matter where the application opening the file resides.

The GetChanRefNum library routine returns the file reference number of a file opened in Basic given the channel number. The channel number is the number specified in the OPEN statement. For example, in the statement OPEN f$ FOR INPUT AS #5, the channel number is 5.

The GetPathName subprogram uses the library routines GetFCBInfo and GetCatInfo to build the full pathname. GetFCBInfo returns information in a File Control Block that contains information about a file. GetCatInfo is similar, but returns information about a folder.

First, it passes the file reference number to the GetFCBInfo library routine. This returns the simple name of the file. This call also fills in other information in the IOPB%() array. At this point, you extract the directory id (DirID&) of the directory the file resides in, and the Volume Reference Number (VolRefNum%) of the disk volume the file is on.

The DirID& and VolRefNum% are passed to the GetCatInfo library routine to find the DirID& and name of the folder the current folder is in. This is done repeatedly for each "parent" folder until we reach the name of the volume, building up the full name of the file in question.

Additional information on the system functions used in the GetPathNames program can be found in "Inside Macintosh" Volume IV. The GetCatInfo function is discussed on page 155. The GetFCBInfo function is discussed on page 179.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB36394


How to Use REM or ' Comments in DATA Statements without Error (36395)

The information in this article applies to:
  • Microsoft QuickBasic 1.02
  • Microsoft QuickBasic 2.0
  • Microsoft QuickBasic 2.01
  • Microsoft QuickBasic 3.00
  • Microsoft QuickBasic 4.00
  • Microsoft QuickBasic 4.0B
  • Microsoft QuickBasic 4.50
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.10
  • Microsoft GW-Basic 3.2
  • Microsoft GW-Basic 3.22
  • Microsoft GW-Basic 3.23
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    If you want to append a comment [using REM or an apostrophe (')] to a DATA statement, you must put a colon (:) in front of the REM or apostrophe on the DATA line.

    This information applies to QuickBasic 1.00, 1.02, 2.00, 2.01, 3.00, 4.00, 4.0B, and 4.50 for Ms-Dos; to Microsoft Basic Compiler 6.00 and 6.0B for Ms-Dos and MS OS/2; Microsoft Basic PDS 7.00 for Ms-Dos and MS OS/2; to GW-Basic Versions 3.20, 3.22, and 3.23 for Ms-Dos; to QuickBasic 1.00 for the Apple Macintosh; to Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh; and to Microsoft Basic Compiler 1.00 for the Apple Macintosh. It may also apply to other versions of Microsoft Basic not listed here.

    More information

    In QuickBasic for Ms-Dos, in Microsoft Basic Compiler for Ms-Dos and MS OS/2, and in GW-Basic for Ms-Dos, a READ statement that is accepted into a non-string variable produces a "Syntax error" if it encounters a comment [a REM or an apostrophe(')] without a preceding colon (:) in a DATA statement line.

    In QuickBasic for Macintosh, you get a "Type Mismatch" error if you READ the comment (without a preceding colon) into a non-string variable when you run the program.

    In all above versions of Basic (for all operating systems), the READ statement treats the comment as additional string data for input when it reads into a string variable.

    Correct Example

    Separating the DATA statement from the REM (or apostrophe) with a colon (:) lets the program run correctly, as in the following example:
       DATA abc,,def:  rem The second item is null.
   DATA 1,,2:      ' The second item is null.
   READ a$, b$, c$    ' Note that b$ is assigned to null string ("")
   PRINT a$, b$, c$
   PRINT
   READ d, e, f       ' Note that e is assigned to 0
   PRINT d, e, f
   END

    Incorrect Example

    In the following program, the first READ statement reads the DATA statement's comment into c$ along with the last element ("def") of the DATA statement, which is not what the programmer may have wanted. The second READ statement produces a "Syntax error" in QuickBasic, the Basic compiler, and GW-Basic for Ms-Dos, and produces "Type Mismatch" in QuickBasic and Basic for the Apple Macintosh when it attempts to mistakenly read a (string) comment into a numeric variable:
       DATA abc,,def  rem The second item is null. [This becomes data.]
   DATA 1,,2      ' The second item is null. [This becomes data.]
   READ a$, b$, c$    ' Note that b$ is assigned to null string ("")
   PRINT a$, b$, c$
   PRINT
   READ d, e, f       ' This READ gives error while reading in f.
   PRINT d, e, f
   END
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB36395


Program to Compile QuickBasic Programs from Macintosh Desktop (36644)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    The program below allows you to bypass QuickBasic's load step and compile a QuickBasic program directly from the Macintosh desktop or from another text editor. This makes the process of compiling a large program faster.

    This information applies to Microsoft QuickBasic 1.0, 1.0a, and 1.0b for Apple Macintosh Systems.

    More information

    Some editors such as QUED/M from Paragon Courseware are able to pass the name of a file to another application when it transfers to that application. If this is done with QuickBasic, QuickBasic will RUN the program. You may transfer to the program below instead. This program will then launch QuickBasic, passing it a message to compile the file rather than RUN it.

    On the desktop, if you select both this program and the desired program source, then choose Open from the Finder's File menu, this program will launch QuickBasic and pass it the name of the file and a message to compile the file.

    If you start this program alone from the desktop, or transfer to it from another application, it will ask for the name of the file to compile.

    You will need to have loaded the file into QuickBasic once before, to set the desired compiler options. If you have never set the options, then QuickBasic will use the defaults.
    '----------------------------------------------------------------
'    Quick Compile
'    Copyright 1988 Microsoft Corp.
'    Written in Microsoft QuickBasic 1.0 for Apple Macintosh
'
'    Microsoft does not make any warranty or claims for the
'    performance of this program.
'
'----------------------------------------------------------------
'
'    Quick Compile is a utility for Macintosh QuickBasic. It enables
'    you to compile a file directly from the desktop (or another
'    application), bypassing QuickBasic's loading step. The source
'    file must be saved as Text.
'
'    Some text-editing applications are able to transfer to another
'    program, telling it to open a file. If you transfer to QuickBasic
'    this way, then QuickBasic will RUN the program, not compile it.
'    You can transfer to Quick Compile instead, and it will take care
'    of telling QuickBasic to compile the file.
'
'    When started from the desktop, Quick Compile asks for the file
'    name, then launches QuickBasic to compile the file.
'
'    When you shift-click to select a file and Quick Compile, then
'    select Open from the Finder's File menu, Quick Compile will
'    compile that file.
'
'    After compiling Quick Compile, you should run it once to
'    initialize it's resources.
'
'    You should compile with Options:
'        OFF: Checking, Default Window, Runtime Events
'        ON : Static Arrays, MBLCs & MBPCs, Save Before Compile
'
'----------------------------------------------------------------

WindOW 1,"",(0,0)-(1,1),3   'invisible window
DIM ShareD r%(3)    'scratch rectangle

'   If QuickBasic is in another folder or you've changed the name,
'   then change this assignment so you won't always have to go
'   looking for QuickBasic.
QB$ = "Microsoft QuickBasic (b)"
h& = 0
me% = SYSTEM(7)

GetRes me%,"QBLI",0,h&
IF h& = 0 THEN    'missing QB Launch Info
    NewHandle 2, h&    'allocate a 2-byte handle
    returning% = -1
    POKEW PEEKL(h&),returning%
    AddRes me%,h&,"QBLI",0,"QB Launch Info"
ELSE
    returning% = PEEKW(PEEKL(h&))
END IF

IF returning% THEN
    POKEW PEEKL(h&),0   'FALSE -> returning flag
    SetResAtt h&,2    'set dirty flag on resource
    UpdateResFile me%
    END
END IF

type$ = "" : f$ = "" : m% = -1
'   look for message to Open file
IF PEEKW(PEEKL(PEEKL(&HAEC))+2 ) > 0 THEN
    '    get finder message: 0 = Open, 1 = Print
    m% = PEEKW(PEEKL(PEEKL(&HAEC)))
    '    get file name
    l& = PEEK(PEEKL(PEEKL(&HAEC))+12 )
    f$ = String$(l&," ")
    BlockMove PEEKL(PEEKL(&HAEC))+13,SADD(f$),l&
    '    get file type
    type$ = MKL$(PEEKL(PEEKL(PEEKL(&HAEC))+6))
    '    get full path name of file
    Folder$ = ""
    VolRefNum% = PEEKW( PEEKL(PEEKL(&HAEC))+4)
    GetDirName VolRefNum%, Folder$
    f$ = Folder$ + ":" + f$
END IF

'    second chance for bad or no arguments
IF type$ <> "Text" OR m% <> 0 THEN
    GetFile f$,"Text","What source file to compile?"
END IF

IF f$ = "" THEN END 'no file to compile so quit

e% = 0
Exists QB$,e%   'can we find QB?
IF e%= 0 THEN
    GetFile QB$,"Appl","Please find "+QB$+" for me"
    IF QB$ = "" THEN END    'quit if no QB
END IF

'    remember that we're returning from a
'    sublaunch the next time we start
GetRes me%,"QBLI",0,h&
POKEW(PEEKL(h&)),-1    'TRUE -> returning flag
SetResAtt h&,2    'set dirty flag
UpdateResFile me%

'    make sure there's a valid application name resource
CheckAplName f$, f$+" apl"

'    compile the file
SubLaunch QB$, f$, 256, "Text"

END    'here if SubLaunch failed

'----------------------------------------------------------------
'   CheckAplName
'   Make sure there is a valid MBAN resource in the source file.
'
'   If there is not a valid MBAN resource in the source file, then
'   bad things will happen when QuickBasic tries to compile.
'
'   If there is just 1 MBAN, then we're ok
'   If there is more than 1 MBAN, something is wrong with the file,
'   so delete them all and use the default.
'   If there are no MBANs then use the default name.
'
'   n$  = source file
'   cn$ = default file name
'
SUB CheckAplName( n$, cn$ ) STATIC
    c% = 0 : x% = 0 : fr% = 0 : h& = 0
    CountRes "MBAN",c%
    OpenResFile n$, fr% : UpdateResFile fr%
    CountRes "MBAN",x%
    x% = x% - c%
    IF x% <> 1 THEN
        IF x% >1 THEN    'bad file: extra MBANs
            FOR k% = 1 TO x%    'delete all
                GetIndRes "MBAN",k%,h&
                RemoveRes fr%,h&
                ReleaseRes h&
            NEXT
            UpdateResFile fr%
        END IF
        '    use default MBAN
        StringToHandle cn$,h&
        AddRes fr%, h&, "MBAN", 0
        CloseResFile fr%
        ReleaseRes h&
    END IF
END SUB

'----------------------------------------------------------------
'   StringToHandle
'   Create a Pascal string in a handle from a Basic string
'
SUB StringToHandle(a$,h&) STATIC
        x$ = ""
        ReleaseRes h& : h& = 0    'make sure handle is empty
        B2PStr a$,x$
        size& = ASC(x$) + 1    'string length + length byte
        NewHandle size&, h&
        BlockMove SADD(x$),PEEKL(h&),size&
        x$ = ""
END SUB

'----------------------------------------------------------------
'   GetFile
'   Prompt for a specific file to open
'
SUB GetFile(f$,t$,m$) STATIC
    WindOW 10,"",(-20001,-20001)-(-20000,-20000),3
    TextFont 0
    '    window width is w% or m$ width +10, whichever is larger
    w%=300 : x% = WIDTH(m$)
    IF x% > w%-10 THEN w% = x% + 10
    mBar%=PEEKW(&HBAA)
    l%=(SYSTEM(5)-w%)\2
    WindOW 10,"",(l%,mBar%+11)-(l%+w%,mBar%+30),2
    SetRect r%(0),2,2,CINT(WindOW(2)-2),CINT(WindOW(3)-2)
    TextFont 0 :TextSize 12
    textbox m$,r%(0),1
    f$=FILES$(1,t$)
    WindOW CLOSE 10
END SUB
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB36644


Macintosh QuickBasic Does Not Use Sane for Floating-Point Math (36735)

Summary

Microsoft QuickBasic 1.00 for the Apple Macintosh does not use Standard Apple Numeric Environment (Sane). Microsoft QuickBasic (b) uses its own IEEE standard binary floating-point routines, which are faster than using Sane. Microsoft QuickBasic (d) uses a decimal math package that is slower but more accurate for business calculations (such as making dollars and cents add up exactly).

Sane is the set of methods that provides a basis for floating-point calculations in Apple computers. Sane meets all requirements for extended-precision, floating-point arithmetic as prescribed by the IEEE Standard 754 and ensures that all floating-point operations are performed consistently and return accurate results. This information about Sane is from the "Technical Introduction to the Macintosh Family," by Apple Computer, Inc. (Published by Addison-Wesley, 1987).

More information

For more information about Sane, please refer to the "Apple Numerics Manual", which should be available from Apple Computer, Inc. or Apple Dealers.

(The "Apple Numerics Manual" used to be available from the Apple Programmer's and Developer's Association (Apda), but Apple Computer, Inc. has taken over the functions of Apda for offering official Macintosh technical manuals and developer-oriented products through mail-order.)
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB36735


Mac QuickBasic Reserved Words Marked "*" Means Not Implemented (37299)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Reserved words for Macintosh QuickBasic are listed on Pages 369-371 in Appendix B, "Basic Reserved Words" in the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual.

    The reserved words that are not implemented are marked with an asterisk (*). The manual marks several reserved words with an asterisk, but fails to mention what the asterisk means.

    Using a reserved word as the name of a variable or label usually results in a syntax error. Some reserved words (marked with asterisks) are not implemented, which means they do not perform any function in QuickBasic. Unimplemented reserved words can be carryovers from other versions of Basic or can potentially be added in future versions. Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB37299


QuickBasic Maximum String Size Is 32767; 255 Saved as Resource (37300)

Summary

The largest size for a string variable in Macintosh QuickBasic is 32,767 bytes for both the QuickBasic environment and compiled programs. Note that you may write strings of up to 32,767 bytes at a time into QuickBasic sequential and random access files.

The maximum length for a string resource is 255 characters. You can invoke the QuickBasic Toolbox Library (MBLC) routines such as SaveString and GetString to save and retrieve strings to and from resource files. Other Toolbox library string routines are listed on Page 473 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB37300


Why QuickBasic's "Generate 68881 Code" Option Dims Out (37301)

Summary

In the compiler Options... choice on the Run menu of Macintosh QuickBasic, the "Generate 68881 Code" check box is disabled (marked in dim letters) until you click the "Generate 68020 Code" check box in the Binary Math version. In the Decimal Math version, the "Generate 68881 Code" check box remains permanently disabled because Microsoft QuickBasic (d) cannot take advantage of the coprocessor.

This feature prevents you from generating 68881 instructions for a machine that could not have this chip.

To generate code that takes advantage of the 68881 math coprocessor, do the following:

  1. Run Microsoft QuickBasic (b), Binary Math version.
  2. Click the box labeled "Generate 68020 Code."
  3. Click the box labeled "Generate 68881 Code."
A program compiled with the 68020 and 68881 options requires the presence of the 68881 math-coprocessor chip at run time.

More information

The 68881 chip must not be on an accelerator board; it must be built into the Macintosh as standard equipment. QuickBasic has not been tested with accelerator boards.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB37301


QuickBasic 1.00 is Not Compatible with AppleShare File Server (37303)

Summary

QuickBasic 1.00 for the Apple Macintosh is not compatible with (nor tested with) the AppleShare file server.

QuickBasic is compatible with printing over the AppleTalk Network system if you OPEN the device name "LPT1:" or "Lpt1:Prompt", or select PRINT from the File menu to print a program listing.

Printing is the only service that is built into the AppleTalk Network. AppleShare is a separate software server package that runs on the AppleTalk network.

More information

The AppleTalk Personal Network (from Apple Inc.) physically connects multiple Macintosh computers and Apple printers.

AppleShare is a software server that runs on an AppleTalk network. A server such as AppleShare allows computers to run applications that reside on another machine, usually called the host. QuickBasic or programs compiled in QuickBasic are not designed (or tested) to open files or run remotely over the AppleShare server.

The following products are not compatible with (or tested with) the AppleShare server:

  1. Microsoft QuickBasic 1.00 for the Apple Macintosh
  2. Microsoft Basic Compiler 1.00 for the Apple Macintosh
  3. Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB37303


A Handle Points to a Pointer to a Macintosh Heap Block (37311)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh

    • Summary

    Many of the Microsoft QuickBasic Toolbox Library (MBLC) routines make use of handles for manipulating resources.

    A handle is a pointer to a block of memory in the Macintosh heap. This pointing structure is used to allow dynamic memory allocation and management by the system to occur without creating havoc.

    More information

    The Macintosh heap space is managed by the System dynamically. Parts of the heap can move around. The System can compress the information in the heap to one location, allowing a large continuous block of heap space for other applications.

    A handle will actually point to a master pointer, which in turn points to a particular block in the heap. When the system performs its memory allocations and management, it only knows the location of the master pointer. It does NOT know the handle's location. Thus, when the memory block is moved, the master pointer is updated, which in effect updates the handle.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB37311


Example of Toolbox Register ROM Call for Date/Time Conversion (37312)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0A
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0B

    • Summary

    This article provides an example of calling Macintosh register-based ROM functions with the ToolBox statement in QuickBasic 1.0, 1.0A, and 1.0B for the Apple Macintosh.

    This article discusses date and time conversion functions, which are register-based ROM calls accessible with the QuickBasic Toolbox statement. The following register-based ROM calls pass arguments in Macintosh machine registers:

  • The Date2Secs ROM function

    This function takes a given date/time record, (a0&), which is the pointer to the date/time record, and converts it to the corresponding seconds since midnight of January 1, 1904. The result is put in the argument (d0&). The dayofweek field can be ignored for this function. See code example 1 below.

  • The Secs2Date ROM function

    This function takes the number of seconds since midnight, January 1, 1904, (d0&) and converts it to the corresponding date and time, returning it in the date/time record argument, (a0&), which is the pointer to the date/time record. See code example 2 below.
    • Note: Further below are examples of how to use the date and time conversion functions listed above.

    More information

    You can access Date2Secs and Secs2Date from within a QuickBasic program with the ToolBox statement. The ToolBox statement must first be initialized (only once within a program) with the following statement:
       ToolBox "i"   'case is not significant
    You can make a register-based ROM call in the following manner
       ToolBox "R",trapnum%,returnarray&(0),(a0&),(a1&),(d0&),(d1&),(d2&)
    where the following is true:

    "R" -- is for "register call."

    trapnum% -- is the trap number for the ROM routine.

    returnarray&(0) -- will contain the contents of the registers a0&, a1&, d0&, d1&, d2& (in order) after the ROM call. This array must be dimensioned to five elememts.

    The arguments a0&, a1&, d0&, d1&, d2& are arguments whose values are passed into the registers before the ROM call.

    Note: The arguments and returnarray&(0) are optional. They depend upon whether you need to use a particular register and whether there is a return value.

    The Date2Secs and Secs2Date functions use the following date/time record structure (based in Pascal):
       TYPE DateTimeRec =
         year:       integer; {1904 to 2040}
         month:      integer; {1 to 12 for January to December}
         day:        integer; {1 to 31}
         hour:       integer; {0 to 23)
         minute:     integer; {0 to 59}
         second:     integer; {0 to 59}
         dayofweek:  integer; {1 to 7 for Sunday to Saturday}
   END;
    In Basic, use an integer array to represent this structure, as in the following example:
       DIM DateTimeRec%(6)
    where:
       DateTimeRec%(0) represents DateTimeRec.year
   DateTimeRec%(1) represents DateTimeRec.month
   DateTimeRec%(2) represents DateTimeRec.day
   DateTimeRec%(3) represents DateTimeRec.hour
   DateTimeRec%(4) represents DateTimeRec.minute
   DateTimeRec%(5) represents DateTimeRec.second
   DateTimeRec%(6) represents DateTimeRec.dayofweek
    For additional information, see sections E.10.3 to E.10.3.5 of the "Microsoft QuickBasic for the Apple Macintosh: Language Reference."

    See "Inside Macintosh Volume II" for trap numbers and descriptions of routines.

    Code Example 1

       Toolbox "i"  ' Required to initialized toolbox routines; if you
                ' forget this statement, you get "Invalid Function Call"
   ' Example of invoking Date2Secs function.
   DIM returnarray&(5)   'Must be at least 5 to handle the
                         'five arguments for register ROM calls.
   DIM DateTimeRec%(6)    'set up date/time record
   trapnum% = &HA9C7    'trapnum for Date2Secs function
   d0& = 0         'initialization
   DateTimeRec%(0) = 1904    'fill date/time record
   DateTimeRec%(1) = 1
   DateTimeRec%(2) = 1
   DateTimeRec%(3) = 2
   DateTimeRec%(4) = 46
   DateTimeRec%(5) = 40
   DateTimeRec%(6) = 6
   ToolBox "R",trapnum%,returnarray&(0),DateTimeRec%(0)
   ' Note: The only parameter needed is DateTimeRec%, which is passed
   '       through the a0& register as noted by its position.
   PRINT returnarray&(2), "seconds have elapsed since 01-01-04"
    The code example above gives the following output:
    10000 minutes have elapsed since midnight 01-01-04

    Code Example 2

       ' Secs2Date function example:
   DIM datetimerec%(6)
   trapnum% = &HA9C6   'trap number for Secs2Date
   d0& = 10000       'time in seconds
   ToolBox "i"
   a0& = VARPTR(datetimerec%(0))
   ToolBox "R",trapnum%,,(a0&),,(d0&)
   ' Note: since no return value is needed, returnarray%(0) is omitted.
   PRINT "the year is ";datetimerec%(0)
   PRINT "month ";datetimerec%(1); " of the year"
   PRINT "day ";datetimerec%(2); " of the month"
   PRINT "the time is ";datetimerec%(3);" hours "; datetimerec%(4);
   PRINT " minutes ";datetimerec%(5);" seconds military time"
   PRINT "this is day ";datetimerec%(6); "  in the week"
    The code example above gives the following output:
    the year is 1904
    month 1 of the year
    day 1 of the month
    the time is 2 hundred hours 46 minutes 40 seconds military time
    this is day 6 in the week
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB37312


QuickBasic String Descriptor Has Six Bytes: 3.00 Has Five (37313)

Summary

The length of a string descriptor in Macintosh QuickBasic is six bytes, in both compiled and interpreted programs.

Note that the Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 uses a five-byte string descriptor. QuickBasic has changed the length of its string descriptors from five bytes to six bytes so programs written in the Microsoft Basic Interpreter environment can be more compatible with the compiler. The Microsoft Basic Compiler 1.00 (released before QuickBasic) also uses a six-byte string descriptor.

An assembly-language routine that uses string descriptors and used to work correctly with the Microsoft Basic Interpreter Versions 2.00, 2.10, or 3.00 may now give strange results in QuickBasic. The assembly-language routine will need to be rewritten to take into account the larger string descriptor size. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB37313


Metacommands Ignored inside Macintosh QuickBasic Interpreter (37314)

Summary

Metacommands (such as $INCLUDE and $IGNORE) are treated as comments in the interpreter environment QuickBasic for the Macintosh. The following information is taken from Page 375 of the "Microsoft QuickBasic for Apple Macintosh Systems: Basic Language Reference":

QuickBasic only recognizes metacommands when they are in a comment statement (line beginning with REM or an apostrophe). This means you can use metacommands when developing programs in the QuickBasic environment because the environment ignores them as comments, but the compiler acts on them.

Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB37314


Macintosh QuickBasic Example to Create and Use Scroll Bars (37315)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article contains a sample program that creates and uses QuickBasic scroll bars. Before attempting to write your own QuickBasic program that uses scroll bars, we recommend that you research the following areas in the "Microsoft QuickBasic for the Macintosh: Basic Language Reference" manual:
       Item                Page(s)
   ----                -------

   NewScroll           488

   DisposeScroll       478

   ScrollText          492

   SetRect             495

   FrameRect           402

   SetPt               495

   PtInRect            490

   GetFontInfo         482

   Mouse function      210-214
    Scrolling is also discussed on Pages 432-434.

    A program that defines scroll bars is provided further below. Two additional examples for defining scroll bars in QuickBasic are "ToolBoxSampler" and "File Browser.source", which are located in the QB Demos folder on the Examples disk for QuickBasic 1.00 for the Apple Macintosh.

    More information

    Code Example

    'ProgRAM: scroll

'Description:
' This programs puts up a scroll bar with an associated scrolling
' region. This region contains lines of text to be scrolled by
' clicking or dragging the scroll box around the scroll bar.
' Clicking on a particular line of text selects that line. And
' finally, a double-click ends the program.

'Constants:
'  SingleClick               Single click value
'  DoubleClick               Double-click value
'  MaxLines                  Maximum number of text lines

'Variables:
'  linenum                   Currently selected line
'  top                       Top line in scroll region
'  s&                        Handle to a scroll bar
'  PtInside                  Boolean flag that indicates
'                            inside/outside of scroll region
'  s$()                      Array that holds text to be
'                            scrolled
'  scr()                     Array that holds dimensions of
'                            scroll region (rectangle)
'  bar()                     Array that holds dimensions of
'                            scroll bar (rectangle)
'  FontInfo()                Array that holds information
'                            about the current font
'  AnyPt()                   Array that holds the (x,y)
'                            coordinates of the mouse pointer
'                            at the time of a single click,
'                            inside the scroll region
'  FontHeight                Vertical length of the current
'                            font
defint a-z
option base 1
SingleClick = -1: DoubleClick = -2: MaxLines = 10
linenum=1: top=0: s&=0: PtInside=0
dim s$(Maxlines), scr(4), bar(4), FontInfo(4), AnyPt(2)

SetRect scr(1), 3, 6, 114, 111
SetRect bar(1), 113, 6, 129, 111
FrameRect varptr (scr(1))
NewScroll s&, bar(1), 1, 1, 10, 1
GetFontInfo FontInfo(1)
FontHeight = FontInfo(1) + FontInfo(2) + FontInfo(4)

for n = 1 to MaxLines
  read s$(n)
next n

while Mouse (0) <> DoubleClick
  ScrollText s&, scr(1), s$(1), top, MaxLines, linenum
  if Mouse (0) = SingleClick then
    PtInside = 0
    SetPt AnyPt(1), Mouse(1), Mouse(2)
    PtInRect AnyPt(1), scr(1), PtInside
    if PtInside then
      linenum = (AnyPt(1) - scr(1)) \ (FontHeight + 4) + top
      top = 0
    end if
  end if
wend
DisposeScroll s&

end
  data one, two, three, four, five
  data six, seven, eight, nine, ten
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB37315


FIX: Page Setup Isn't Supported in Macintosh QuickBasic Env (37317)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    The Page Setup options under the File menu are not implemented in the QuickBasic editor. Any changes to the options under Page Setup, such as Reduce/Enlarge or Orientation, are not saved; therefore, they are ignored during printing. To print a source listing in the Reduced/Enlarge or Landscape/Portrait modes, you need to exit from QuickBasic and use another editor (such as Edit on the release disk) or the Print Listing File utility in the Tools folder.

    Microsoft has confirmed this problem in QuickBasic 1.00 for Macintosh . This problem is corrected in QuickBasic 1.00b for Macintosh .
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB37317


How to Input Image from Clipboard, Output to Screen or File (37318)

Summary

There is a correction for Page 141 of the "Microsoft QuickBasic for Apple Macintosh: Users Guide." Step 6 of the example to transfer a picture from MacPaint to QuickBasic should read as follows:
   Picture, image$
(The manual incorrectly uses the Picture$ function instead of the Picture statement in Step 6.)

Once you successfully put an image into a string variable, you can write it permanently to a disk file if you want, as shown in the examples below.

More information

Example 1

Below is a complete program that transfers an image from the clipboard to a picture string in Macintosh QuickBasic. The program also outputs the image string to a sequential file for retrieval at a later time.

To perform this process, do the following:

  1. Run MacPaint or another graphics application.
  2. Copy a picture to the clipboard.
  3. Exit the program.
  4. Run the following program in Microsoft QuickBasic, or in the earlier Microsoft Basic Interpreter Version 2.00, 2.10, or 3.00:
    OPEN "clip:picture" FOR INPUT AS #1  ' Opens clip: in picture mode.
image1$=INPUT$(LOF(1),1)             ' Reads the image into image1$
Picture, image1$                     ' Displays the picture.

OPEN "Imagefile" FOR OUTPUT AS #2  ' Opens file for sequential output.
PRINT #2, image1$;   ' Writes image to the sequential disk file.
CLOSE #1
CLOSE #2

CLS   ' The following section can also be run at a later time.
OPEN "Imagefile" FOR INPUT AS #1  ' Opens file for sequential input.
image2$=INPUT$(LOF(1),1)  ' Inputs image from disk file into image2$.
Picture, image2$     ' Displays the picture.
CLOSE #1
WHILE Mouse(0) <> -1 : WEND   ' Waits for a mouse click to end.
END

Example 2

The following is an example of storing multiple pictures as variable-length strings in one sequential disk file. This program works in Microsoft QuickBasic 1.00, in Microsoft Basic Interpreter Version 2.00, 2.10, or 3.00, or in Microsoft Basic Compiler 1.00 for the Apple Macintosh.
INPUT; "Display (D) current image file or Append (A) to file?:,r$
CLS
IF r$ <> "A" AND r$ <> "a" THEN GOTO display
again:
   INPUT "Copy a picture from the Scrapbook then hit RETURN",r$
   CLS
   OPEN "Clip:Picture" FOR INPUT AS #1
      lenpic% = LOF(1)  ' Get length in bytes of clipboard picture.
      image$ = INPUT$(lenpic%,1)  ' Put picture into string variable.
   CLOSE#1
   Picture,image$   ' Display the retrieved picture for confirmation
   OPEN "Stored Images" FOR APPEND AS #2  ' Open a file for images.
   PRINT#2,lenpic%    ' In one record, write length of image string.
   PRINT#2,image$     ' In next record, write image string variable.
   CLOSE#2
   INPUT "Append another image to images file? (Y/N)",r$
   CLS
   IF r$ = "y" OR r$ = "Y" THEN GOTO again
Display:
   DIM p$(64)    ' String array to hold up to 64 pictures.
   OPEN "Stored Images" FOR INPUT AS #1   ' Opens Stored Images file.
   imagenum = 0
   WHILE ( imagenum < 64 ) AND NOT EOF(1)
      imagenum = imagenum + 1
      INPUT #1,n   ' Get length of image string we stored earlier.
      p$(imagenum) = INPUT$(n,1)  ' Input image into string array.
      extra$ = INPUT$(1,1)     ' Skip past ASCII 13 (RETURN) byte
   WEND                        ' that terminates image record.
   CLOSE #1
   WHILE 1
      FOR j = 1 TO imagenum
         Picture,P$(j)  ' Draw each stored picture.
         FOR Y=1 TO 2000
         NEXT ' This pauses briefly so you can see picture.
         CLS
      NEXT
      INPUT "(R) Redisplay, (D) Delete Stored Images, (S) Stop";r$
      IF r$ = "D" OR r$ = "d" THEN KILL "Stored Images" : GOTO again
      IF r$ = "S" OR r$ = "s" THEN STOP
   WEND
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB37318


BUG: Dynamic Array Element in OCT$/HEX$ Return Bad If Compiled (37320)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    The OCT$ and HEX$ functions return erroneous results when the following three conditions are met:
    1. The parameter passed to OCT$ or HEX$ is an array element.
    2. The array is dynamic.
    3. The program is compiled.
    The code sample below demonstrates the problem.

    Microsoft has confirmed this to be a bug in the compiler in QuickBasic 1.00 for Macintosh. We are researching this problem and will post new information as it becomes available.

    The OCT$ and HEX$ functions work correctly when run within the QuickBasic environment. To work around this problem in the compiled version, do any of the following:
    1. Assign the array element to a temporary variable and pass the temporary variable to the OCT$ or HEX$ function.
    2. Make the array static.
    3. Pass the array element to the OCT$ or HEX$ function in an expression, such as OCT$(array%(1)+null%).

    More information

    Both the decimal math and binary math compiled versions demonstrate the problem. Compile the program below with the following options selected (i.e., do not compile with "Make All Arrays Static"):
    1. Include The Runtime Code
    2. Launch After Compiling
    3. Use Default Window
    4. Use Default Menu
    The following is a code example:
    DIM array%(1)
array%(1) = 0
'      Incorrect output using array element:
PRINT OCT$(array%(1))      'Output is: 37774600000
PRINT HEX$(array%(1))      'Output is: FFF30000
'      Correct output with a temporary variable:
temp% = array%(1)             'Assign to a temporary variable
PRINT OCT$(temp)             'Output is: 0
PRINT HEX$(temp)             'Output is: 0
'      Correct output with an expression:
null% = 0
PRINT OCT$(array%(1)+null%)      'Output is: 0
PRINT HEX$(array%(1)+null%)      'Output is: 0
END
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: kbbug KB37320


REM $INCLUDE Versus Merge in QuickBasic Compiler & Interpreter (37425)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    In Microsoft QuickBasic for the Apple Macintosh, the REM $INCLUDE metacommand is only used in the compiler (as are other metacommands) and is ignored in the interpreter environment. Placing a REM $INCLUDE metacommand in your source file makes the compiler insert an external text file containing additional program code at compile time.

    The Merge command acts similar to the $INCLUDE metacommand; however, Merge only works within the QuickBasic interpreter environment. The Merge command appends a text file to the end of the current source file in memory.

    More information

    Using a combination of the $INCLUDE and $IGNORE metacommands, you can write a program source file that is compatible as both a compiled and interpreted program.

    You can use the $INCLUDE metacommand to bring in compiler-specific code. The $IGNORE ON and $IGNORE OFF metacommands can be used to set aside code for the interpreter only. See the example code skeleton below.

    The following is a code example:
    REM $INCLUDE: 'text file for compiler only'
REM $IGNORE ON
PRINT "This is only used in interpreter; compiler ignores this line.
REM $IGNORE OFF
PRINT "This is used by both compiler and interpreter."
END
    Below is the $INCLUDE file, called 'text file for compiler only':

    PRINT "This line is only included and executed in the compiled program."
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB37425


"File Not Found" or Hang Using Init with Macintosh QuickBasic (37884)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    "Init" files are placed in the Macintosh System folder and are installed as memory-resident programs at boot time.

    The following Init files have been reported to cause various problems with Microsoft QuickBasic 1.0, 1.0a, and/or 1.0b for Apple Macintosh. Reported problems include system errors (bombs), hanging, or a "File Not Found" error at compile time:

    Super Laser Spool
    Super Spool*
    Grappler (print spooler)
    MacBuffer, from Egatron
    Beep Sound
    Guardian
    Short Lib
    Easy Menus, from CE Software
    Quote Init
    Pyro
    Menufonts
    Quickeys, from CE Software (reported to cause system hang or error when using QuickBasic's Alert Demo sample program)
    InitPicker
    Backgrounder (According to a customer, this printer Init caused a "Too many files open" error at compile time in QuickBasic.)
    HeirDA (a menu expander, reportedly caused the QuickBasic 1.0b compiler to stop with error "53", (File Not Found))
    Vaccine 2.0 (A customer reported that he couldn't compile his program when running on Apple System 6.0.7 or 6.0.8 with the Vaccine 2.0 Init program in memory.)

    * It has been reported that the Microsoft Basic Compiler 1.0 and the Microsoft Basic Interpreter version 3.0 work correctly while Super Spool version 5.0 is resident in memory.

    More information

    This Init-incompatibility list originates from Microsoft customers and has not been confirmed by Microsoft. Microsoft cannot guarantee compatibility with third-party Inits or memory-resident software.

    If you find that compiling or running a program results in an unusual error or it hangs the system, remove all Init files from your Macintosh System folder and reboot. If this procedure corrects the problem, you should reinstall the Init files one by one to determine which Init or combination of Inits caused the interference.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB37884


Macintosh QB Limits for Names, Strings, Numbers, Arrays (37895)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Listed below are the various limits to QuickBasic 1.00 language for the Macintosh. Note: some of these are incorrectly stated in Chapter 1.9 (Internal Representation of Numbers) of the "Microsoft QuickBasic 1.00: Basic Language Reference" manual.

    More information

    The list of limits is as follows:
    Variable Name Length: minimum 1  character
                      maximum 40 characters

String Length:        minimum 0  character
                      maximum 32,767 characters

Integers:             minimum -32768
                      maximum 32767

Long Integers:        minimum -2,147,483,648  maximum 2,147,483,647

Single Precision (positive):
  Decimal (d) version: minimum 9.99999 E-64   maximum 9.99999 E+62
  Binary  (b) version: minimum 1.401298 E-45  maximum 3.40283 E+38
  (Incorrect on page 36)

Single Precision (negative):
  Decimal (d) version: minimum -9.99999 E-64   maximum -9.99999 E+62
  Binary  (b) version: minimum -3.402823 E+38  maximum -1.401298 E-45
  (Incorrect on page 36)

Double Precision (positive):
  Decimal (d) version: minimum 9.9999999999999 D-64
                       maximum 9.9999999999999 D+62

  Binary  (b) version: minimum 4.940656458412465 D-324
                       maximum 1.797693134862315 D+308
  (Incorrect on page 36)

Double Precision (negative):
  Decimal (d) version: minimum -9.9999999999999 E-64
                       maximum -9.9999999999999 E+62
  Binary  (b) version: minimum -1.797693134862315 D+308
                       maximum -4.940656458412465 D-324
  (Incorrect on page 36)

Array Size: Available memory

Number of Array Subscripts Allowed Per Dimension: maximum 32,767

Number of Array Dimensions Allowed:
  Compiled:                minimum 1,  maximum 7
  Interpreter Environment: minimum 1,  maximum 255
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB37895


INPUT Statement Removes Unquoted Leading and Trailing Spaces (37897)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.01
  • Microsoft QuickBasic 1.02
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 2.0
  • Microsoft QuickBasic 2.01
  • Microsoft QuickBasic 3.00
  • Microsoft QuickBasic 4.00
  • Microsoft QuickBasic 4.0B
  • Microsoft QuickBasic 4.50
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.10
  • Microsoft GW-Basic Interpreter 3.20
  • Microsoft GW-Basic Interpreter 3.22
  • Microsoft GW-Basic Interpreter 3.23
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    In all versions of Microsoft Basic, the INPUT statement will remove leading and trailing spaces without quotation marks from an input string. The following two processes will help you work around this behavior:

  • Put double quotation marks around the input string.
  • Use LINE INPUT into a string variable.

    • More information

    Code Example

    ' Run this program and input the following with leading and
' trailing spaces:       test
INPUT X$
PRINT X$,LEN(X$)
' You must surround leading and trailing spaces in your input with
' double quotation marks to make them significant: "    test    "
' or else use LINE INPUT:
LINE INPUT X$
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB37897


Macintosh QuickBasic Change: Register-Based Toolbox ROM Call (38070)

Summary

The Toolbox statement on Page 501 of the "QuickBasic for Macintosh: Language Reference" manual should be corrected to read as follows:

ToolBox "R",Trapnum%,ReturnArray&(0),(a0&),(a1&),(d0&),(d1&),(d2&)

Also, the two occurrences of "ReturnArray(0)%" on Page 501 should be replaced with "ReturnArray&(0)".

The Toolbox statement on Page 499 is missing trapnum%, and the registers should be passed by value. Page 499 should be changed to read as follows:

ToolBox "R",Trapnum%,ReturnArray&(0),(a0&),(a1&),(d0&),(d1&),(d2&)

More information

Page 501 of the "QuickBasic for Macintosh: Language Reference" manual correctly specifies that the parameters of a register-based ROM call must be a long integer, but the example provided incorrectly shows these values typecast with % (short integer). The values passed to a register-based ROM call should be a long integer (&), except for trapNum%.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB38070


DialoB Should Be DialoG on Page 77 "QB for Macintosh Ref" (38077)

Summary

The example on Page 77 of the "QuickBasic for Macintosh: Language Reference" manual is incorrect. The following line
   WHILE DialoB(0) <> 1 :WEND
should read as follows:
   WHILE DialoG(0) <> 1 :WEND
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB38077


Must Initialize Toolbox-Routine Parameters; GetDirName Sample (38374)

Summary

The first reference to a variable cannot be in a toolbox-library routine. All variables used with library routines must be explicitly initialized (assigned to a certain value) before you use them with a library statement. If this is not done, incorrect program behavior may occur, as shown in the example below.

QuickBasic Does NOT warn you about uninitialized variables passed to toolbox-library routines, thus you must remember to initialize them.

Note that QuickBasic Does warn you with a "Type Mismatch" message at run time if you pass the incorrect variable type (string, integer, single precision, or double precision) to a toolbox routine or to many calls of the ToolBox statement. The type-checking information for a toolbox-library routine is stored in that routine's MBLC resource in QuickBasic. For the ToolBox statement, which is a special MBLC routine, the type-checking information is stored in the MBTS resource in QuickBasic and can be modified.

More information

GetDirName is a toolbox routine that returns the current folder path. Calling GetDirName with an uninitialized string variable appears to work, but afterwards, all other uninitialized string variables are improperly initialized to the pathname returned by GetDirName. The following program demonstrates the behavior in the QuickBasic interpreter:
   cls
   ' x$=""     ' Must add this line to correct the bad behavior.
   GetDirName 0, x$
   print x$
   print y$  ' y$ now incorrectly contains the same as x$
   print z$  ' z$ now incorrectly contains the same as x$
The memory environment in the QuickBasic interpreter is confused after running the above program, and you must Quit then restart QuickBasic to eliminate problems. You must add the statement x$="" to make the program work correctly.

The following is taken from Page 420 of the "QuickBasic for Macintosh: Basic Language Reference" manual:
   "E.2.3.1 Initializing Variables

   The first reference to a variable cannot be in a ToolBox statement.
   All variables used with library routines must be explicitly
   initialized (declared to be a certain value) before you use them
   with a library statement. This initialization requirement does not
   apply to array variables, since the elements of an array are
   automatically initialized to 0 when the array is dimensioned.
   However, arrays must be dimensioned or referenced in the source
   code before being referenced in a library call."
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB38374


Statement Mover Is in Tools Folder, Not in QB Demos Folder (38499)

Summary

On Page 418 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual, Section E.1.2 incorrectly states that the Statement Mover program appears in the QB Demos folder on the Examples disk. Page 418 should be corrected to say that the Statement Mover program appears in the Tools folder on the Examples disk.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

The Statement Mover program allows you to create smaller applications by removing unneeded library routines from your compiled application. The Statement Mover included in the Tools folder is a QuickBasic source file, and can be either run inside QuickBasic or else compiled to an application (" apl") file and launched (double-clicked) from the Finder. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB38499


About, WAIT Are Reserved and Unimplemented; Renum Misspelled (38500)

Summary

The following are three corrections to the "Basic Reserved Words" list in the "Microsoft QuickBasic for Apple Macintosh: Basic Language Reference" manual (Appendix B):

  1. The Basic reserved word About (*) is not listed on Page 369 and needs to be added to the list of Basic Reserved Words.
  2. On Page 370, the reserved word Renum (*) is misspelled as Remum.
  3. On Page 371, the reserved word WAIT needs to be marked with an asterisk (*), which means that it is reserved but not implemented.
The words About, Renum, and WAIT are NOT implemented in QuickBasic but they ARE "reserved," which means they cannot be used as names for variables or labels. Words that are reserved but not implemented are marked with an asterisk (*) on Pages 369-371 of the manual.

More information

When you type a reserved word into the QuickBasic List window and press the RETURN key, the word becomes bold-faced. If the reserved word is not implemented, then you get a "Syntax Error" when you try to run or compile the program.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB38500


Changing Macintosh System Can Make QuickBasic Fail to Run (38641)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The QuickBasic Settings file stored in the System Folder will not allow QuickBasic to load if there has been a system modification or change since the last time it was open.

    If you have used QuickBasic 1.00 for the Apple Macintosh on any given version of the system, then you have installed a new version of the system (such as System Version 6.0.2). QuickBasic will begin loading, but it only will momentarily run before returning to the desktop.

    To correct the problem, delete the QuickBasic Settings file from the system folder; this forces QuickBasic to build a new one.

    More information

    Microsoft QuickBasic 1.00 for the Apple Macintosh has the following system requirements:

    1. A Macintosh with a 128K ROM (such as the Macintosh Plus, Macintosh SE, or Macintosh II).
    2. System Version 4.10 or later.
    3. Finder Version 5.50 or later.
    4. Two disk drives, at least one of which must handle 800K disks.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB38641


Example ToolBox Routine for Moving a WindOW; System Can Bomb (39094)

Summary

You can easily cause a System Error or cause garbage in the QuickBasic List window if you pass incorrect parameters to the ToolBox statement in QuickBasic for Macintosh. (You must usually restart the Macintosh after a System bomb. ReOPENing the file often corrects the garbage in the List window.)

ToolBox is a powerful statement that lets you make many Macintosh ROM traps; however, you must be cautious to pass only the correct parameters to ToolBox.

Below is an example of how to correctly pass parameters to the ToolBox statement to programmatically move a window defined with the QuickBasic WindOW statement.

More information

The example below shows how to invoke a ROM trap called MoveWindow with a ToolBox statement. MoveWindow is defined on Page 289 of Volume I of "Inside Macintosh" (published by Addison-Wesley). MoveWindow is defined in Pascal as follows:
   Procedure MoveWindow (theWindow:WindowPtr;
                         hGlobal,vGlobal:Integer; front:Boolean);
To call this ROM routine, you must match the parameters to the expected type. It is important to note that in Pascal, all parameters are passed by value unless they are preceded by VAR, in which case they are passed by reference.

To call MoveWindow, you need to pass a pointer to the window that you want to move, two integer values for the horizontal and vertical distance to which you want the window to move, and a boolean value for determining if the window is in the foreground or background. Because Basic passes parameters by reference, you must put parentheses around the variable to pass it by value. The correct syntax to call MoveWindow from QuickBasic is as follows:
   ToolBox "PQ",&HA91b,(Winptr&),(hglobal%),(vglobal%),(front%)
The "PQ" is the call type. The "P" means the call is to a stack-based procedure with no return value, and the "Q" allows calls to be made to routines that are not listed in the resource. A complete description of all of the call types can be found on Page 499 of the "QuickBasic for Macintosh: Language Reference" manual.

The second parameter, &HA91b, is the ROM trap number. These trap numbers can be found in Appendix C of Volume III of "Inside Macintosh."

The third parameter (Winptr&) is a pointer to a window that you have created. Because this variable contains the pointer value (address) of the beginning of the window, you need to pass it by value, which is what the ROM routine is expecting. To pass the variable by value, enclose the variable in parentheses.

The fourth, fifth, and sixth parameters must also be passed by value; therefore, they must also be enclosed in parentheses.

The following is a complete QuickBasic program that opens a window and then moves it after you press a key:
Toolbox "i"
WindOW 2, "test window",(10,40) - (250,200),1
w2& = 0
GetWindow w2&        'returns a pointer of the current window
vglobal% = 150
hglobal% = 300
front% = -1         '-1 for true
PRINT "Hit any key to move window"
WHILE INKEY$ ="":WEND
Toolbox "PQ",&HA91B,(w2&),(hglobal%),(vglobal%),(front%)
WHILE INKEY$ = "":WEND
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB39094


How to Pop Up a Desk Accessory from Macintosh QuickBasic (39095)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    A Macintosh QuickBasic program can make a desired desk accessory pop up (as the front-most window) by using the ToolBox statement to invoke the OpenDeskAcc ROM trap.

    To open a desk accessory with the ToolBox trap, OpenDeskAcc, you must pass the desk accessory name beginning with a null (zero-value) byte, i.e., CHR$(0), as shown below.

    More information

    The code example below will pop up the Control Panel desk accessory from a QuickBasic program. Changes that you make in the Control Panel settings are retained after termination of the program. All currently-installed Macintosh desk accessories can be popped up in this manner.

    The desk accessories are located in the Apple menu in the upper left corner of the Macintosh Desktop. You can install/un-install desk accessories with the Font/DA Mover program provided on most Apple System disks. Common desk accessories include the Control Panel, Chooser, Scrapbook, and Calculator.

    The following is a code example:
    Toolbox "i"
deskacc$ = CHR$(0) + "Control Panel"  'Null byte before name
refnum% = 0
Toolbox "WQ", &H9B6, deskacc$, refnum%
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB39095 kbAudDeveloper


FIX: Command+PERIOD During LPRINT May Hang Mac QuickBasic (39096)

Symptoms

If you press Command+PERIOD to break (stop) the program during the execution of an LPRINT statement, the system can hang or give a System Error.

The best workaround is to avoid pressing Command+PERIOD during the execution of an LPRINT. Alternatively, you may OPEN the device name "LPT1:" or "Lpt1:Prompt" as #n and output using PRINT#n, which allows you to abort printing with Command+PERIOD.

Microsoft has confirmed this to be a bug in QuickBasic 1.00 for the Macintosh . This problem is corrected in QuickBasic version 1.00b for Macintosh .
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB39096


FIX: Bad Compiled Floating Point w/ Static Arrays & 68020 Code (39097)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    The compiler in QuickBasic 1.00 for Macintosh has a problem optimizing FOR...Next loops that contain single- or double-precision static arrays when you compile with the "Generate 68020 code" option. Incorrect floating point results can occur.

    Microsoft has confirmed this to be a bug in version 1.00. This problem is corrected in QuickBasic 1.00b for Macintosh .

    You can avoid this problem by doing any of the following:

    1. Compile without the "Generate 68020 code" option.
    2. Use only dynamic arrays (avoid static arrays) in FOR...Next loops. (For example, don't compile with the "Make All Arrays Static" option if you have single- or double-precision arrays in FOR...Next loops.)
    The problem does not occur in the QuickBasic interpreter environment (since it does not take advantage of the 68020 chip).

    More information

    With the "Generate 68020 code" compiler option and an array defined as static, the compiled QuickBasic program below gives bad floating-point results at run time in assignments to the temporary variable and array elements in the FOR...Next loop.

    The sample compiled program gives the Correct results if you compile Without the "Generate 68020 code" option, or if you make the array dynamic, or if you use Array(I)=SQR(A) instead of assigning the square root to the intermediate variable X.

    This problem applies only to QuickBasic 1.00, and does not apply to the older Microsoft Basic Compiler 1.00 for Macintosh, which does not offer an option to take special advantage of the 68020 chip. (The 68020 chip is the processor in the Macintosh II computer.)

    In the example below, when a temporary variable accepts a value returned by the SQR() function and is then assigned to a static array element in the FOR...Next loop, some array elements are incorrect; more elements are bad after exiting the loop. The following conditions must be present to produce this problem:

    1. The program must be compiled.
    2. The "Generate 68020 Code" compiler option must be selected.
    3. The "Make All Arrays Static" compiler option must be selected.
    4. A temporary variable must be used (as shown) for the return value of the SQR() function before assigning it to the array element.
    The following code example demonstrates the problem:
    DEFDBL A-H,K-Z : DEFINT I,J
Im$ = "###.########"
DIM Array(4)
FOR I = 1 TO 3

    X = SQR(A)
    Array(I) = X
    ' Array(I)=SQR(A) ' Workaround: Add this & delete above 2 lines.
    PRINT USING Im$;  I, Array(I)

NEXT
PRINT array(1)
PRINT array(2)
PRINT array(3)
    The compiled program displays the following Incorrect output:
       1.00000000000  1.00000000000
   2.00000000000  0.00000000000
   3.00000000000  1.73205089569

   1.000000001396983
   0
   1.73205089569092
    In the QuickBasic interpreter, the following Correct output displays:
       1.00000000000  1.00000000000
   2.00000000000  1.41421353816
   3.00000000000  1.73205089569

   1
   1.414213538169861
   1.732050776481628
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: kbbug KB39097


TIMER Example; Sieve of Eratosthenes Prime Number Correction (39188)

Summary

On Page 333 of the "Microsoft QuickBasic for Apple Macintosh: Basic Language Reference", the TIMER function Example (the Sieve of Eratosthenes benchmark program) is supposed to find prime numbers. However, it mistakenly finds some numbers that are not actually prime.

The Sieve of Eratosthenes benchmark program on Page 333 should be replaced with the version below, which correctly returns only prime numbers.

More information

The replacement program is as follows:
defint a-z
size=8191
dim flags(8191)
count=0
for i=2 to size
  flags(i)=-1
next
for i=2 to sqr(size)
  if flags(i) then
    for k=i*i to size step i
      flags(k)=0
    next
  end if
next

for i=0 to size
  if flags(i) then print i; : count = count + 1
next
print
print count; "primes"
while mouse(0): wend
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB39188


No Line Continuation in Macintosh QuickBasic; Break Long FIELD (39240)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    Line continuation is not implemented for Macintosh QuickBasic 1.00, or the earlier Basic Compiler 1.00, or the earlier Basic Interpreter (Versions 1.00, 1.01, 2.00, 2.10, or 3.00) for Apple Macintosh.

    You might want a line continuation for better LIST window visibility for very long, single-line IF...Then statements. To improve the structure of long IF statements, we recommend using a multi-line, block IF ... THEN ... ELSEIF ... END IF structure, or a SELECT CASE statement.

    Another reason you might want to continue a line is to make a FIELD statement that is wider than the LIST window completely visible on multiple lines. Below are some suggestions for improving the readability of long FIELD statements.

    More information

    The following information describes several methods for handling long FIELD statements:
    1. To pack as many fields as possible on the FIELD statement line, do the following:

      1. Use one-character variable names for the fields.
      2. Use DEFSTR, so you don't have to specify a '$' after the string variable names.
      These steps make your program less readable, however. There are several better and easier alternatives below.
    2. You can FIELD the entire buffer as one string and extract pieces of the string using the MID$ function, as in the following:
         OPEN "TEST" AS #1  'Assume data file TEST already has data in it.
   FIELD #1, 512 AS buffer$   'fields entire buffer in one string
   GET#1,2   ' Get record number 2 (written by some other program).
   'extract the 8 bytes beginning at byte 500:
   component1# = CVD(MID$(buffer$,500,8))
   'extract a long integer beginning at byte 508:
   component2& = CVL(MID$(buffer$,508,4))
      You could also write a function to extract the fields, such as the following:
         ' This is a function to extract a long integer from buffer$.
   ' FieldOffset% is the byte offset where the data starts.
   ' Note that buffer$ doesn't have to be a fielded string, it
   ' just has to be a minimum of FieldOffset% + 4 bytes long.
   DEF FNL&amp;(FieldOffset%) = CVL(MID$(buffer$, FieldOffset%,4))
    3. The easiest method is to break up the FIELD statement into more than one FIELD statement for the same file number, using a dummy placeholder string to account for the data previously fielded in that same buffer, as in the following:
         FIELD #1, 4 AS partNof$, 96 AS pricef$   '4+96=100 total bytes
   FIELD #1, 100 AS dummy1$, 4 AS sizef$, 2 AS partTypef$
   FIELD #1, 106 AS dummy2$, 10 as x$
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB39240 kbAudDeveloper


Macintosh QuickBasic Manual Correction: Array1, Array2 Sizes (39242)

Summary

Below is a correction for the second paragraph on Page 18 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual. This paragraph should be changed to read as follows:

"The first array, Array1, has 10 integer elements, so its values take 20 bytes of memory. The second array, Array2, has 110 double-precision elements, and its values require 880 bytes of memory."

Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB39242


Figure 7.3 Is Non-Existent: Should Be Corrected to Figure 2.2 (39243)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh

    • Summary

    Under "Wave Elements Explained," on Page 345 of the "QuickBasic for Macintosh: Basic Language Reference" manual, the paragraph should refer to Figure 2.2, which is on the same page, instead of the non-existent Figure 7.3. Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB39243


Macintosh QuickBasic Runs OK on the Macintosh IIX Computer (39360)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Microsoft QuickBasic for the Macintosh will run on the Macintosh IIX computer.

    The Macintosh IIX computer has a 68030 processor, a new math coprocessor, and a 1.44-megabyte disk drive. QuickBasic 1.00 is not able to generate 68030 code and cannot take advantage of the special features of the 68030 chip, but QuickBasic's code can still be used on this hardware.

    Microsoft has not announced plans to upgrade QuickBasic to take special advantage of the new capabilities in the 68030 chip. Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB39360


Mac QuickBasic File Browser Example Views & Prints Text Files (39363)

Summary

File Browser is a simple utility program that allows you to view and print text files. The source code for this program is provided on the Examples disk. There is no separate documentation for this program. It is well documented in the source file and meant to be an example program that demonstrates file manipulation. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB39363


Use "LPT1: Prompt" for Mailing Labels/Other Printer Paper Sizes (39576)

Summary

OPENing the "Lpt1:Prompt" device name in a QuickBasic program prompts you for various print options and Apple ImageWriter printer paper sizes, including the following:

US Letter (8.5 inches by 11 inches)
Mailing Label (1-inch form size)
R4 Letter
US Legal (8.5 inches by 14 inches)
Rolodex Card (3-inch form size)
Computer Paper (11-inch form length)

Changing the ImageWriter page size to 1-inch mailing labels or 3-inch Rolodex cards allows printing where a formfeed aligns to the next label or card in a spool. The Mailing Label and Rolodex options are not available to the Apple LaserWriter printer (or versions of Macintosh Basic prior to QuickBasic).

More information

You can select your desired printer driver in the Chooser in the Apple menu. The appropriate ImageWriter or LaserWriter driver file must exist in the System Folder.

ResEdit can be used to change the ImageWriter page length. This is explained in "Changing the Print Page Size with Prec" on Pages 156-157 of the "Microsoft QuickBasic for Apple Macintosh: User's Guide."

To read the "Lpt1:Prompt" settings that are clicked at run time, search for a separate article by querying on the following word:

GetPrintRecord

Note that you cannot suppress the automatic formfeed when the "LPT1:" or "Lpt1:Prompt" device is CLOSEd.

The following is a code example:
ON ERROR GOTO Erhandle
OPEN "Lpt1:Prompt" FOR OUTPUT AS #1
' An error occurs on the following statement if you clicked Cancel
' in the "Lpt1:Prompt" dialog box:
PRINT #1,"This IS Meant TO GO TO Printer"
CLOSE
label1:

   PRINT "This is the end."

END
Erhandle:

   E = ERR  ' assign error number to variable E
   PRINT "ERROR Number = "; E
   IF E = 52 THEN

     PRINT "YOU Clicked THE Cancel Button. Printing IS Canceled."

   END IF
   RESUME label1     ' Resumes execution at label1. File not opened.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB39576


BUG: Extra $ with PRINT USING "$$" Format in Mac QuickBasic (39589)

Symptoms

Within the interpreter of Microsoft QuickBasic 1.00 for the Macintosh, the floating dollar sign ("$$") format of the PRINT USING statement does not work correctly when multiple variables are used in the argument list. The problem does not occur in compiled programs.

The code example below demonstrates the problem. If the first argument uses the floating dollar sign ("$$") in the format string, any subsequent arguments are incorrectly displayed with the floating dollar sign.

A workaround for this problem is to break up the PRINT USING statement into several PRINT USING statements so that each has only one argument.

Microsoft has confirmed this to be a bug in Version 1.00. We are researching this problem and will post more information as it becomes available.

More information

The following code example shows the problem:
 x = 0: y = 1
 PRINT USING "$# ##"; x, y     ' Not a floating dollar problem.
 PRINT USING "$$### ##"; x, y  ' This is a floating dollar problem.
The program above gives the following output:
$0  1             <---- Output OK.
   $0 $1          <---- Problem: Should be no $ on second argument.
A workaround is to print the variables in separate PRINT USING statements:
 PRINT USING "$$###"; x;       ' These two will work. Use semi-colon
 PRINT USING "##"; y           ' to concatenate output.
 WHILE INKEY$ = ""
 WEND
The following is the output from the above workaround:
   $0  1
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB39589


BUG: MBPC Library Fails in Compiled Mac QuickBasic w/o Libinit (39870)

The information in this article applies to:
  • Microsoft QuickBasic 1.00

    • Symptoms

    This article applies to programs compiled in QuickBasic 1.00 for the Macintosh that use the Library statement to access assembly-language routines or MBPC pure code resources that you have created yourself in assembler, C, or Pascal (as documented in Appendix E.9 "Building Your Own Libraries" in the "Microsoft QuickBasic for Macintosh: Language Reference").

    This article does not apply to using the Library statement with the MBLC routines that are built into QuickBasic.

    If CALLing your customized Library routine fails (such as by returning garbage, a system error, or a system hang) in a compiled program, but works correctly in the interpreter, you need to CALL Libinit right after the Library statement in the compiled program.

    Microsoft has confirmed this to be a bug in QuickBasic 1.00. We are researching this problem and will post new information as it becomes available.

    More information

    Programs compiled in QuickBasic 1.00 for the Macintosh fail to automatically CALL Libinit in programs using the Library statement. This behavior differs from the QuickBasic interpreter environment (and the earlier Basic compiler Version 1.00 and interpreter Version 3.00), which automatically invokes CALL Libinit in programs using the Library statement.

    To make the program run as a QuickBasic compiled program, the following statement should be added as shown right after the Library statement:
       Library "YourCustomLibrary"
   IF SYSTEM(4) THEN CALL Libinit
    In the above IF statement, CALL Libinit will execute in a compiled program, and will be ignored in an interpreted program. The SYSTEM(4) function returns 1 ("true") when compiled, and 0 ("false") when interpreted.

    Note: The MBLC (Macintosh Basic Library Code) resources built into QuickBasic do not require the CALL Libinit statement (even if you put them into an external library file that can be opened with the Library statement).

    Note: Instead of using Library statements that access external libraries (as done above), Microsoft recommends doing the following:

    1. Don't use the Library statement. Instead, include all required resources (including MBLC resources and MBPC pure code resources) into the application (and source code) itself. Then you do not need a Library statement, because the application's resource fork is automatically open at run time, and all stored code and pure code resources are automatically available for calling.
    2. Explicitly CALL all needed routines, including Libinit (if needed by your MBPC pure code resources). Be sure to give all routines unique names; you may want to rename Libinit to avoid confusion.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB39870


Library Statement "INPUT Past END" If Bad or Empty Library (40038)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    When the Library statement returns the error message "INPUT Past END," then the file specified as the argument of Library does not contain any proper code routines. This error can occur due to any of the following reasons:

    1. The filename is not that of a valid library, and the resource fork of the file contains no library routines.
    2. The resource fork of the library file has been corrupted. If it is corrupted, you must copy or create a new library file from a backup or from the Basic release disk.
    This information applies to Microsoft QuickBasic 1.00, Basic Compiler 1.00, and Basic Interpreter Version 3.00 for the Apple Macintosh.

    More information

    You can use Apple's ResEdit program, or Basic's Statement Mover program to move valid Library routines into the resource fork of a file.

    Library routines are stored as MBLC resources in the resource fork of Microsoft QuickBasic (b) or (d).

    In the earlier Basic Compiler 1.00 and Interpreter Version 3.00, Library routines are provided as Code resources in the ToolLib file on the Basic ToolBox disk (disk 2 of 2).

    The following is a code example of Library statement syntax:
       Library "ShortLib"
   Library "ToolLib"
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB40038


Closing Active Macintosh Window Doesn't Activate Other Window (40080)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    In a Macintosh Basic application that uses multiple windows, when the current active window is closed, another window is not automatically activated. Edit FIELDs appear as if they are waiting for input, but keystrokes are not accepted because the WindOW is not yet active. Your program must activate the desired window with the WindOW n statement.

    This information applies to Microsoft QuickBasic 1.00, Basic Compiler 1.00, and Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

    More information

    Your program can trap dialog events (such as the closing of a window) with the ON DialoG GOSUB statement, which jumps to a specified subroutine when the event occurs. In the event-handling subroutine, you can invoke the DialoG(0) function, such as x=DialoG(0), and test x to find out what kind of dialog event has occurred. If DialoG(0) returns a value of 4, it means that a window was closed. The DialoG(4) function returns the number of the window that was closed. Based on this information, your program can activate one of the other remaining windows using the following statement, where n is the number of the window to activate:

    WindOW n

    The following QuickBasic program creates two windows, and when the second window is closed, the first window becomes the active window:
    ON DialoG GOSUB closew
DialoG ON
WindOW 2,"Test Window 1",(10,30)-(200,200),1
Edit FIELD 1,"",(1,50)-(50,70),1
WindOW 3, "Test Window 2",(100,100)-(350,350),1
Edit FIELD 2,"",(110,150)-(150,170),1
WHILE 1:WEND
END
closew:
IF DialoG(0) <> 4 THEN
   RETURN
ELSE
   WindOW 2
   RETURN
ENDIF
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB40080


Refresh Basic Windows with ON DialoG GOSUB or SetWindowPic (40083)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft Basic Compiler 1.00

    • Summary

    Microsoft QuickBasic for Macintosh and the earlier Microsoft Basic versions for Macintosh do not automatically refresh the contents of the output window if covered by any other window. Therefore, manipulating multiple windows in a program involves continually updating the contents of various windows.

    There are two alternatives that make your program refresh windows:

    1. When a window in a program needs to be refreshed, an event occurs that can be trapped with the ON DialoG GOSUB statement. Example 1 below demonstrates trapping the refresh event and then refreshing the screen in the event-handling subroutine. When the current output window needs to be refreshed, the DialoG(0) function returns a value of 5. Subsequently, the DialoG(5) function returns the number of the window that needs to be refreshed. You then can execute any graphics statements to refresh the window any way you desire.
    2. If your picture on a window will not be changing during the program, you can invoke the SetWindowPic routine to automatically handle refreshing, thus saving you from writing a window refresh handler for that window. Example 2 below gives a demonstration of using SetWindowPic to automatically refresh a window. An advantage of SetWindowPic is that it refreshes any window, even windows that are not the current output window.
    This information applies to Microsoft QuickBasic 1.0, 1.0a, and 1.0b for Apple Macintosh, to Microsoft Basic Compiler 1.0 for Macintosh, and to Microsoft Basic Interpreter version 3.0 for Macintosh.

    More information

    A window may need to be refreshed after various events, such as the following:

  • An alert box, window, or desk accessory was opened and closed on top of the window.
  • A window that has just been activated and brought to the front needs to be updated.
  • Another window was moved onto and then off of the window.
  • You sized the window larger in either the X or Y dimension, or you zoomed the window larger by clicking the zoom box. (The currently active output window does not need refreshing when zoomed smaller, and no refresh event occurs for it when zooming smaller.)
  • The window was moved partially off the screen, and then back on.
    • SetWindowPic is a very useful routine that lets you assign a static, unchanging picture to be refreshed automatically whenever necessary. SetWindowPic saves you from writing a window-refresh handler. In the QuickBasic environment, SetWindowPic refreshes the output window if overlaid by the List window, even when the program is stopped. However, SetWindowPic is not suitable for refreshing a picture that will change as the program progresses because it only refreshes an unchanging, static picture.

    SetWindowPic is an MBLC routine built into QuickBasic. SetWindowPic is a Library routine in the "ToolLib" file in the earlier Microsoft Basic Compiler 1.0 and Microsoft Basic Interpreter version 3.0 for Macintosh.

    Example 1: Refreshing with ON DialoG GOSUB, Handling Event 5

    Example 1 below is a sample QuickBasic program that demonstrates using the DialoG function to maintain the appearance of two output windows. The program allows you to move the windows over the top of each other, and so on, to cause refresh requests and see how the Basic program reacts to them.

    Note: A window generates a refresh event when it is initially opened.
    ON DialoG GOSUB DoDialog
DialoG ON
WindOW 1, "1", (1,40)-(220,180), 1
WindOW 2, "2", (222,40)-(440,180), 1
f$=FILES$(1)   ' Invokes file dialog box which overlays windows
WHILE INKEY$="":WEND   ' Press any key to end program.
END

' The following is the event-handler subroutine:
DoDialog:
  event%=DialoG(0)  ' Don't invoke DialoG(0) more than once in handler
                    ' or else the event sequence will be confused.

  SELECT CASE event%

    CASE 3   ' If DialoG(0) returned 3, a new window was clicked.
      WindOW DialoG(3)   ' Activate the clicked window.
    CASE 5   ' If DialoG(0) returned 5, a window needs refreshing.
      w=DialoG(5)   ' Returns the number of window needing refreshing
      WindOW OUTPUT w   ' Makes window w the current output window.
      ' Alternative idea here: IF condition THEN refresh differently.
      CLS
      PRINT "Refresh"; w
      FOR t=4 TO 100 STEP 2
        LINE (4,15)-(t*2, t+15),,b
      NEXT t
    CASE ELSE

  END SELECT
  RETURN
    Note: SELECT CASE (used above) is supported in QuickBasic (interpreter and compiler) and in the earlier Microsoft Basic Compiler 1.0, but is not supported in the earlier Microsoft Basic Interpreter version 2.0, 2.1, or 3.0 for the Macintosh. You can always replace a SELECT CASE statement with multiple IF...Then statements.

    Example 2: Refreshing with SetWindowPic

    ' Example using SetWindowPic for auto-refreshing of static picture.
' This program works in Microsoft QuickBasic 1.0, Basic
' compiler version 1.0, and Basic interpreter version 3.0.
' (Interpreter versions 2.0 and 2.1 do not support this program.)
' Library "ToolLib"  ' Add this statement only for Basic compiler 1.0
                     ' or Basic interpreter 3.0, not for QuickBasic.

ON DialoG GOSUB handle
DialoG ON
DIM a%(3)      ' Array of coordinates of the static picture's frame.
SetArray a%(0),1,1,110,245  ' Initialize coordinates of picture frame.
pic&=0   ' Handle to the static picture in heap space.
w&=0     ' Pointer to the window (2) which will contain static picture
WindOW 1,"Overlaying window",(1,40)-(300,200)
WindOW 2,"Auto-refresh Window",(20,60)-(320,220),5
GetWindow w&   ' Get pointer to currently active window (window 2).
OpenPicture a%(0),pic&   ' Subsequent graphics will define picture:
  ShowPen        ' Lets you see the picture as it is drawn.
  TextFont 4 : TextSize 9
  FOR J=1 TO 9

    FOR K=1 TO 4
      DrawText "1234567890"    ' DrawText is much faster than PRINT.
    NEXT
    PRINT   ' DrawText doesn't give carriage returns, so do a PRINT.

  NEXT
  DrawText "You can overlay window, and picture" : PRINT
  DrawText "will auto-refresh. Press any key to end."
  LINE (1,1)-(245,110)
ClosePicture             ' End of picture definition.
SetWindowPic w&,pic&;     ' Sets up picture pic& to be auto-refreshed.
WHILE INKEY$="" : WEND   ' Wait for key press.
SetWindowPic w&,0&       ' Turn off auto-refreshing.
DisposePicture pic&      ' Remove the picture from memory (heap).
END
' Below is an event handler subroutine to activate clicked window:
Handle:
  Event=DialoG(0)
  IF Event=3 THEN WindOW DialoG(3)  ' Activates clicked window.
  RETURN
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB40083


FIX: Date2Secs MBLC, Bad Seconds for Secs2Date (40086)

Symptoms

The Date2Secs routine (which is an MBLC routine built into QuickBasic for Macintosh) returns an incorrect number of seconds. When the number of seconds is passed back into the corresponding Secs2Date routine, an invalid date is produced.

Microsoft has confirmed this to be a bug in QuickBasic 1.00. This problem is corrected in QuickBasic 1.00b.

To work around the problem, it is possible to invoke QuickBasic's ToolBox routine with an equivalent Register-based ROM trap function, Date2Secs.

The program provided below demonstrates this procedure. Please remember to set up the date array as described in the "Microsoft QuickBasic for the Macintosh: Basic Language Reference" manual, page 493, before running this sample program.

For a complete description of the ROM routine, please refer to "Inside Macintosh" Volume II, page 379.

More information

The following is a code example:
'ON Entry OF THE ROM Routine
'  The array, d%, corresponds to the time/date record. The ROM
'routine expects the time/date record to be passed through the register
'a0, which is the first parameter after the returnarray&. The remaining
'registers are not used, so they are not included.
'ON EXIT OF THE ROM Routine
'   The returnarray& will contain the values of the registers that
'are passed back from the ROM routine. Register d0 will contain the
'seconds, which corresponds to returnarray&(2).

DIM d%(20),returnarray&(5)
d%(0)=1988
d%(1)=11
d%(2)=10
d%(3)=5
d%(4)=5
d%(5)=5
d%(6)=5
Secs& = 0
ToolBox "I"       'initialize toolbox
ToolBox "R",&HA9C7,returnarray&(0), d%(0)
PRINT "Number of seconds:"; returnarray&(2)
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB40086


BUG: DragGrayRgn Works Differently in QuickBasic (40140)

Symptoms

The program example shown below demonstrates how to work around a problem with the DragGrayRgn routine in QuickBasic 1.00 for Macintosh. The behavior of DragGrayRgn differs from the DragGrayRgn provided in Basic Version 3.00 or in the earlier Basic Compiler Version 1.00 for Macintosh.

Microsoft has confirmed this DragGrayRgn problem in QuickBasic 1.00. We are researching this problem and will post new information as it becomes available.

More information

The DragGrayRgn routine (which is an MBLC routine) in QuickBasic produces the following incorrect behavior:

DragGrayRgn copies the region into a frame (a border outline), forgets the handle to the original region (so that EraseRgn can't reference or erase it), and leaves you with just a frame outline (at the wrong coordinates) when you finish the drag.

The code example below demonstrates the necessary modifications to a Basic Version 3.00 routine to work around the problem. The program then behaves correctly as follows:

You click on the triangle, drag its outline to a new location, then release the button. At this time, the old triangle should be erased and the outline of the triangle that was dragged to the new location should be filled in.

To work around the problem in QuickBasic 1.00, copy the original region to a new region before the drag, and invoke DragGrayRgn with the new region.

The program example that follows shows a Basic Version 3.00 source code that uses DragGrayRgn which has been modified to make it run under QuickBasic 1.00:
'This example program is based on one published in Nibble Mac,
'Volume 3, Number 1, 1988, Page 59, Listing 2, DragGrayRgn Example.
'The example is shown modified to run in QuickBasic.
REM Library "ToolLib"   'Required for Basic 3.0, not for QuickBasic
WindOW 1,,(10,30)-(500,300),2
OPTION BASE 1
bool% = 0
FirstReg& = 0

   QBReg& =0               ' Required only for QuickBasic

DIM bnd%(4), pin%(4), p%(2), dis%(2)
SetRect bnd%(1), 0, 0, 490, 270
SetRect pin%(1), 0, 0, 490, 270
NewRgn FirstReg& : OpenRgn
MoveTo 50, 39 : Lineto 60, 21
Lineto 70, 39 : Lineto 51, 39
CloseRgn FirstReg&
PaintRgn FirstReg&

  NewRgn QBReg&                  ' Required only for QuickBasic
  CopyRgn FirstReg&, QBReg&      ' Required only for QuickBasic

WaitClick:
WHILE Mouse(0) <> 0 : WEND
WHILE Mouse(0) = 0 : WEND
GetMouse p%(1)
PtInRgn p%(1), FirstReg&, bool%
IF NOT bool% THEN DisposeRgn FirstReg& : STOP
' On the following line, QuickBasic uses QBReg& (instead of
' FirstReg& used in Basic 3.00):
DragGrayRgn QBReg&, p%(1), pin%(1), bnd%(1), 0, dis%(1)
EraseRgn FirstReg&
OffsetRgn FirstReg&, dis%(2), dis%(1)
PaintRgn FirstReg&
GOTO WaitClick
Note the following:

  1. For this program to run in Basic Version 3.00, you must change the following:

    1. Change all "&" characters to "!" (because Basic Version 3.00 doesn't support the long-integer data type).
    2. Remove all lines that are marked "Required for QuickBasic".
    3. Change the DragGrayRgn routine to use FirstReg instead of QBReg.
    4. The first line of the original program example in Nibble Mac referred to Library "DragGrayLib". You can use "ToolLib" more easily than "DragGrayLib". ("DragGrayLib" is a library file that you must build from Code resources taken from the "ToolLib" file in Basic Version 3.00. In Basic Version 3.00, you can use Statement Mover to move needed routines from "ToolLib" into "DragGrayLib", if you want a library smaller than "ToolLib".)
  2. The original DragGrayRgn routine in the Basic Version 3.00 ToolLib correctly remembers the region before the region is dragged with the mouse. The DragGrayRgn routine in QuickBasic requires the workaround solution shown.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB40140


BUG: OpenResFile "Bad File Mode" Opening Macintosh Application (40271)

Symptoms

In the interpreter in QuickBasic for Macintosh, the OpenResFile routine cannot open the resource fork of any Macintosh application [such as Microsoft Word, or a compiled QuickBasic "apl" file (which has a resource type of Appl)]. OpenResFile can open only the resource fork of external nonapplication files (such as QuickBasic's Demo Resources file, a text file, or a Basic source file). This problem doesn't occur for the OpenResFile statement in programs compiled in QuickBasic.

The error "Bad File Mode" (number 54) displays when you attempt to open a Macintosh application with the OpenResFile statement in the interpreter.

Microsoft has confirmed this to be a bug in the OpenResFile MBLC routine in the interpreter in Microsoft QuickBasic 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

To work around this problem in the interpreter, use the ToolBox statement as described below, or use a compiled program.

More information

If you want to open the resource fork of an external application, you must use the ToolBox statement (which is an MBLC routine in QuickBasic) instead of the OpenResFile statement (another MBLC routine). You need to call ToolBox to invoke the following low-level Macintosh File Manager routine:
   PBOpenRF ROM trap
Please see the Statement Mover program for an example. Another brief example is shown at the bottom of this article. Note: Only advanced Macintosh developers familiar with "Inside Macintosh" by Apple Computer (published by Addison-Wesley) should attempt to use the ToolBox statement.

The QuickBasic subprogram OpenFile, located in the Statement Mover source file, demonstrates how to use the ToolBox statement to open the resource fork of an application (or any file). (The Statement Mover program is found in the Tools folder on the QuickBasic release disk.)

For more information about low-level Macintosh File Manager routines (or other ROM traps accessible with the ToolBox routine), please refer to "Inside Macintosh."

More information about Statement Mover can be found starting on Page 99 of the "Microsoft QuickBasic for Macintosh : User's Guide," and on Page 418 of the "Microsoft QuickBasic for Macintosh : Language Reference."

Code Examples

The following code incorrectly produces the "Bad File Mode" error when run in the interpreter in QuickBasic (the "Test Apl" file opened by this program must be an existing external compiled application to duplicate the problem):
   ref% = 0
   OpenResfile "Test Apl", ref%
   PRINT ref%
   END
The following is a workaround:
   ref% = 0
   OpenResFileTrap% = &HA997
   toolbox "i"
   toolbox "WQ", OpenResFileTrap%,"Test Apl",ref%
   PRINT ref%   ' At this point you can use ref%, the resource file
   END          ' reference number, to access stored resources.

Background Information

Note that compiled programs that need to access their own resource fork must use the SYSTEM(7) function instead of using OpenResFile. However, a compiled program is free to use OpenResfile to open the resource fork of any file or application that is external to the current compiled program.

An interpreted program must use SYSTEM(7), not OpenResFile, to get the file reference number of its own source file. An interpreted program is free to use OpenResFile to open the resource fork of all external files except for application files, where you must use the above ToolBox statement as a workaround.

For more information about the SYSTEM(7) function and the OpenResFile routine, query on the following words:

SYSTEM(7) and OpenResFile

Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB40271


Macintosh Alternate Video Buffer Not Supported by QuickBasic (40372)

Summary

Using the alternate video buffer on the Macintosh is not recommended by Apple's programming guidelines. Because hardware access to the Macintosh video buffer may change in the future, we recommend that you do not create applications that depend on this buffer. Using PEEK and POKE to access the alternate video buffer is not supported by Microsoft QuickBasic for Macintosh and may result in run-time problems with your program. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB40372


Scroll Bar Cannot Be Placed in Right Bar of WindOW Type 1 or 7 (40373)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh

    • Summary

    Creating a window with type 1, 7, -1, or -7 with the WindOW statement in QuickBasic for the Apple Macintosh creates a window that has a title bar and a size box. A vertical box (a bar) in the window above the size box has proportions that seems to invite adding a scroll bar. However, when you place a scroll bar in this section of the window using NewScroll (which is an MBLC routine in QuickBasic), the scroll bar does not appear. This is a design limitation of window types 1, 7, -1, and -7 in QuickBasic.

    The area of the window directly above the size box is considered part of the window border. The border of a window is not a valid display area. An attempt to write on the border of a window is considered outside the window's display area and nothing is written by NewScroll (or any other statement).

    More information

    To work around this design limitation, a scroll bar can be placed flush with the outer edge of a window by using one of the other window types (2, 3, 4, 5, 6, -2, -3, -4, -5, or -6), which have only a narrow border. Another option is to place the scroll bar on the left-hand side of the window where the border is narrow in every window type.

    The following program shows two different types of windows. The window with a type of 1 does not allow the scroll bar to be flush against the right-hand side of the window, while window type 2 allows the scroll bar.

    The following is a code example:
    WindOW 2,"Test Window",(50,100)-(250,300),1
DIM scr%(5)
SetRect scr%(0),179,0,195,185
h&=0
vis%=1
min%=0
max%=5
value%=0
NewScroll h&,scr%(0),vis%,min%,max%,value%

WindOW 3,"Test Window 2",(275,90)-(450,295),2
SetRect scr%(0),162,0,175,205
h&=0
vis%=1
min%=0
max%=5
value%=0
NewScroll h&,scr%(0),vis%,min%,max%,value%
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB40373


BUG: Mac QuickBasic Renamed File Reverts to Old Compiled Name (40409)

Symptoms

If you rename a QuickBasic source file in the Finder (by making a Duplicate with the name "Copy of filename," or by just modifying the name in the Finder), then QuickBasic fails to update the MBAN 0 resource (stored in the source file) with the new application filename on a Macintosh II. As a consequence, when QuickBasic compiles the program, it will output a compiled application name using the old name instead of the new name.

This problem occurs only on a Macintosh II computer. The problem does not occur on an SE or Plus, where the MBAN 0 resource is properly updated with the new name.

Microsoft has confirmed this to be a bug in Version 1.00. We are researching this problem and will post new information as it becomes available.

To work around the problem, select the Compile AS... option instead of Compile on a Macintosh II. Compile AS... lets you rename the file as desired.

More information

Note: QuickBasic stores the name of the (potential) compiled application in the MBAN 0 resource of the source file of every program. The MBAN resource is documented in the Readme file and this KnowledgeBase (Query for MBAN).

The following steps duplicate the problem on a Macintosh II:

  1. On the Macintosh II Desktop, duplicate the Cones sample program with Duplicate from the Finder's FILE menu. This creates "Copy of Cones."

    The problem also occurs if you rename the file by editing the filename in the Finder.
  2. Load the "Copy of Cones" into QuickBasic (or the renamed file). The title bar shows: Listing of "Copy of Cones".
  3. Compile the program with the Compile option (not with Compile AS...) from the RUN menu.
  4. Now the APL application improperly has the following original name:

    "Cones APL"

    The name should be "Copy of Cones APL".
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB40409


Reviews of Macintosh QuickBasic 1.00 in MacWorld and Byte (40412)

Summary

The following magazines give a review of Microsoft QuickBasic Version 1.00 for Apple Macintosh:

  1. "Microsoft QuickBasic 1.0," MacWorld Magazine, February 1989; Pages 240-241
  2. "QuickBasic Comes to the Macintosh," Byte Magazine, January 1989; Pages 223-228

    Please note the error in Byte, Page 228. A sentence in the second paragraph incorrectly implies that a coprocessor will help speed up the decimal math version of QuickBasic. A coprocessor will only help speed the program if you compile in the Microsoft QuickBasic (b) binary math version and select the "Generate 68881 Code" option.
These reviews may interest customers who are thinking about buying QuickBasic for the Apple Macintosh. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB40412


BUG: SetOrigin Diff in Compiled vs. Interpreted Mac QuickBasic (40712)

Symptoms

The SetOrigin routine can be either called by name (with the SetOrigin MBLC routine built into QuickBasic), or invoked with the ToolBox statement (which can invoke the equivalent ROM trap).

The SetOrigin routine works differently when compiled rather than interpreted in QuickBasic 1.0 for the Macintosh. SetOrigin appears to work differently than documented for the interpreter and compiler.

After invoking SetOrigin in a compiled program (either with the SetOrigin MBLC routine or the ToolBox ROM function call), subsequent graphics routines (such as Circle or LINE) can only draw to coordinates where both x and y components are positive.

On the first run in the interpreted mode, the program behaves the same as the compiled version. But if you abort the program and run it a second time in the interpreter in the same session of QuickBasic, the program will then display graphics correctly, including negative x and y components.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic version 1.0 for Macintosh systems. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

More information

The following program demonstrates the problem:
WHILE a$<>"q"
  INPUT "Enter x coordinate: ",a%
  INPUT "Enter y coordinate: ",b%
  CLS
  setorigin (-a%),(-b%)
  circle (0,0),20  ' A full circle should be drawn.
  call lineto(-a%,-b%)  ' A long diagonal line should be drawn.
  a$=""
  WHILE a$="":a$=INKEY$:WEND
WEND
In the compiled version, only the circle's lower right-hand quadrant (where both x and y coordinates are positive) is drawn. In the interpreted version, the full circle is correctly drawn on the second loop iteration or second program run during that session of QuickBasic.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB40712


Macintosh Basic Example to TAB between Multiple Edit FIELDs (40713)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article gives an example of how to design a program to use multiple Edit FIELDs and a Button. Programs that use Edit FIELDs or Buttons must use special event-handling techniques described below.

    The sample program below is designed to detect the TAB key or a click of the mouse in order to move between the multiple Edit FIELDs. You can type and edit text in any activated Edit FIELD. When a Button is clicked or you press Enter or RETURN, the program prints the contents of each Edit FIELD and stops.

    More information

    To make a program that uses Edit FIELD statements, you must use one of the following two techniques:

    1. Event trapping, using the ON DialoG GOSUB label and DialoG ON statements and a separate idle loop, which is interrupted by event GOSUBs
    2. Event polling, involving polling the value of x in a loop, where you invoke x=DialoG(0) once per loop cycle and test x for various conditions (events)
    The code example below uses the second technique, event polling, to handle TAB, RETURN, and mouse-clicking events that occur when using Edit FIELDs.

    The DialoG(0) function returns a 7 if a TAB key was pressed in an Edit FIELD. Once you know the TAB key was pressed in an Edit FIELD, you can activate the next desired Edit FIELD by executing the Edit FIELD n statement. The DialoG(2) function is useful to keep track of the most recently selected Edit FIELD, so you can decide which Edit FIELD to activate next with the Edit FIELD n statement.

    For more information about event trapping and polling, please refer to the following:

    1. Pages 115-119 of "QuickBasic for Macintosh: Language Reference."
    2. A simple example of using one Edit FIELD is shown on Page 113 of "QuickBasic for Macintosh: Language Reference."
    3. "Microsoft Macinations: An Introduction to Microsoft Basic for the Apple Macintosh" by Mitchell Waite (published by Microsoft Press 1985). Chapters 11 through 14 give the best tutorial available for using Edit FIELDs and event handling. Every owner of Basic or QuickBasic for the Macintosh should have this book.
    The example shown below expands upon the similar example on Page 132 of the "Microsoft Basic Interpreter for Apple Macintosh" manual for Versions 2.00, 2.10, and 3.00.

    Code Example
    NumFields = 3  ' NumFields = Number of Edit FIELDs defined below.
WindOW 2, "HIT TAB", (50, 110) -(430, 240)
Edit FIELD 3, "FIELD 3", (5, 82) - (250, 115)
Edit FIELD 2, "FIELD 2", (5, 47) - (250, 80)
Edit FIELD 1, "FIELD 1", (5, 10) - (250, 45)
Button 1, 1, "Done", (290, 49) - (340, 67)
CurrentField = 1
Edit FIELD CurrentField  ' Puts cursor at first Edit FIELD.
WHILE 1
     dial = DialoG(0)  ' Invoke DialoG(0) just once per loop cycle.
     IF dial = 1 THEN done  ' If button clicked, go to done.
     IF dial = 2 THEN
          CurrentField = DialoG(2) ' Returns # of clicked Edit FIELD.
          Edit FIELD CurrentField  ' Activate clicked Edit FIELD.
     END IF
     IF dial = 6 THEN done  ' If RETURN key pressed, go to done.
     IF dial = 7 THEN   ' If TAB pressed, activate next Edit FIELD:
          CurrentField = (CurrentField MOD NumFields) + 1
          Edit FIELD CurrentField
     END IF
WEND
done:   ' Use Edit$(n) function to return contents of Edit FIELD n:
     e1$ = Edit$(1)
     e2$ = Edit$(2)
     e3$ = Edit$(3)
     Edit FIELD CLOSE 0   ' Closes all edit fields.
     PRINT "Edit FIELD 1 contents:" : PRINT e1$
     PRINT "Edit FIELD 2 contents:" : PRINT e2$
     PRINT "Edit FIELD 3 contents:" : PRINT e3$
END
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB40713


In Macintosh Basic, FILES$(0) Doesn't Create File; OPEN Does (40714)

Summary

The purpose of the FILES$(0) function is to prompt you for the name of a file that will be created or accessed later in the program.

FILES$(0) does NOT actually create a file. You must execute an OPEN statement on the filename string returned by FILES$(0) to actually create the file.

More information

Note: In QuickBasic, OPENing a new file for Random or APPEND access displays a "Can't Find: <file>" dialog box, unless you select the "Disable File Not Found Dialog" option, or first create the file with OPEN FOR OUTPUT. For more information about the "Can't Find: <file>" dialog box, please refer to a separate article in this database (query for Random AND DialoG AND Disable AND QuickBasic AND Macintosh).

The remainder of this article is a tutorial for the FILES$(0) function.

FILES$(0) prompts you with a standard Macintosh dialog box that allows you to type a filename and choose the folder or Drive (volume) for the new file to reside in. The Save button becomes enabled as soon as you type one or more characters. If you click the Save button (or press the RETURN or Enter key), FILES$(0) returns a string with a path-qualified filename of the form "disk:folder:filename". If you click the Cancel button, FILES$(0) returns a null string.

For a better understanding of FILES$(0), just run the following program:
   N$ = FILES$(0,"Name the file:")
   PRINT N$
If you type the name of an existing file in response to the FILES$(0) prompt, an alert box asks you whether or not to replace the existing file. If you select "No", you are allowed to change the name or Cancel. If you select "Yes", FILES$(0) returns a name of the form "disk:folder:filename". The existing file is NOT affected unless later in the program you execute an OPEN statement with that filename.

FILES$(1) is different than FILES$(0). The function FILES$(1) prompts you with a standard Macintosh dialog box of Existing files and returns the name of an existing file. You can then execute an OPEN statement on the returned filename string.

The FILES$(0) and FILES$(1) functions are documented on Pages 131 through 133 of the "QuickBasic For Apple Macintosh: Language Reference" manual.

Code Example 1

OPEN FOR OUTPUT never gives you a "Can't Find: <file>" dialog prompt (regardless of QuickBasic's "Disable File Not Found Dialog" option):
NewFile$ = FILES$(0, "Name the new file:")
OPEN NewFile$ FOR OUTPUT AS #1
' Write to the file here if you wish.
CLOSE
END
Code Example 2
' This random access works in QuickBasic as is, regardless of
' the "Disable File Not Found Dialog" option:
NewFile$ = FILES$(0, "Name the new file")
OPEN NewFile$ FOR OUTPUT AS #1
CLOSE #1   ' First create and close file before opening with random
OPEN NewFile$ AS #1    ' or APPEND access.
' Write to the file here if you wish.
CLOSE
END
Code Example 3
' You must select the "Disable File Not Found Dialog" option
' before running this program in QuickBasic (interpreter or
' compiler). Works as is in earlier Basics for Macintosh.
NewFile$ = FILES$(0, "Name the new file")
OPEN NewFile$ AS #1    ' Opens new file for random access.
' Write to the file here if you wish.
CLOSE
END
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB40714


Locked Printer Driver File Can Hang Macintosh QuickBasic (40715)

Summary

Locking a printer driver file that is in the Macintosh System Folder may cause Microsoft QuickBasic (b) or (d) to produce a system bomb or hang the system when it attempts to load a source file. The problem occurs even when you don't print to the printer.

The easy workaround is to unlock the printer driver file before loading any source files into the QuickBasic editor.

More information

The following steps are required to reproduce the problem:

  1. Select (single-click) a printer driver from the System Folder, such as the Laserwriter driver. From the desktop File menu, select Get Info, and click the box to LOCK the driver file. Close the Get Info window.
  2. Bring up the Chooser, select the Laserwriter, and click on the device that corresponds to the locked Laserwriter driver.
  3. Run QuickBasic (b) or (d), and Open a source file. You may just double-click on a source file that runs QuickBasic and loads and runs the program file.
At this point, the system bombs or hangs.

Microsoft is researching this problem and will post more information as it becomes available.

The printer driver may be unlocked by opening the System Folder and selecting the file that is locked (by single-clicking on the file). Then use Get Info from the File menu, which displays information about the printer driver, including a box that indicates the "Locking" status of the file. This box may be clicked on with the mouse to toggle the locking status on and off.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB40715


How to Change "About Application..." Using ResEdit (40720)

Summary

In all Macintosh applications that use the menu bar, the first item under the Apple menu is an "About Application..." item that brings up a dialog box giving you various information about the application.

In applications written and compiled with Microsoft QuickBasic, this item brings up a simple box which states "This application was created using Microsoft QuickBasic". This box and the text for the item under the Apple menu can be changed using ResEdit.

More information

The Apple menu is in the upper left-hand corner of the Macintosh screen.

Follow these steps to change the dialog box/menu item string for the "About Application..." item in the Apple menu:

  1. Launch ResEdit.
  2. Open your application.
  3. Open STR to change the menu item string.
  4. Open STR ID = 128.
  5. Edit the string and close the edit box.
  6. Close the STR window.
  7. Open Ditl (Dialog Item List) to change the items in the "About application..." dialog box.
  8. Open Ditl ID = 128.
  9. To change the text or edit any existing dialog item, double click on it to bring up the edit box.
  10. To add dialog items, select New from the file menu. Note: You can resize the dialog box, but the size will not take effect until you perform the Steps 11 through 15 that follow.
  11. When finished adding/editing dialog items, close the Ditl window.
  12. To resize the dialog and define its placement on the screen, open Dlog.
  13. Open Dlog ID = 128.
  14. Resize the dialog by doing one of the following:

    1. Click in the bottom right corner of the box and drag.
    2. Select "Display as text" under the Dlog menu item and change the coordinates.
  15. When finished, close all windows, click YES to save changes, and exit ResEdit.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB40720


BUG: Mac QuickBasic Compiled Decimal Math Div Error 1D+62 / x (40722)

Symptoms

The expression 1D+62 / x, where x is in the range of 0.1000001 to 0.99999999, incorrectly produces the result "0". This incorrect calculation result occurs only in an application compiled in Microsoft QuickBasic (d), the decimal math version of QuickBasic 1.00 for the Macintosh. The problem does not occur in the Microsoft QuickBasic (d) Interpreter, or in the interpreter or compiler of Microsoft QuickBasic (b), the binary math version.

Microsoft has confirmed this to be a bug in Version 1.00. We are researching this problem and will post new information as it becomes available.

To work around this problem, restate the expression in the following form:
   1D+62 * (1 / x)
This expression was computed correctly in the following earlier products: the Microsoft Basic Interpreter (Versions 2.00, 2.10, and 3.00) and Microsoft Basic Compiler 1.00.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB40722


Compiling Mac QuickBasic Program with !Vaccine C_DEV Installed (40724)

Summary

!Vaccine is a C_DEV that protects against the addition of resources (such as a potential computer virus) to the resource fork of all applications in the system. (A C_DEV is a device invoked as an icon in the Control Panel in the Macintosh Apple menu.)

When the compiler in Macintosh QuickBasic compiles a source file and creates an application (a file with the extension .APL), it must add resources to the resource fork of the generated application. !Vaccine traps this and alerts you.

!Vaccine gives you the option of granting or denying permission for a resource to be added to an application. To successfully create the application, answer "Yes" to !Vaccine's inquiries.

More information

!Vaccine Version 1.0.1 (dated December 1988) gives you the following two alert options:

  1. Non-expert, a big dialog box with Yes or No buttons
  2. Expert, a small Icon in the title bar with two buttons, Yes or No
The only time QuickBasic knows that !Vaccine is present is when you try to compile an application. For QuickBasic to go ahead and complete the compilation, access must be granted for every resource that will be added to an application. !Vaccine asks you for permission each time.

!Vaccine (TM) is a trademark of CE Software, Inc. (1988).
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB40724


Macintosh QuickBasic Program to Hide/Unhide File in Finder (40887)

Summary

Below is a Macintosh QuickBasic 1.00 program that makes a file invisible on the Macintosh desktop. Even though it is invisible, the file can still be accessed by an application and can be read and written to, e.g. QuickBasic can still open the file.

The program example uses the GetFileInfo and SetFileInfo routines (i.e., MBLC routines in QuickBasic), which are not provided in earlier releases of Basic interpreter or compiler for Macintosh.

More information

The following is a program example:
' Hides a visible file or unhides an invisible file
DEFINT A-Z
DIM FileInfo(40)
FILENAME$ = "myfile"
GetFileInfo FILENAME$,FileInfo(0)
FileInfo(20) = FileInfo(20) XOR 16384
SetFileInfo FILENAME$,FileInfo(0)
END
The contents of the FileInfo array can be found in "Inside Macintosh" Volume II on Page 116 (by Apple Inc., published by Addison-Wesley). In this array, the Finder information is stored in parameter block 32 (i.e., element 16 in the array). The Finder information block is 16 bytes long. These 16 bytes are described on Page 130. They are as follows:
   fdType      OStype {file type}
   fdCreator   OStype {file's creator}
   fdFlags     Integer {flags}
   fdLocation  Point {file's location}
   fdFldr      Integer {file's window}
The fdFlags are used to determine if the file is visible to the Finder. The constant 16384 is XORed to the flag's value to determine if the file should be visible or not.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB40887


How to PRINT Superscript/Subscript Letters in Mac QuickBasic (40889)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The sample program below shows how to subscript and superscript a character on the screen from a Macintosh QuickBasic program using the CALL Move and CALL TextSize routines. The CALL Move routine is used to change the relative vertical position of the text, and the CALL TextSize routine is to reduce the text size.

    More information

    The following is a code example:
    superscript% = 1
subscript% = 0
PRINT "hi"
PRINT "hi";
CALL ssscript(subscript%,"hh")
PRINT "hi"
END

SUB ssscript(script%,text$) STATIC
 default%=0
 SELECT CASE script%        'determine script type
  CASE 0                    'subscript
   y1delta%=+2
   y2delta%=-2
  CASE 1                    'superscript
   y1delta%=-2
   y2delta%=+2
  CASE ELSE
   PRINT "Invalid Argument"
   EXIT SUB
 END SELECT

 CALL Move (0,y1delta%)        'move either up or down 2
 CALL TextSize(8)              'reduce text size
 PRINT text$;                  'display text without return
 CALL Move (0,y2delta%)        'return to original position
 CALL TextSize(default%)       'return to default text size
ENDSUB
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB40889


If Communications Buffer Overflows During Output to "Com1: " (40897)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft Basic Compiler 1.00

    • Summary

    If the communications buffer overflows, overprints, or fails when outputting to the "Com1:" device, such as to a plotter, Apple ImageWriter printer, or other hardware, it is probably due to the fact that the Macintosh hardware handshaking has not been turned on.

    The machine language program below invokes the _ContROL ROM call to turn on the hardware handshaking for "Com1:". This program can be used with the following products:

    1. Microsoft QuickBasic 1.00 for the Apple Macintosh
    2. Microsoft Basic Compiler 1.00 for the Apple Macintosh
    3. Microsoft Basic Interpreter Version 3.00 for the Apple Macintosh
    This program is not necessary for earlier (1.x, 2.x) versions of the Microsoft Basic Interpreter for Macintosh, where hardware handshaking is ON by default.

    More information

    To support the Apple Personal Modem, QuickBasic 1.00 and the Basic interpreter Version 3.00 set "Com1:" hardware handshaking OFF. Unfortunately, this can cause buffer overrun problems to occur with devices that rely on hardware handshaking.

    Please note that Macintosh QuickBasic and earlier versions of Macintosh Basic support only one communications port, "Com1:", which is marked with a phone icon on the back of the Macintosh. QuickBasic does not offer a feature to change the communications parameters for the "LPT1:" printer port, which is marked with a printer icon on the back of the Macintosh.

    Code Example

    The following code example turns ON hardware handshaking to prevent buffer overflow problems on hardware that requires handshaking ON:
    OPEN "Com1:9600,n,8,1" AS #1  ' Substitute your OPEN "Com1:..." here.
DIM Code%(100)
n=0 : hdhs=0
FOR j=0 TO 15   ' This loop READs machine language code into an array.
 READ n
 Code%(j)=n
NEXT
hdhs=VARPTR(Code%(0))    ' Get address of array.
CALL hdhs  ' Call the machine language instructions (stored in array)
' It is now possible to output with PRINT#n to the "Com1:" device.
END
' Below are machine language instructions (represented as
' hexadecimal constants) that invoke the _ContROL ROM routine.
DATA &H41FA,&H001E
DATA &H317C,&HFFF9,&H18
DATA &H317C,&H000A,&H001A
DATA &H217C,&H001,&H1113,&H1C
DATA &H42A8,&H0020
DATA &HA004
DATA &H4E75
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB40897


How to Poll Mouse(0) to Detect Single, Double, Triple Click (40951)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Mouse programming is very dependent on timing between mouse clicks. The System Control Panel is used to set the current mouse click timing rate.

    This article contains a sample program that shows how to poll the Mouse(0) function in a loop. The program detects single, double, and triple clicks in Macintosh QuickBasic 1.00, Basic Compiler Version 1.00, and Basic Interpreter for the Macintosh Versions 2.00, 2.10, and 3.00.

    The following is a code example:
    PRINT "Click in right window border to quit"
WHILE x < 490   ' Quits if you click beyond 490 pixels to right.
   WHILE Mouse(0)=0 : WEND   ' Wait for mouse button to go down.
   GOSUB delay   ' Delay long enough for user to triple click.
   waitup:
      buttonstatus=Mouse(0)  ' Read current mouse status.
      x=Mouse(1)   ' Returns X coordinate of mouse.
      IF buttonstatus < 0 THEN GOTO waitup   ' Avoids down status.
   PRINT "buttonstatus=",buttonstatus
   IF buttonstatus=1 THEN PRINT "Single clicked"
   IF buttonstatus=2 THEN PRINT "Double clicked"
   IF buttonstatus=3 THEN PRINT "Triple clicked"
WEND
END

REM   Please note:   If the mouse is clicked three times at a rate that
REM                  nearly exceeds the system time period for a triple
REM                  click, the program may report a double and a
REM                  triple click.

delay:
   PRINT "Now waiting for clicking to finish . . ."
   ' If compiled, then use a longer loop:
   IF SYSTEM(4) THEN      ' SYSTEM(4) returns "true" if compiled.
     FOR I=1 TO 7000 : NEXT
   ELSE  ' Use shorter loop if run in interpreter:
     FOR I=1 TO 1100 : NEXT
   END IF

REM   The SYSTEM(4) command is not supported in the Macintosh Basic
REM   Interpreter or Compiler products.  When using either product,
REM   comment the IF...END IF loop and uncomment the loop that follows.

REM   FOR I=1 TO 7000 : NEXT 'Use a shorter loop if run in interpreter

   PRINT " . . . time is up."
   RETURN
    Program notes:

    The delay loop in this program has different timing on a Mac Plus than it does on a Macintosh II. To make the program behave the same on different Macintosh computers, replace the program's loop with another loop based on calling the ToolBox statement to invoke the TickCount ROM function. (Query on the word "tickcount" in this database for an example of a timer accurate to one-sixtieth of a second). Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB40951


AppleTalk Network Connects Apple Macintosh and Printers (41042)

Summary

AppleTalk Personal Network (from Apple Inc.) physically connects multiple Macintosh computers and Apple printers into a local area network (LAN).

The network is established by connecting cables through connector ports. Macintoshes and Apple printers come with built-in AppleTalk connector ports.

Printing is the only service that is built into the AppleTalk network.

Network services other than printing are provided by separate software packages. For example, AppleShare is a software server that runs on the AppleTalk network. A server such as AppleShare allows computers to run applications that reside on another machine, which is usually called the host. (QuickBasic 1.00 or programs compiled in QuickBasic are not designed for or tested for opening files or running remotely over the AppleShare server.)

Using the AppleTalk cable, you can link up to 32 devices with a maximum network length of 1000 feet. The bandwidth is narrow (230K per second). With Farallon's twisted-pair Phonenet, you can extend the network up to 1000 feet, and connect up to 100 nodes.

You can link PCs into the net by installing a network interface card (NIC) and running special network software on the PCs.

More information

AppleTalk's layered model is similar to the International Standards Organization's OSI Reference Model.

More information about Ethernet connections and LAN networking can be found in the article "Appletalk: Much More Than a Macintosh/ Laserwriter LAN" by David Buerger, in the January 23, 1989, issue of InfoWorld Magazine on Page 15.

Apple Computer, Inc. is the best source for more information about its AppleTalk network.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB41042


Macintosh QuickBasic "Packing List", Release Disk Contents (41392)

Summary

This article contains the complete Packing List file from the Examples disk from QuickBasic 1.00 for Apple Macintosh. This list describes all files shipped with the product.

More information

Packing LIST
              Contents of Disks for Microsoft QuickBasic for
                     Apple Macintosh Systems
                          Version 1.0

                Copyright Microsoft Corporation, 1988

This document contains information about Version 1.0 of
Microsoft QuickBasic.

============================< Packing List >======================

--------------------------- Program Disk--------------------------
      Contents                 Description
      --------                 -----------
File Browser                   Utility to read and print Text files
Microsoft QuickBasic (b)       Binary QuickBasic
Microsoft QuickBasic (d)       Decimal QuickBasic
ReadMe                         Miscellaneous notes and warnings
Packing List                   This file

Runtime Folder
--------------
    QB10.bl                   binary external runtime
    QB10.cl                   68881 coprocesser external runtime
    QB10.dl                   decimal external runtime

--------------------------- Examples Disk------------------------

      Contents                Description
      --------                -----------
MacBanker Folder
----------------
    MacBanker                 personal finance manager
    MacBanker Docs.MacWrite   MacBanker documentation

QB Demos Folder
---------------
Short demos
      AlertDemo               'Alrt' resources to get Mac Alerts
      Cones                   program from the User's Guide
      Crazy Color             fun graphics
      Demo Resources          Resources used by the demo programs
      Dialog Example          'Dlog' resources to get a Mac dialog
      Icon Example            icon resource example
      It's a Drag             shows how to drag a gray outline
      Music                   play Bach, and draw a musical picture
      Music Picture           Contains the picture for Music
      Lace                    graphics with GET,PUT, and XOR
      POS/CSRLIN Example      using different fonts on the screen
      Show MacPaint File      read a MacPaint file
      Show me                 MacPaint file to show
      String Resource Example Mac 'STR ' resources
      ToolBoxSampler          Sampler of Toolbox routines
      Using Textboxes         easily format text in your windows
      Waveform Sounds         defining waveforms for sound
      Window Chase            a toy and programming puzzle
Example application sources
      Animated Sort           sorting algorithms brought to life
      Calendar                create calendars
      Terminal                simple telecommunications program
Utility programs
      Program Skeleton        outline of Mac Basic application
      Utility Subprograms     a collection of useful subprograms
Advanced programming examples
      Clip Regions            fun demo of clipping regions and color
      FileInfo                get file types and modification dates
      File Browser.source     Source for the File Browser utility
      GetPathNames            get a file's full path name
      Text Edit Example       advanced text editing functions

Tools Folder
------------
      AlertMover
      Cursor Editor
      Edit                    Apple text editor
      extra MBLC remover      strips an application's unused MBLCs
      Pattern Editor
      Print Listing File      utility to print a paginated "lst" file
      Renumber Codes          old library fixer
      ResEdit                 resource editing and moving tool
      SortSub                 sort subprograms for the compiler
      Statement Mover         library statement and resource mover

User Libraries Folder
---------------------
For the advanced programmer.
Support and example files for building custom libraries with MPW
assembler, MPW C, MPW Pascal, or Lightspeed C.  See appendix E.9 for
more details.

========================< Subject To Change>======================

Information in this document is subject to change without notice and
does not represent a commitment on the part of Microsoft Corporation.
The software and/or databases described in this document are furnished
under a license agreement or nondisclosure agreement. The software
and/or databases may be used or copied only in accordance with the
terms of the agreement. The purchaser may make one copy of the
software for backup purposes. No part of this manual and/or database
may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or
information storage and retrieval systems, for any purposes other than
the purchaser's personal use, without the written permission of
Microsoft Corporation.

Copyright Microsoft Corporation, 1988. All rights reserved.
Simultaneously published in the U.S. and Canada.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB41392


Screen Width and Height for Macintosh Plus, SE, and II (42322)

Summary

The following is a summary of the screen widths and heights (measured in pixels) for Apple Macintosh screens:
   Computer                       Width           Height

   Macintosh Plus and SE          512             342
   Macintosh II                   640             480
In QuickBasic the SYSTEM(5) function returns the screen width, and SYSTEM(6) returns the screen height of the machine on which a program is running. These functions should be used to make applications portable, as opposed to hard-coding the above values into a program. This function is documented starting on Page 323 of "Microsoft QuickBasic for Apple Macintosh: Language Reference."

More information

The term "resolution" is not standard terminology for Macintosh literature. The terms "width" and "height" are more common. The Macintosh II screen has the same resolution as VGA Screen modes 11 and 12 in QuickBasic for Ms-Dos, which are the highest resolutions possible for QuickBasic for Ms-Dos.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB42322


"Bad File Name or Number" (Error 52) If Cancel "LPT1: Prompt" (42361)

Summary

OPENing the "Lpt1:Prompt" device name as #n in a program prompts you for various print options and printer paper sizes. If you click the Cancel option, you will correctly receive the following error on a subsequent PRINT#n or WRITE#n statement:
"Bad File Name or Number" (Error 52)
This error occurs because you canceled opening the printer file. You can trap the error with an ON ERROR GOTO statement and then resume execution of the program.

This procedure applies to QuickBasic Compiler 1.00, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for Apple Macintosh.

More information

The following is a code example:
ON ERROR GOTO Erhandle
OPEN "Lpt1:Prompt" FOR OUTPUT AS #1
' An error occurs on the following statement if you clicked Cancel
' in the "Lpt1:Prompt" dialog box:
PRINT #1,"This IS Meant TO GO TO Printer"
CLOSE
label1:
   PRINT "This is the end."
END
Erhandle:
   E = ERR  ' assign error number to variable E
   PRINT "ERROR Number = "; E
   IF E = 52 THEN
     PRINT "YOU Clicked THE Cancel Button. Printing IS Canceled."
   END IF
   RESUME label1     ' Resumes execution at label1. File not opened.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB42361


Debugging System Errors in Compiled Programs with Mac Debugger (42364)

Summary

When debugging memory problems (with heap or data) or system errors that may occur in QuickBasic compiled programs, you can get a lot of information by surrounding the questionable statement with dead loops so you can drop into your favorite Macintosh debugger and dump the heap before and after. An illustration of this is shown below. This information is only appropriate for advanced Macintosh users who are already familiar with a Macintosh debugger.

More information

Suppose you have a Basic statement in a compiled program that you suspect is giving you memory problems. You can surround it with loops as follows:
   zippy: goto zippy
   aBasicStatement
   zip2: goto zip2
Wait until the program hangs at the loop, then press the Macintosh Programmer's Switch on the outside of the Macintosh. At this point, you can dump the heap, etc. To proceed past the loop, leave the "Process Runtime Events" option off in the compiler. If you do so, these loops compile to the following:

L1: bra.s L1

Change this to NOP ($4e71) and continue executing. If the "Process Runtime Events" option is on, do the following:

  1. Dump the heap, while gathering the statistics you want, and locate the handle that is equal to the size of the MBRL resource (it is detached, so it will not show up as a resource).
  2. Disassemble at the first data in the handle; you should see the following:
       bra.l   xxxx        'bra.l  InterstatmentEventProcessor
   bra.l   xxxx
   bra.l   xxxx
   ...
  3. Set a breakpoint at the first "bra.l" and GO.
  4. STEP once; you will see the following:
       MoveA.L (A7)+,A1                  * Get return address.
   Movem.L A1/A3/A5/A6/A7,INTRLN(A0) * Save user state for RESUME.
   Addq.L  #6,A1                     * Bypass interline information.
  5. If you step Past the Addq.L #6,A1, A1 contains the address of the code for the current statement.
  6. Disassemble at A1. You will see "bra.s xxxx". Change it to a NOP and continue executing.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB42364


"Invalid Function Call"; OpenResFile Makes Empty File; Path (42462)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    When using the OpenResFile statement, you must specify the complete path to the resource file being opened, such as in the following example:
       ref%=0
   OpenResFile "Examples:QB Demos:Demo Resources",ref%
    Otherwise, you must put the resource file in the current folder (the folder where QuickBasic itself or the compiled application is located) and specify no path, as follows:
       ref%=0
   OpenResFile "Demo Resources",ref%
    If the file does not exist in the specified location, then OpenResFile will create an empty file with the specified name. If the file is created empty, it will have no resources, and calling a subsequent library routine that tries to pull a resource out of it may produce a run-time error, such as the following:
    "Invalid Function Call"
    Note: You can use CHDIR to change the current default folder where OpenResFile searches for unqualified filenames, as follows:
       CHDIR "Examples:QB Demos:"
   OpenResFile "Demo Resources"

    More information

    This subject can be demonstrated by compiling the demonstration program DialoG Example, included with QuickBasic 1.00 in the QB Demos folder. If the file is compiled into an application and put in a different folder, the program will not find the needed resources as it does inside the interpreter. (The interpreted version always finds the resources, which Microsoft stored in the resource fork of the source file itself.)

    Here are three methods to make the compiled version of DialoG Example find the Demo Resources file:
    1. Copy the Demo Resources file into the same folder as the DialoG Example APL compiled application.
    2. Modify the source code of DialoG Example, changing the following line
            IF SYSTEM(4) THEN   'If compiled...
         OpenResFile "Demo Resources",ref%
      to include the drive and path of the Demo Resources file, for example:
            IF SYSTEM(4) THEN   'If compiled...
         OpenResFile "HD 20:Folder 1:Demo Resources",ref%
      Note that the SYSTEM(4) function returns a value of "true" (non-zero) when the program is compiled, and "false" (zero) when interpreted.
    3. Modify the source code of DialoG Example and add a CHDIR statement to change the default directory. In the following example, CHDIR changes the default folder to "Folder 1" on the disk named "HD 20":
            IF SYSTEM(4) THEN   'If compiled...
         CHDIR "HD 20:Folder 1:"
         OpenResFile "Demo Resources",ref%
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB42462 kbAudDeveloper


How Macintosh QuickBasic Uses Resource and Data Forks of Files (42463)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh

    • Summary

    Any file stored on a Macintosh disk has two parts or forks: a resource fork and a data fork.

    The resource fork is also known as a "resource file."

    Resources are specially formatted pieces of data stored in the resource fork. An application file, for example, may keep resources such as fonts, icons, menus, and application code in its resource fork.

    The application can keep anything it wishes in the data fork (often nothing). The data fork is often used for the contents of data files.

    Chapters 4 and 8 of the following book give more technical details about Macintosh files:

    "Technical Introduction to the Macintosh Family," by Apple Computer (published by Addison-Wesley, 1987)

    More information

    The QuickBasic (b) or (d) application itself has an empty data fork, and just uses its resource fork.

    The code for your program is located in the data fork in the disk files for compiled and interpreted programs.

    Files created with the OPEN statement in a QuickBasic program store data in the data fork. They have an empty resource fork, unless you perform OpenResFile on that file and write some resources.

    You can place resources into the resource fork of any file by using ResEdit, the "Statement Mover" program, or your own program that invokes Toolbox routines (such as OpenResFile, AddRes, SaveArray, SaveCursor, SaveIcon, SavePicture, and SaveString).

    Use SYSTEM(7) (instead of OpenResFile) to get the file reference number of resources stored in a running source file or compiled application. OpenResFile should only be used for accessing resource files that are external to the program.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB42463


OpenResFile; Resources May Save Incorrectly in Interpreter (42464)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    If you are using the OpenResFile statement (to open external resource files) when developing a program in the interpreter in Macintosh QuickBasic, you must invoke CloseResFile whenever the program ends. This includes when Stop is selected from the File menu or Command+PERIOD is pressed. (Using CloseResFile like this is not required in compiled programs.)

    If external resource files are left open in an interpreted program, the QuickBasic environment may place resources in the wrong files when you Compile or Save. For example, the MBCO resource, the compiler options specific to a source file, may be attached to the wrong file (as discussed in a separate article in this KnowledgeBase; query for MBCO).

    This behavior is a negative side effect of the designed feature to leave the resource file open during single-stepping (debugging) in the interpreter.

    You should invoke an ON Break GOSUB handler to make sure CloseResFile is performed when the program breaks, as shown at the bottom of this article. (An alternative is to always manually execute CloseResFile in the Command window before doing a Save or Compile in the QuickBasic environment.)

    More information

    Before a program does an END, STOP, RUN, CHAIN, or SubLaunch in the interpreter, you should always close external resource files that you have explicitly opened with OpenResFile.

    You should include an ON Break handler to automatically close externally opened resource files when you press Command+PERIOD (or select Stop from the File menu). Below is an outline to follow:
    ON Break GOSUB breakTrap
Break ON
' Program code goes here ...
' ... OpenResFile, et cetera ... end of code.
GOTO breakTrap  ' At the end of the program, close resource files.
END
breakTrap:
   ' Close all open libraries (if any) opened with Library statement:
   Library CLOSE
   ' Do the following for every resource file you have opened. This
   ' code checks to make sure the given resource file is NOT the
   ' program source or the currently running file then closes the
   ' resource file. ref% is the number returned by OpenResFile.
   ' PEEKW(&H900) gets the value in Macintosh global CurApRefNum,
   ' which is the file reference number of the currently running
   ' application:
   IF ref% <> SYSTEM(7) AND ref% <> PEEKW(&H900) THEN
       CloseResFile ref%
   END IF
   STOP
    The following is a complete example of using OpenResFile to open an external resource located in the Demo Resources file (located in the QB Demos folder on the Examples disk):
       ON Break GOSUB breakTrap : Break ON
   DIM r%(3)
   ref% = 0
   SetRect r%(0),10,10,42,42  'Sets rectangle to draw icon in.
   h& = 0
   '   get the file reference number:
   OpenResFile "Examples:QB Demos:Demo Resources",ref%
   n% = 5
   GetIcon ref%, n%, h&
   DrawIcon r%(0), h&
   ReleaseRes h&
   CloseResFile ref%
   END
breakTrap:  ' Here is the safest way to do CloseResFile:
   IF ref% <> SYSTEM(7) AND ref% <> PEEKW(&H900) THEN
      CloseResFile ref%
   END IF
   STOP   ' Stops the program
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB42464


How to Print or View QuickBasic Compiler "lst" Listing File (42516)

Summary

The Macintosh QuickBasic editor (List window) is not very suitable for printing or examining compiler listing files. You may use the following programs to print or examine a program's listing file:

  1. The "Print Listing File" program provided with QuickBasic 1.00
  2. Edit (included on the compiler distribution disk)
  3. Microsoft Word for Apple Macintosh, or another text editor
The Print Listing File program is the most convenient because it automatically forces a new page at the beginning of a page header. If you are using Edit, Word, or another text editor, then you will have to insert page breaks yourself.

A compiled program's listing file is created by selecting "Create Program List File" from Options... in the Run menu before compiling. Compiler listing files are given the extension "lst" by the compiler. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB42516


Use Long Integer with PEEK, PEEKW, and PEEKL; Single Can Fail (42550)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh

    • Summary

    Microsoft QuickBasic for the Macintosh allows for the contents of memory locations to be assigned to variables with the PEEK, PEEKW, or PEEKL functions. PEEK returns one byte of information, PEEKW returns one word (two bytes) of information, and PEEKL returns a double word (four bytes).

    The variable used to store a memory address should be of type long integer.

    If memory addresses are stored in Single precision numbers, it is possible (if the address is large enough) to lose one or more digits. A Single precision number may not be able to store memory addresses that are sufficiently large (such as FFFFFF Hex). A Double precision number has the capacity to represent high memory addresses, but rounding or truncation may occur (as it also does in single precision) because of the IEEE internal representation of floating-point numbers. This will not be a problem with Long integers.

    More information

    There are two methods in Macintosh QuickBasic to make a variable with a type of long integer:

    1. DEFLNG J-M defines variables beginning with letters J through M as long integer. DEFLNG A-Z makes all variables default to long integer.
    2. Appending the "&" character to a variable makes it long integer. This explicit typing overrides DEFSNG, DEFDBL, and DEFINT.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB42550


LINE INPUT#n Drops Null Characters from File; Use INPUT$ (42669)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.01
  • Microsoft QuickBasic 1.02
  • Microsoft QuickBasic 2.0
  • Microsoft QuickBasic 2.01
  • Microsoft QuickBasic 3.00
  • Microsoft QuickBasic 4.00
  • Microsoft QuickBasic 4.0B
  • Microsoft QuickBasic 4.50
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft GW-Basic Interpreter 3.20
  • Microsoft GW-Basic Interpreter 3.22
  • Microsoft GW-Basic Interpreter 3.23
  • Microsoft Visual Basic Standard Edition for Windows 1.00

    • Summary

    The LINE INPUT #n statement strips null characters (CHR$(0)) from input files. If you want to input null bytes, you must use the INPUT$ function instead of the LINE INPUT #n statement.

    More information

    Code Sample

    The following code segment will print "helloworld" instead of "hello world":
    OPEN "test.dat" FOR INPUT AS #1
LINE INPUT #1, a$
PRINT a$
CLOSE #1
    where the TEST.DAT data file was created as follows:
    OPEN "test.dat" FOR OUTPUT AS #1
PRINT #1, "hello" + CHR$(0) + "world"
CLOSE #1
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB42669


INPUT and LINE INPUT Make Macintosh Mouse Pointer Disappear (42702)

Summary

In Macintosh QuickBasic 1.00, the mouse pointer will disappear after the execution of an INPUT or LINE INPUT statement. As soon as the mouse is moved, the mouse cursor will reappear on the screen.

This behavior also occurs in the Macintosh Basic Interpreter Versions 2.00, 2.10, and 3.00, and the Macintosh Basic Compiler 1.00.

Microsoft is researching this behavior and will post new information as it becomes available.

The following is a sample program that demonstrates this behavior:
INPUT; "Enter a character"; var$   'Mouse will disappear
LOCATE 2,1
PRINT "The character you entered was a: ";var$
WHILE Mouse(0) = 0:WEND            'Click mouse to end
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB42702


CINT and Integer Assignments Round x.5 to Nearest Even Integer (42732)

Summary

When a numeric expression ending in .5 is assigned to an integer variable, the binary (b) math version of Macintosh QuickBasic will round the expression to the nearest even integer. For example, .5 converts to 0, 1.5 converts to 2, 2.5 converts to 2, and 3.5 converts to 4 [in both compiled and interpreted binary (b) math programs].

This rounding to the nearest even integer occurs for the CINT function and for an integer division assigned to an integer variable. This behavior is a feature of the IEEE Floating Point Standard.

In contrast, the Decimal Math version [Microsoft QuickBasic (d) or Microsoft Basic (d)] always rounds numbers ending in .5 upward when assigned to integer variables. You can choose the math package that best suits your needs.

More information

The even rounding of numbers ending in .5 during integer conversion occurs in the following products:
  1. Microsoft QuickBasic (b) (binary math) Version 1.00 for the Apple Macintosh
  2. Microsoft Basic Compiler 1.00 for the Apple Macintosh (compiled without the "Compile for Decimal Math" option)
  3. Microsoft Basic (b) (binary math) Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh
This type of integer rounding complies with the following IEEE standard:

"If the difference between the unrounded operand and the rounded result is exactly one half, the rounded result is even" (Section 5.4 of the "Proposed Standard for Binary Floating-Point Arithmetic")

The purpose of this behavior is to prevent an average upward (or downward) bias as various calculations are rounded. If the number was always rounded up, there would be an upward bias in calculations. Rounding to the nearest even number averages out; therefore, no rounding bias occurs.

The following are two examples of the above rounding behavior:
  1. The following is an example of always rounding expressions ending in .5 to an even number by integer assignment:
       DEFINT A-Z
   INPUT "Type a whole number (1,2,3,4,5,6,...)",INUM
   Iresult=INUM/2
   PRINT "If INUM/2 ends in .5, it rounds/truncates to even number:"
   PRINT Iresult
  2. The following is an example of rounding of the CINT() function:
          a=.5
      b=1.0
      c=1.5
      d=2.0
      e=2.5
      cls
      print "CINT (0.5) = "; CINT(A)
      PRINT "CINT (1.0) = "; CINT(B)
      PRINT "CINT (1.5) = "; CINT(C)
      PRINT "CINT (2.0) = "; CINT(D)
      PRINT "CINT (2.5) = "; CINT(E)

OUTPUT From:      QuickBasic (b)  |  QuickBasic (d)

CINT (0.5) =           0          |         1
CINT (1.0) =           1          |         1
CINT (1.5) =           2          |         2
CINT (2.0) =           2          |         2
CINT (2.5) =           2          |         3
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB42732


Triple Clicking Highlights Entire Line in QuickBasic Editor (42804)

Summary

Triple clicking selects (highlights) an entire program line in the editor in QuickBasic 1.00 for Macintosh.

Double clicking a word selects an entire word.

You can also highlight text by dragging the mouse over the text or by single clicking while holding down the Shift key.

Once you have selected text, you can Cut or Copy it into the editor clipboard for subsequent Pasting. Pressing the BackSPACE key (or DELETE key on newer keyboards) deletes the text without saving it.

More information

Triple clicking to select a line is a feature in QuickBasic not found in the Basic interpreter Versions 3.00 and earlier.

The various methods to select text are described on Page 50 (Chapter 2, "Writing Your Program") of "Microsoft QuickBasic for Apple Macintosh: User's Guide."
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB42804


OPENing "Com1: " for a Printer May Print Random Characters (42854)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    OPENing Com1: to output to a printer may cause random characters to be printed or overprinted. This is related to the amount of time required for communications port handshaking. To correct the problem, you must turn on hardware handshaking as shown in a separate article in this KnowledgeBase -- query for ImageWriter AND Com1 AND _ContROL.

    This information relates to Macintosh QuickBasic 1.00 and Macintosh Basic Interpreter Version 3.00. Earlier versions have hardware handshaking on by default, and the buffer overflow does not occur.

    More information

    The following program causes an ImageWriter II printer to print out random characters at the end of the output.
    OPEN "Com1:9600" FOR OUTPUT AS #1
FOR i = 1 TO 100
  PRINT #1, "Now its time for all good men..."
NEXT i
CLOSE #1
    Aside from turning on hardware handshaking with machine language, you may also work around the problem by inserting a delay loop in between each PRINT #n statement to provide enough time for the handshaking process between QuickBasic and the printing device to occur. For example, you could modify the previous example to look like the following:
    OPEN "Com1:9600" FOR OUTPUT AS #1
FOR i = 1 TO 100
  PRINT #1, "Now its time for all good men..."
  FOR j = 1 TO 500:NEXT j             'Delay loop
NEXT i
CLOSE #1
    Note: The timing of a FOR NEXT loop is machine dependent; therefore, the number of iterations in the delay may have to be increased or decreased from one machine to the next.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB42854


BUG: Window Sizing Affects Picture Scaling in Macintosh Basic (42930)

Symptoms

When a picture is recorded, the framing rectangle for the picture depends on the size of the current output window. This means that if the same set of drawing commands is recorded in windows of different sizes, then played back scaled to the same rectangle, they will look different.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic Version 1.00, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh (buglist2.00, buglist2.10, buglist3.00). We are researching this problem and will post new information as it becomes available.

More information

If the output window is resized before a program uses the following statement
   "Picture (X1,Y1)-(X2,Y2),Image$"
then the picture will be larger than if the window had not been sized.

A Picture statement that does not specify coordinates does not distort, as in the following:
   Picture ,Image$
The following code example demonstrates this:
   WindOW 1,"BIG WindOW",(1,21)-(510,338),1    ' Draws a big window.
   INPUT "Please Size THE WindOW Smaller THEN HIT RETURN.", B$
   Picture ON     'Draw uniform grid:
   FOR I=1 TO 20 : FOR J=1 TO 20
   LINE (0,10*J)-(200,10*J)  :  LINE (10*I,0)-(10*I,200)
   NEXT  J : NEXT  I
   Picture OFF : A$=Picture$
   X=510 : Y=317    ' X & Y  (Determine scaling of Picture below.)
   Picture (1,1)-(X,Y),A$    '(Distortion occurs for Picture of this form.
   '  Picture ,A$    (Distortion does not occur for Picture of this form.)
   INPUT B$   '  (Pause to see the drawn grid.)
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB42930


QuickBasic Example of Graphics Output to Disk and Printer (42979)

Summary

The program below gives an example of how to store a large graphics image permanently to a disk file and then read it back and print it to a full page on a printer. The purpose of this example is to combine various programming ideas into one practical illustration.

More information

The program below has been successfully tested in QuickBasic 1.00 for Macintosh on Finder Version 6.0 and System Version 4.2, with both normal and sideways (landscape) options on the following printers:

  1. Apple ImageWriter II, using ImageWriter driver Version 2.7
  2. Apple LaserWriter II NTX, using LaserWriter driver Version 5.2
Code Example
' The output window must be defined large enough for the image, or
' else printer output will truncate to the size of the window:
WindOW 1,,(1,1)-(510,750)
Picture ON  ' Turns on recording of a picture
  WIDTH 255
  ShowPen   ' Lets you see picture as you draw and record it.
  TextFont 5 : TextSize 12  ' Font 5 is Venice if installed.
  PRINT "This draws a big X on a full printer page"
  LINE (1,1)-(500,740)
  LINE (500,1)-(1,740)
Picture OFF
temp$=Picture$   ' 32K is largest allowed image string.

REM  This section writes the image string to a sequential file.
OPEN "imagefile" FOR OUTPUT AS #1
PRINT #1,temp$;
CLOSE
Temp$=""   ' Clears the string which stores the image in memory.

REM  This section retrieves the image from the disk file "imagefile"
OPEN "imagefile" FOR INPUT AS #2
b$=INPUT$(LOF(2),2)   ' Input all bytes into a string, b$
CLOSE
CLS          ' Clear the screen
Picture,b$   ' Redraw stored image

REM  This section writes the retrieved image to the printer:
OPEN "Lpt1:Prompt" FOR OUTPUT AS #3
  ' At the printer prompt, click normal or sideways printing, etc.
  WindOW OUTPUT #3  ' Redirects subsequent screen output to device #3
  Picture,B$        ' Draw the picture.
CLOSE               ' Picture is sent to printer after you CLOSE #3.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB42979


Backpat Sets Pattern Used by Subsequent CLS, or ToolBox Erase (42983)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The CALL Backpat statement sets the background pattern that will be used by a subsequent CLS statement, or a subsequent Macintosh Quickdraw ROM routine that performs an erase operation (such as ScrollRect, a Toolbox ROM routine that is documented in the book "Inside Macintosh, Volume I" described below).

    This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

    More information

    There are two equivalent ways to invoke Backpat; we recommend the first method for better program readability:

    Method 1

       CALL Backpat (VARPTR(pattern%(0)))
    The Backpat routine that is built into QuickBasic is explained in "Microsoft QuickBasic for Apple Macintosh: Language Reference" on Page 393. The CALL Backpat statement actually invokes the Backpat ROM toolbox trap described below in Method 2.

    Method 2

       ToolBox "I"
   TrapNo% = &HA87C
   ToolBox "P", TrapNo%, VARPTR(pattern%(0))
    Page 505 describes how to directly invoke the Backpat ROM toolbox trap with the ToolBox statement in QuickBasic (however, this page fails to mention that VARPTR must operate on the passed pattern array or else you receive a "Type Mismatch" error).

    Programming Notes

    The pattern% array must be initialized with a pattern before you can use either method. For articles about using the Pattern Editor program or predefined System patterns, please query in this Knowledge Base on the following keywords:

    Pattern and Macintosh and QuickBasic

    More information about Backpat can be found in "Inside Macintosh, Volume 1" by Apple Computer (published by Addison-Wesley).
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB42983


(Complete) Compile-Time Error Chart for Macintosh QuickBasic (43020)

Summary

The "Compile-Time Error Messages" chart was left out of the "Microsoft QuickBasic For Apple Macintosh: Language Reference" manual for versions 1, 1.00A, and 1.00B. To supplement the manual, you may use the error message chart included below, which is taken from the earlier compiler (pages 437-448 of the "Microsoft Basic Compiler for Apple Macintosh" manual for Microsoft Basic Compiler 1.00 for Apple Macintosh).

More information

The following compile-time error messages are described in greater detail further below:
   Error #     Compile-Time Error Message
   -------     --------------------------

    1          SUB without END SUB
    2          Wrong Number of arguments
    3          Undefined DATA label
    4          Expecting a variable
    5          Expecting end of statement
    6          Illegal character
    7          END SUB/EXIT SUB in main program
    8          DEF statement syntax error
    9          Invalid statement label
   10          Duplicate statement label
   11          Duplicate subprogram name
   12          Duplicate variable name
   13          Missing main program
   14          Missing argument
   15          Numeric overflow
   16          Illegal statement ordering
   17          Syntax error
   18          Undefined statement label
   19          Undeclared array
   21          Expecting closing parenthesis
   23          I/O control list error
   24          Maximum of seven dimensions exceeded
   25          Array subscript error
   27          Spelling error?
   28          Unterminated FOR or WHILE loop
   29          IF without END IF
   30          ELSE/ELSEIF without IF
   31          Static array redimensioned
   32          $INCLUDE file not found
   33          Alpha character expected
   34          Illegal $INCLUDE statement in $INCLUDE file
   36          SELECT CASE without END SELECT
   37          CASE statement expected
   39          DATA statement in single-line IF statement
   40          I/O control argument is not Character
   41          Expecting a symbol
   42          Expecting an opening parenthesis
   43          Unexpected end of statement
   44          Invalid $OPTION specifier
   45          NEXT without FOR or WEND without WHILE
   46          END IF without IF
   47          Array boundary error
   48          Illegal FOR variable
   49          Case constant exceeds 126-character limit
   50          Semicolon was expected
   51          A comma was expected
   52          Argument type mismatch
   53          This feature requires the N option
   54          FOR/WHILE loops nested deeper than 64
   55          CASE without SELECT CASE
   56          Statement not in a subprogram block
   58          Attempt to redefine option base
   59          Illegal argument
   60          Address out of 16-bit-range - use A option
   61          An equals sign was expected
   62          Undeclared subprogram
   63          Static variables cannot be erased
   64          System startup code file not found
   65          Internal error
   99          Internal stack level error
               Undefined error code - internal error
Below is a description of each compile-time error message:
   Error #     Compile-Time Error Message
   -------     --------------------------

    1          SUB without END SUB

               This occurs when the compiler encounters two SUB state-
               ments without an intervening END SUB statement, or a
               SUB statement without a matching END SUB statement.

    2          Wrong number of arguments

               An intrinsic or user-defined function or subprogram was
               called with the wrong number of arguments. For
               example, the number of arguments in a subprogram CALL
               statement was not the same as the number of parameters
               in the corresponding SUB statement.

    3          Undefined DATA label

               A label referenced by a REStore statement does not
               exist in the program.

    4          Expecting a variable

               An intrinsic function expects a variable in this
               position, but was passed an expression instead. An
               example of this is VARPTR, which takes a single
               parameter that must be a variable.

    5          Expecting end of statement

               The statement has been completely processed by the
               compiler and there is text remaining on the line that
               is not a trailing comment or legal statement separator.
               This can be caused by characters unrecognizable to
               Basic on the line, an incorrect trailing comment
               format, or parameters beyond those defined for the
               statement.

    6          Illegal character

               The compiler did not find an expected character, as in
               the following examples:

               1. A parameter in a function definition statement
                  (DEF FN) is not followed by a comma or a right
                  parenthesis.

               2. The compiler expected an expression or subexpres-
                  sion, but the next character was not one of the
                  characters that can legally begin an expression,
                  namely, an alphanumeric character, left or right
                  parenthesis, +, or -.

    7          END SUB/EXIT SUB in main program

               This indicates an END SUB or EXIT SUB statement that
               has no matching SUB statement.

    8          DEF statement syntax error

               This error is caused by one of the following two
               conditions:

               1. The name following the DEF keyword in a user-
                  defined function does not start with the letters FN.

               2. The range of characters in a DEFINT, DEFSNG, DEFDBL,
                  or DEFSTR statement is out of alphabetical order.

    9          Invalid statement label

               A line number has a value greater the 65,529.

   10          Duplicate statement label

               The same line number or label exists in a previous line
               in the program or subprogram.

   11          Duplicate subprogram name

               A subprogram name appears in two SUB statements in the
               same program.

   12          Duplicate Variable name

               The same variable appears in more than one COMMON
               statement.

   13          Missing main program

               The program contains no executable statements outside
               of a subprogram definition.

   14          Missing argument

               An intrinsic function was called without enough
               arguments.

   15          Numeric overflow

               This occurs when an expression resolved at compile time
               exceeds the maximum number that can be represented.

   16          Illegal statement ordering

               This can be caused by several conditions, four of which
               are as follows:

               1. A ShareD statement either follows executable code in
                  a subprogram or appears outside a subprogram block.

               2. An ERASE statement for shared or passed arrays
                  occurs in a subprogram.

               3. A user-defined function is called before the function
                  definition is given in a DEF FN statement.

               4. A COMMON statement appears in a subprogram.

   17          Syntax error

               This can be caused by a number of different conditions,
               some of which are listed below:

               1. An expression contains an operator without a
                  following operand.

               2. An expression contains two operands without a
                  connecting operator.

               3. A THEN keyword is missing an IF...Then...ELSE
                  statement.

               4. A TO keyword is missing in a FOR...Next loop.

               5. SELECT appears without the CASE keyword.

               6. IF condition or ELSEIF condition is not followed by
                   the keyword THEN.

               7. An ON ERROR clause is not followed by GOTO, or an ON
                  event clause is not followed by GOSUB.

               8. The hyphen (-) is missing between coordinate pairs
                  in a statement such as Button or LINE.

   18          Undefined statement label

               A label referred to in an IF...Then [[...ELSE]], GOSUB,
               or GOTO statement does not exist in the program or
               subprogram.

   19          Undeclared array

               This error can result from one of the following
               conditions:

               1. A GET, PUT, or Wave statement contains a reference
                  to an array that has not been previously declared in
                  a DIM statement.

               2. An array referenced in a ShareD statement was not
                  found in the main program.

   21          Expecting closing parenthesis

               The end of an expression was reached without enough
               right parentheses to balance the left parentheses
               encountered.

   23          I/O control list error

               This error can be caused by one of the following
               conditions:

               1. No legal mode is specified after FOR in an OPEN
                  statement.

               2. The keyword AS is missing in an OPEN or NAME
                  statement.

               3. The LEN keyword was not used when an attempt was
                  made to specify a file buffer size in an OPEN
                  statement.

               4. A constant null string ("") is used for a filename
                  in an OPEN statement.

               5. There is an error in the format of a PRINT [#] USING
                  format string or an INPUT statement prompt string.

   24          Maximum of seven dimensions exceeded

               The Basic compiler limits arrays to a maximum of seven
               dimensions.

   25          Array subscript error

               A static array reference has the wrong number of
               indexes.

   27          Spelling error?

               A statement does not begin with a number, label,
               keyword, or comment character.

   28          Unterminated FOR or WHILE loop

               The compiler has reached the end of the program with an
               unbalanced FOR statement; that is, one without a
               corresponding NEXT. This error message also appears
               when the program has a WHILE statement without a
               matching WEND statement.

   29          IF without END IF

               The compiler has reached the end of the program with an
               unbalanced block IF statement; that is, one without a
               matching END IF statement.

   30          ELSE/ELSEIF without IF

               There was no block IF statement pending when this block
               ELSE statement was encountered.

   31          Static array redimensioned

               Limits for a static array were declared more than once.

   32          $INCLUDE file not found

               A file specified in a $INCLUDE statement does not exist
               or cannot be found by the compiler in the specified
               volume or folder.

   33          Alpha character expected

               An identifier that starts with a letter is expected at
               this point.

   34          Illegal $INCLUDE statement in $INCLUDE file

               The compiler has encountered an $INCLUDE statement
               while processing another $INCLUDE statement. $INCLUDE
               statements cannot be nested.

   36          SELECT CASE without END SELECT

               The compiler has reached the end of the program with an
               unbalanced CASE statement, that is, one without a
               corresponding END SELECT.

   37          CASE statement expected

               The statement immediately following a SELECT CASE
               statement is not a CASE statement. All statements
               between a SELECT CASE statement and the matching END
               SELECT statement must be introduced by a CASE
               statement.

   39          DATA statement in single-line IF statement

               A DATA statement cannot be part of a single-line
               IF...Then...ELSE statement. DATA statements can appear
               in block IF...Then...ELSE statements, but they are not
               conditional.

   40          I/O control argument is not Character

               This is caused by one of the following two conditions:

               1. AS in a FIELD statement is not defined by a string
                  variable.

               2. A non-string expression is used for the mode or the
                  filename in an OPEN statement.

   41          Expecting a symbol

               The compiler encountered something such as a constant,
               keyword, or operator, instead of an expected symbol.

   42          Expecting an opening parenthesis

               This can be caused by one of the following two
               conditions:

               1. The compiler did not find a required left
                  parenthesis before the argument list in a call to a
                  subprogram, an intrinsic Basic function, or a
                  user-defined function.

               2. The compiler did not find a required left
                  parenthesis before a coordinate pair in a statement
                  such as Button, Edit FIELD, or WindOW.

   43          Unexpected end of statement

               The compiler reached a statement separator without
               completely processing the statement; it expects more
               text.

   44          Invalid $OPTION specifier

               An attempt was made to change some option other than A
               (use long addressing mode) or C (check array
               boundaries) in an $OPTION metacommand.

   45          NEXT without FOR or WEND without WHILE

               A NEXT statement was encountered when no FOR was
               pending, or a WEND statement was encountered when no
               WHILE was pending.

   46          END IF without IF

               An END IF statement was encountered when no block IF
               statement was pending.

   47          Array boundary error

               This error can result from one of the following
               conditions:

               1. A static array reference is outside the limits of
                  the array. This is the only boundary checking that
                  can be done in the compiler; all other types are
                  done at run time.

               2. A static array is declared in such a way that it
                  cannot have any elements, as in the following
                  example:

                     OPTION BASE 1
                     DIM STATIC Array%(0)

   48          Illegal FOR variable

               An array reference is used as a FOR variable.

   49          Case constant exceeds 126 character limit

               The maximum length permissible for a string in a CASE
               selector statement is 126 characters.

   50          Semicolon was expected

               The compiler did not find a semicolon after
               string-expression in a PRINT USING string-expression or
               PRINT #filenumber USING string-expression statement.

   51          A comma was expected

               The compiler encountered a syntax error in any of
               several I/O statements, subprograms and function
               calls, or declarations.

   52          Argument type mismatch

               This error is encountered in a number of instances
               where types should match. For example, in subprogram
               calls, this message indicates that the actual argument
               types do not exactly match the declared parameter types
               in the SUB statement. In function calls, it indicates a
               character has been passed for a number of vice-versa.

               This error also occurs in the following situations:

               1. A LINE INPUT statement is followed by some-
                   thing other that a string variable.

               2. There is a string array in a graphics GET or
                   PUT statement.

               3. Something other that a string expression is
                   used in a Button, Edit FIELD, Picture, or
                   WindOW statement.

   53          This feature requires the N option

               This features requires some process to occur between
               each statement; this processing is enabled by the
               compiler N option. Note that this option significantly
               slows program execution.

   54          FOR/WHILE loops nested deeper than 64

               The combined number of FOR and WHILE statements
               without matching NEXT or WEND statements is greater
               that 64.

   55          CASE without SELECT CASE

               The compiler has encountered a CASE statement outside
               a SELECT Case...END SELECT block.

   56          Statement not in a subprogram block

               After the main program block, the compiler encountered
               statements following an END SUB statement that are not
               in a new SUB...END SUB subprogram block.

               Subprogram blocks cannot be interspersed with the main
               program; subprograms must appear either before or after
               the main program block.

   58          Attempt to redefine option base

               The option base is a global value in a compiled Basic
               program and can be defined only once. This value can
               be defined explicitly in an OPTION BASE statement or
               implicitly by simply declaring an array. In the latter
               case, the option base is 0, the default.

   59          Illegal argument

               An invalid argument was passed to an intrinsic Basic
               function, such as a static array as the argument to
               LBOUND or UBOUND.

   60          Address out of 16-bit-range - use A option

               Your program is too large for the default addressing
               mode. Recompile your program with the A option
               (long addressing mode). (See Section 4.3.1 for
               information about the A option.)

   61          An equals sign was expected

               The compiler did not encounter an expected equal (=)
               sign. This error can be caused by any situation where
               an equal sign should appear (such as after the LEN
               keyword in an OPEN statement), but does not.

   62          Undeclared subprogram

               A name does not refer to a legal subprogram. This error
               occurs when both of the following conditions are true:

               1.  A user-defined name in a CALL statement is
                   not defined in a SUB statement and is not
                   a defined variable.

               2.  There are no Library statements in the program.

   63          Static variables cannot be erased

               The argument in an ERASE statement is a static array.

   64          System startup code file not found

               The compiler was unable to find the basinit file
               (basinit contains the run-time start-up object code
               and other resources required by the compiler).

   65          Internal error

               The compiler has detected an unexpected error. This
               error report indicates a problem within the compiler
               rather than within the source code being compiled.
               Please report the conditions and the circumstances in
               which it occurred to Microsoft, using the Software
               Problem Report at the back of this manual.

   99          Internal stack level error

               This occurs when the compiler detects that the code
               it has generated would leave the run-time stack in
               an inconsistent state. As in error 65, this indicates
               a problem in the compiler that should be reported to
               Microsoft.

               Undefined error code - internal error

               This error occurs when the compiler error handler
               encounters an undefined error number. As in errors
               65 and 99, this indicates a problem in the compiler
               that should be reported to Microsoft.

Modification Type: Minor
Last Reviewed: 1/8/2003
Keywords: KB43020


Making Pict Resource with Picture$ Picture and SavePicture (43021)

Summary

There are two routines you can use to write a picture to the resource fork of a file: SavePicture and AddPicture.

This article describes how to use SavePicture to save an image as a Pict resource that was recorded in the QuickDraw string format using the Picture ON and Picture OFF statements.

An alternate method is to record the picture as a bitmap with OpenPicture and ClosePicture, and save it as a Pict resource with the AddPicture routine. For more information, query in this Knowledge Base on the following words:

OpenPicture AddPicture

More information

You can record a picture as a string of QuickDraw calls with the Picture ON and Picture OFF statements. This string can be translated to a picture with the Picture$ function and written to the resource fork of a file with SavePicture. SavePicture is an MBLC routine that is built into QuickBasic.

Once you save the picture in the resource fork of a file, you can use ResEdit or a Basic program to move it to the resource fork of another file or application. (However, this QuickDraw string format will not be viewable in ResEdit.) You can retrieve the picture into a string variable with the LoadPicture routine, and redraw it with QuickBasic's Picture statement.

Code Example

'  Example of how to save a picture saved as a string
'  to the resource fork of a file
'  Open a file to hold your resource:
ref% = 0
OpenResFile "circle",ref%

'  Draw your picture:
Picture ON    ' Turn on recording of picture
  CALL ShowPen   ' Turns on screen pen to see drawing while recording
  Circle (100,100),25  ' Any drawing statements go here
Picture OFF   ' Turn off recording of picture
image$ = picture$  'Retrieve picture string stored as QuickDraw calls

'  Place the finished picture in the resource fork of the file:
id% = 1
SavePicture ref%,id%,image$
CloseResFile ref%
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB43021


INPUT or LINE INPUT Erases Existing Line When Accepting Input (43025)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    When accepting input with the INPUT or LINE INPUT statement on top of existing text (or pixels) on the screen, the rest of the line will be blanked out when you enter the first character. This behavior is a consequence of the feature that lets you use standard mouse editing on the entire input line.

    To avoid the erasure, you can accept input using the INKEY$ function (see example below).

    This information applies to Microsoft QuickBasic 1.00, Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00, and Microsoft Basic Compiler 1.00 for the Apple Macintosh.

    Another alternative is to use the Edit FIELD statement for input that is delimited by a box. For more information, query on the following words:

    DialoG and Edit and FIELD and QuickBasic

    More information

    The following is a sample program that demonstrates the erasing behavior during INPUT:
       LOCATE 1,3 : PRINT "*************"
   LOCATE 1,1 : INPUT A$
    The following is what you see when this program starts:
      ?_*************
    The existing line is erased (by the line editor) when you type a character. For example, the following output results when you type the letter a:
      ?a
    To avoid the erasure, you can accept input using the INKEY$ function, as shown in the following example:
    CALL TextFont 4  'This font has equally-spaced (monospaced)
                 'characters that line up correctly on the "*".
TextSize 9
PRINT "*****************"
LOCATE 1,1
a$ = ""
i$ = INKEY$
WHILE i$ <> CHR$(13)   ' RETURN key terminates input.
  'checks for valid input from keyboard
  IF i$ <> "" AND i$ <> CHR$(8) THEN  ' Ignore null and BackSPACE.
    a$ = a$ + i$
    LOCATE 1,1 : PRINT a$
    i$ = INKEY$
  END IF
  i$ = INKEY$
WEND
PRINT
' Waits until you press a key for program to end
WHILE INKEY$ = "": WEND
END
    The following is what you see when this program starts:
    ************
    As you type characters, the asterisks stay on the screen, as in the following:
    John Doe****
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB43025


Decimal File Format to Binary File Format (43202)

Summary

Microsoft QuickBasic(b) Version 1.00 for the Apple Macintosh (binary version) does not recognize a program created in Microsoft QuickBasic(d) Version 1.00 (decimal version) saved in compressed mode.

To work around this situation, when working in the decimal version, save your file as text and not compressed. You can do this by pulling down the FILE menu and choosing the Save As... option. Change the file format from the default (Compressed) to Text. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB43202


FIX: TextFont Reset in Interpreter on 2nd Printed Page (43204)

Symptoms

When redirecting fonts to a printer with WindOW OUTPUT #n, the fonts are reset after the first page of output. This occurs only in the interpreter part of QuickBasic 1.00 for the Macintosh. This problem does not occur with applications compiled with QuickBasic, nor with the Basic Interpreter version 3.00.

Microsoft has confirmed this problem in Microsoft QuickBasic 1.00 for Macintosh Systems. This problem is corrected in QuickBasic 1.00b.

More information

The workaround for this problem is to set TextFont at the beginning of each printed page. As mentioned above, compiling the program also solves the problem.

Code Example

The following code produces one page of Monaco font and one page of the default font. The default font is determined by the Finder. The default application font was changed from New York to Geneva on the Finder released May 7, 1984.
REM *** TextFont example ***
OPEN "LPT1:" FOR OUTPUT AS #1
WindOW OUTPUT #1
TextFont 4              'Monaco
FOR i%=1 to 132
  PRINT "Hello"
NEXT i%
CLOSE #1
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB43204


Language Ref. Page 35 Has Incorrect Double-Precision Format (43205)

Summary

On Page 35 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" Version 1.00 manual, the representation for the Binary-Math Double-Precision values is incorrect. The bits for the mantissa should be 0 to 51, instead of 0 to 55. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB43205


How to Align Misaligned Columns in Macintosh Program Output (43206)

Summary

If columns of characters you want to line up in a program's output appear to be misaligned, you must change from a proportional font, such as the default Geneva (3), to a nonproportional (monospaced) font such as Monaco (4). You can do this by using the statement CALL TextFont (n), where n represents the family number for a particular font.

This information applies to Microsoft QuickBasic 1.00, Microsoft Basic Compiler 1.00, and Microsoft Basic Interpreter 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh.

More information on TextFont is on Pages 396-397 in the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual, on Page 290 in the "Microsoft Basic Interpreter for Apple Macintosh" manual for Versions 2.x and 3.00, or on Page 420 in the "Microsoft Basic Compiler for Apple Macintosh" manual for the Basic 1.00 compiler. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB43206


Example of Playing a Sound Resource in Macintosh QuickBasic (43253)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    The SOUND and Wave statements in QuickBasic for the Macintosh let you generate four-voice sound. In addition, using Macintosh Sound Manager routines, you can also play sounds that have been stored on disk as resources, as described below.

    The following is an explanation and example of playing a sound or "snd " resource using Macintosh QuickBasic. The routines for playing sounds are managed by the Sound Manager. The Sound Manager is documented in Volume V of "Inside Macintosh" by Apple Computer (published by Addison-Wesley).

    There are seven routines that call the Sound Manager. SndPlay is the one that plays "snd " resources. The seven Sound Manager routines are not available as QuickBasic Toolbox Library routines (MBLCs), and they must be called with a modified version of QuickBasic's ToolBox statement. The ToolBox statement itself is an MBLC.

    This information applies to Microsoft QuickBasic 1.0, 1.0a, and 1.0b for Apple Macintosh.

    More information

    The "snd " resource name must be lowercase and followed by a space as shown.

    To play large sounds (greater than 100K or so), you need to increase the memory available for QuickBasic for Macintosh so that it can load the resource (which is done when you call GetIndRes). Under Apple MultiFinder, you have to do this by changing the memory requirements from the 'Get Info' or with ResEdit so MultiFinder allocates enough memory when the program starts up. If you don't increase the memory limit, you will hang or get a system error when the program tries to invoke 'GetIndRes'.

    The steps for calling Sound Manager routines are as follows:

    1. Steps to take before writing QuickBasic code are as follows:

      1. You must have an application that can create "snd " resources or have obtained them from a third party. QuickBasic does not create "snd " resources. To play "snd " resources, you must use ResEdit to insert them into some file that you can open with OpenResFile. If you cannot obtain any "snd " resources, there should be at least one in the resource fork of the SYSTEM itself so that this program example can be executed. You should verify this with ResEdit.
      2. QuickBasic's ToolBox routine itself needs modification. You must create two new MBLCs with ResEdit: ToolBoxOS and ToolBoxNewTool. For instructions to create these routines, query on the words ToolBoxNewTool or ToolBoxNewOS in this knowledge base. The instructions are also found in an application note, which can be obtained by calling Microsoft Technical Support at (425) 454-2030.
    2. Steps inside of the QuickBasic source code are as follows:

      1. Use OpenResFile to open the resource fork of the file where the "snd " resources are stored.
      2. Get a handle to the first "snd " resource available using GetIndRes. This MBLC routine uses the index, which is passed to it, to get the nth resource of that type available. It searches all of the resource forks currently open, including the SYSTEM itself. That is why it's important that the SYSTEM include at least one "snd " resource for this program to work.
      3. Use ToolBoxNewTool to call SndPlay with trap number &HA805. You must consult "Inside Macintosh," Volume V, and "Microsoft QuickBasic for Apple Macintosh: Language Reference," pages 497 to 503, to determine what parameters to pass, their data types, and whether to pass them by reference or by value.

    Code Example

    The following should be compiled with the "Include MBPCs & MBLCs" option:
    ' parameters for SndPlay
DIM chan&, sndHdl&, OSErr%, async%, ref%
' Trap Numbers for SndPlay
SndPlay% = &HA805
' Initialize program variables
chan& = 0  : sndHdl&= 0 : OSErr% = 0
async% = 0 : ref% = 0   : Index% = 1

ON ERROR GOTO errtrap
ON DialoG GOSUB PlaySound
DialoG ON
Button 1, 1, "Sound", (100, 100)-(200, 200), 1

' Include the following line if you have an "snd " resource file.
'    OpenResFile "Your Resource File", ref%
     ToolBoxNewTool "I"

WHILE 1
' Loop waiting for the button to be pressed.
WEND
END
errtrap:
    Index% = 1
    RESUME retry

PlaySound:
    temp = DialoG(0)
retry:
    GetIndRes "snd ",Index%, sndHdl&
    Index% = Index% + 1
    ToolBoxNewTool "WQ",SndPlay%,(chan&),(sndHdl&),(async%),OSErr%
    RETURN
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB43253


How to Create ToolBoxNewOS, ToolBoxNewTool for New ROM Calls (43561)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    Listed below are the steps necessary to create two new Toolbox statements required to access the new ROM routines listed in Volumes IV and V of "Inside Macintosh" (by Apple Computer, published by Addison-Wesley), and revised ROM routines in Volumes I, II, and III.

    This information applies to Microsoft QuickBasic 1.0, 1.0a, and 1.0b for Apple Macintosh.

    More information

    The address of certain ROM routines in "Inside Macintosh," Volumes IV and V, and revised ROM routines listed in Volumes I, II, and III, are not accessible through the standard Toolbox statement (which is an MBLC routine) packaged with QuickBasic. To call these additional routines, you need to modify Macintosh QuickBasic with the ResEdit utility.

    This situation occurs because QuickBasic uses _GetTrapAddress to obtain the address of the "trap" specified in the ToolBox MBLC. This procedure doesn't work correctly with the new "traps" that are listed in "Inside Macintosh," Volumes IV and V, and for the revised ROM routines in Volumes I, II, and III. For a detailed explanation of how _GetTrapAddress is used, refer to Page 234 of "Inside Macintosh," Volume IV.

    To make all ROM routines accessible to QuickBasic, two new Toolbox library routines need to be created. The two new Toolbox routines are used for the following:

  • Old ROM routines that have not been revised
  • The new Operating System routines
  • The new Toolbox routines
    • On the second part of this document is an example showing how to use the revised ROM routine NewPtr. Pages 497-524 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual discuss how to call the existing Toolbox statement.

    Use the following steps to create the two new Toolbox statements ToolBoxNewOS and ToolBoxNewTool:

    1. Invoke ResEdit.
    2. Open QuickBasic (b) or (d).
    3. Double-click the MBLC resource in the Microsoft QuickBasic (b) or (d) window.
    4. Scroll down to MBLC "Toolbox" ID = 3550.
    5. Click the MBLC "ToolBox" ID = 3550.
    6. From the Edit menu, choose Duplicate.
    7. Choose Duplicate from the Edit menu a second time.
    8. Double-click the first MBLC "ToolBox" ID = nnnn to open the window that displays the code for that routine.
    9. From the File menu, choose Get Info.
    10. Change the "Name:" field from "ToolBox" to ToolBoxNewOS.
    11. Close the "Info for MBLC nnnn from QuickBasic" window.
    12. From the Search menu, choose Find Hex.
    13. Put a146 in the "Find Hex:" field.
    14. Put a346 in the "Change To:" field.
    15. Choose the Change All button.
    16. Choose the OK button in the Alert box.
    17. Close the Change Hex window.
    18. Close the MBLC "ToolboxNewOS" ID = nnnn window.
    19. Double-click the second MBLC "ToolBox" ID = nnnn to open the window that displays the code for that routine.
    20. From the File menu, choose Get Info.
    21. Change the "Name:" field from "ToolBox" to ToolBoxNewTOOL.
    22. Close the "Info for MBLC nnnn from QuickBasic" window.
    23. From the Search menu, choose Find Hex.
    24. Put a146 in the "Find Hex:" field.
    25. Put a746 in the "Change To:" field.
    26. Choose the Change All button.
    27. Choose the OK button in the Alert box.
    28. Close the Change Hex window.
    29. Close the MBLC "ToolboxNewTOOL" ID = nnnn window.
    The next step is to decide which Toolbox routine should be used. Page 13 of "Inside Macintosh," Vol. IV, states the following:

    Bit 11 of the trap word determines how the remainder of the word will be interpreted; usually it's "0" for Operating System calls and "1" for ToolBox calls, though there can be exceptions.

    As a general rule, try to use the "ToolBox" statement first. If that fails, examine bit 11 of the trap number and use "ToolBoxNewTool" or "ToolBoxNewOS" if it is a "0" or "1," respectively.

    For example, because bit 11 of NewPtr is 0, you know that NewPtr is an Operating System call. Listed in the back of Volumes III, IV, and V of "Inside Macintosh" are the SYSTEM Traps for each routine call. The number listed is in hexadecimal notation; therefore, the number must be converted into binary so that bit 11 can be checked. The following is an example showing how to allocate a block of memory using Newptr:
        DIM regsarray&(5)
    size& = 0
    Newptr& = &HA11E
    ToolboxNewOS "I"
    ToolboxNewOS "R",NewPtr&,regsarray&(0),,,(size&)
    PRINT HEX$(regsarray&(2))      'print out the pointer
    PRINT regsarray&(0)            'print out the error, 0 if none
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB43561


BUG: Double Precision to Power of Integer Var Fails Compiled (43566)

Symptoms

Raising a double-precision number to the power of an integer variable incorrectly returns zero in the program below when compiled in Microsoft QuickBasic 1.00 for Macintosh .

The problem occurs in either the Binary math [QuickBasic (b)] or the Decimal math [QuickBasic (d)] versions of the compiler. The problem does not occur in the interpreter in QuickBasic. Microsoft is researching this problem and will post new information as it becomes available.

To work around the problem, raise the double-precision number to the power of a non-integer variable, such as a double-precision variable or a constant of any precision.

More information

The program compiled in QuickBasic incorrectly returns "0" (zero) for the following expression:
   D# ^ i%
However, the following correct result is produced for the expression:
  D# ^ j#
The problem does not occur in Microsoft Basic Compiler 1.00 for the Macintosh (released earlier than QuickBasic), which correctly produces 12 digits of precision for both expressions.

The following code example produces two printouts of a number raised to the power of 2; the first one improperly returns "0" and the second correctly returns a value with 12 digits of precision.

Example Code:
D# = RND( 1)
J# = 2
i% = J#
print D# ^ i%,  D# ^ J#
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB43566


QuickBasic for Macintosh Is Not Multi-Launchable on Network (43689)

Summary

Microsoft QuickBasic 1.00 for the Apple Macintosh is not multi-launchable, i.e., no more than ONE person can invoke QuickBasic at one time in a networked system environment, such as (AppleTalk).

This information also applies to Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00, and Microsoft Basic Compiler Version 1.00. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB43689


Lower-Right Pixels of Rectangle Not Included in FrameRect (43697)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The video mapping of the Macintosh, as used by Toolbox calls such as FrameRect(), is based upon infinitely small points instead of finite pixels. Because of this mapping scheme, when a rectangle is defined for a Toolbox call, the lower-right pixel boundary is one less than the point boundary. These calls are described on Pages 401 to 404 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual.

    More information

    For further information on Macintosh video mapping, refer to the QuickDraw section of "Inside Macintosh Volume I."

    Code Example
    REM For example, the corners of the following rectangle are actually
REM   (100,100) and (199,199):

rect%(0)=100           ' Y1
rect%(1)=100           ' X1
rect%(2)=200           ' Y2
rect%(3)=200           ' X2
CALL FrameRect(VARPTR(rect%(0)))

This information applies to the following Toolbox routines:

   FrameRect, PaintRect, EraseRect, InvertRect, FillRect

   FrameRoundRect, PaintRoundRect, EraseRoundRect, InvertRoundRect,
   FillRoundRect

   FrameOval, PaintOval, EraseOval, InvertOval, FillOval

   FrameArc, PaintArc, EraseArc, InvertArc, FillArc
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB43697


Directly Connected ImageWriter LQ Problem with OPEN "LPT1: " (43744)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Output to an Apple ImageWriter LQ printer may give problems if it is directly connected and you output to it using the "LPT1:" or "Lpt1:Prompt" device name from your Microsoft QuickBasic program. The problems do not occur when sending output to the ImageWriter LQ printer over the AppleTalk Network.

    The LPT1: device is expecting to communicate with a device at 9600 baud. The ImageWriter LQ communicates at a rate of 19,200 baud. To communicate with a directly connected ImageWriter LQ printer from your QuickBasic program, you must connect the printer to the communications port and use the OPEN "Com1:" statement instead. Output can then be sent with the PRINT#n or WRITE#n statement.

    More information

    The major drawback with output to Com1: is that the WindOW OUTPUT #n statement (for redirecting graphics to the printer) is not supported to the Com1: device. Your program must send the proper Apple ImageWriter printer control codes to change the font and size of printed text. The ImageWriter's control characters invoke only certain character-mode fonts, such as Elite and Pica, which don't look like Macintosh graphics-mode fonts. Your program must also send a carriage return and linefeed character sequence at the end of each line.

    If the ImageWriter LQ still prints strange characters using the method described above, check the dip switch settings for the printer. Specifically, check the fourth dip switch on the second bank of switches. It should be in the UP position. Check your ImageWriter LQ user's manual for the location of these switches.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB43744


PtInRects Returns Incorrect Value with Multidimensional Arrays (43747)

Summary

The modified version of the PointinRec example below demonstrates that PtInRects does not work correctly if the coordinates of the boxes are stored in a multidimensional array. When you click the mouse within a particular box, the box number is returned.

More information

In the example below, the box number returned is off by (2 * N - 1), where N is the number of the box that the mouse was clicked in. If the first box is clicked, it returns a 1; if the second box is clicked, it returns a 3; the third box returns a 5; and the fourth box returns a 7.

Microsoft is researching this problem and will post more information as it becomes available.

The following code example demonstrates the problem:
'----------------------------------------------------------------'
' PointinRec example. Copyright 1988 Microsoft Corp. This
' program is for personal use only. It may not be redistributed in
' any form, electronic or mechanical, for any purpose, without the
' written permission of Microsoft Corporation.
'----------------------------------------------------------------'

' This program draws four rectangles on the screen and waits for
' the user to click the mouse inside of one of the rectangles. It
' will then print out the number of the rectangle that the mouse
' was clicked in.

DIM box1%(7,7),pt%(1)
num% = 8
first% = 0
box1%(0,0)=40
box1%(1,0 )=10
box1%(2,0)=100
box1%(3,0)=130
'--------------
box1%(0,1)=110
box1%(1,1)=10
box1%(2,1)=170
box1%(3,1)=130
'--------------
box1%(0,2)=40
box1%(1,2)=140
box1%(2,2)=100
box1%(3,2)=260
'--------------
box1%(0,3)=110
box1%(1,3)=140
box1%(2,3)=170
box1%(3,3)=260
FrameRect (VARPTR(box1%(0,0)))
CALL MoveTo (13,45)
PRINT "Box 1
FrameRect (VARPTR(box1%(0,1)))
CALL MoveTo (13,115)
PRINT "Box 2"
FrameRect (VARPTR(box1%(0,2)))
CALL MoveTo (143,45)
PRINT "Box 3"
FrameRect (VARPTR(box1%(0,3)))
CALL MoveTo (143,115)
PRINT "Box 4"
LOCATE 13,10
PRINT "Use File Menu to Quit"
WHILE 1
WHILE Mouse (0) = 0 :WEND
SetPt pt%(0),Mouse (3), Mouse(4)
    PtInRects pt%(0),box1%(0,0),num%,first%
    PRINT first%
    FrameRect (VARPTR(box1%(0,0)))
    LOCATE 1,1
    PRINT first%
WEND
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB43747


Error 35 "Subprogram Not Defined" Compiling Cones Program (43785)

Summary

Page 41 of the "Microsoft QuickBasic for Apple Macintosh: User's Guide" fails to state that the "Include MBPCs & MBLCs" option is also required for compiling the Cones program.

To compile the Cones sample program that comes with QuickBasic 1.00 for the Macintosh, you must select the following four Options... under the Run menu:

  1. "Include MBPCs & MBLCs"
  2. "Use Default Window"
  3. "Use Default Menu"
  4. "Include The Run Time Code"
The Cones program performs several calls to Toolbox Library routines. These Toolbox Library routines are MBLC (Macintosh Basic Library Code) routines. If the "Include MBLCs" option is not set, then the program gives the run-time error message "Error 35" in a dialog box and terminate the program.

More information

Error 35 means "Subprogram not defined." This is a correct and meaningful message, since it can't find the MBLC code for a called Toolbox Library routine.

When you choose the "Include The Run Time Code" option, the compiled application includes the QB10.bl, QB10.cl, or QB10.dl run-time module so that it will stand alone. The run-time module supports QuickBasic language functions and floating-point routines required by compiled programs.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB43785


nVIR Resources Result from Infection by nVIR Virus (43790)

Summary

The nVIR resource (viewable in ResEdit) is created by the nVIR virus. It is believed that this virus works by first attacking the System. Once the System is infected, it proceeds to attack applications. Every time an application [such as QuickBasic (b) or (d)] is launched, nVIR will insert a new resource of type nVIR with a new ID number into the application's resource fork. The symptoms are not apparent until the application has been launched many times and many nVIR resources have been added. As the virus multiplies, the application begins to run poorly and eventually produces system bombs.

Vaccine(TM) Version 1.01 does not detect or remove nVIR.

Interferon(TM) Version 3.1 does detect and remove nVIR. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB43790


Macintosh QuickBasic Compiled Program Can Give Error Line # (43792)

Summary

To enable a Macintosh QuickBasic compiled application to return the line number where a run-time error occurs, you must choose the compiler option "Process Runtime Events." This option is chosen from the Run menu under "Options...". With this compiler option, applications display error messages in the following form:
***** Error MM at NNNNN
This message is displayed in a dialog box with a STOP sign indicating that the application was terminated. An <OK> button prompts you to return to the application from which the program was launched.

MM refers to the error number. The errors are listed by number in the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual, Pages 557-559.

NNNNN in the message refers to the physical line number in the Basic source file where the error occurred. (This number is not a memory address.)

To see physical line numbers most easily, you must select the "Create Program List File" compiler option. This creates a "lst" listing file with physical line numbers. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB43792


How to Set and Restore a Clipping Region in QuickBasic (44134)

Summary

This article explains how to use the SetClip toolbox library (MBLC) routine to establish a clipping region in Microsoft QuickBasic 1.00 for the Apple Macintosh.

To use SetClip, you pass to it a handle of a region that already exists. SetClip copies the given region. It does not use the actual region you pass to it. The clipping region and the copied region are two different resources. This means that any changes you make to the copied region do not affect the clipping region.

Using the DisposeRgn library routine on the copied region does not reset the clipping region. Once the clip region is set, its definition remains constant until it is redefined with another CALL to SetClip. If you want to restore graphics output to the whole window, you must reset the clipping region to include the entire window region. An example of how to do this is shown below.

More information

Before you can create a clip region, you must create the region from which to copy. To create a region, do the following:

  1. Create a region with the NewRgn routine.
  2. Access the region with OpenRgn.
  3. After it has been opened, define the region with any graphics routine that creates a closed figure (circle, square, oval, etc.).
  4. Close the region.
It is at this point that you pass the handle of the new region to SetClip. After you are finished with the region, use DisposeRgn to discard it.

SetClip is discussed on Pages 166-167 of "Inside Macintosh" Volume I, (by Apple Computer, Inc., published by Addison-Wesley, 1985). Clipping regions are discussed in the "Microsoft QuickBasic For Apple Macintosh: Language Reference" on Pages 429-430.

Code Example

ScreenWidth% = SYSTEM(5)
ScreenHeight% = SYSTEM(6)
centerX% = ScreenWidth% / 2
centerY% = ScreenHeight% / 2
x1% = CenterX% - 40 : x2% = CenterX% + 40
y1% = CenterY% - 40 : y2% = CenterY% + 40

' Set a small, square clip region
CALL SetClipRegion(x1%, y1%, x2%, y2%)

'Draw lines to show the boundaries of the clip region
'Lines are drawn only within the clip region
FOR n = 1 TO 100
  LINE (1, n * 4)-(ScreenWidth%, n * 4)
NEXT n

' Restore the clip region to the entire window
CALL SetClipRegion(1, 1, ScreenWidth%, ScreenHeight%)

' Draw Circles to show the current clip region
FOR i = 1 TO 30
  Circle (50, 50), i * 5
NEXT i

LOCATE 10, 1
INPUT "HIT RETURN TO EXIT THE ProgRAM", A$
END

SUB SetClipRegion(x1%, y1%, x2%, y2%) STATIC
     R& = 0 : SetRect c%(0), x1%, y1%, x2%, y2%
     NewRgn R& : OpenRgn
     FrameRect VARPTR(c%(0))
     CloseRgn R&
     SetClip R&
     DisposeRgn R&
END SUB
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB44134


edhandle& Missing from Parameter List of TeSetSelect Routine (44136)

Summary

The TeSetSelect Toolbox routine is missing the edhandle& parameter in its description on Page 412 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual. The routine should read as follows:

TeSetSelect Start, End, Edhandle&

An edit record handle, Ehandle&, that points to an Edit FIELD is needed to set a selection range that begins at character-position Start and ends at character-position End. QuickBasic's WindOW(6) function can be used to return the handle for the edit record associated with the current output window's active Edit FIELD.

The first character in the Edit FIELD is at position 0. If Start and End are the same, the selection range is an insertion point, and an I-beam cursor is displayed. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB44136


FIX: Wrong Line Marked w/ Error Box in $INCLUDE File (44213)

Symptoms

When a compile-time error occurs in a compiled program's $INCLUDE file, the interpreter puts a box around the wrong line in the main program. The number of lines that this box lies below the REM $INCLUDE statement is the number of the line in error in the $INCLUDE file.

Microsoft has confirmed this to be a bug that occurs when compiling programs that use the $INCLUDE metacommand in QuickBasic version 1.00 for the Macintosh . This problem is corrected in QuickBasic 1.00b.

A more desirable behavior would be for QuickBasic to put a box around the REM $INCLUDE statement and say "Error in $INCLUDE file at line xxx."

More information

For a related article, query on the following:

$INCLUDE and Jump and Macintosh and QuickBasic

Below is an example where the interpreter draws a box around the wrong line (in the main source file) when a compile-time error occurs in an $INCLUDE file. When you compile the following, the interpreter improperly marks line 4 in the main program with a box and gives a "Syntax Error" message:
REM This is the Main program.
REM $INCLUDE "Junk"
PRINT "LINE 3"
PRINT "LINE 4"  'The interpreter flags this line with "Syntax Error"

REM This separate $INCLUDE file is called Junk.        [line 1]
REM This file is saved in Text format.                 [line 2]
INPUT PRINT  ' This line is a deliberate Syntax Error. [line 3]
Note: REM $INCLUDE statements are ignored when the program is run in the interpreter; they have meaning only to the compiler.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB44213


QuickBasic Program to Disable Apple Menu from Menu Bar (44232)

Summary

The program example shown below demonstrates how to disable the Apple menu on the menu bar from a QuickBasic program on the Apple Macintosh. The resulting Apple appears as dim gray, making its menu items nonselectable.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

Code Example

The following program is DimMenu, which demonstrates the toolbox CALL to disable (dim) the Apple Menu:
' Routine to disable Apple Menu
toolbox "i"
menuhandle& = 0

' Disable Apple Menu
toolbox "lq", &H949, 1, menuhandle&     ' GetMHandle
toolbox "pq", &H93A, (menuhandle&), 0   ' DisableItem
toolbox "pq", &H937                         ' DrawMenuBar

PRINT "Notice that the Apple menu is dimmed"
PRINT "Click the mouse button to continue..."
PRINT
WHILE Mouse(0) <> 1 : WEND

' Restore Apple Menu
toolbox "pq", &H939, (menuhandle&), 0   ' EnableItem
toolbox "pq", &H937                         ' DrawMenuBar

PRINT "Presto, its back!"
PRINT "Click the mouse to exit"
WHILE Mouse(0) <> 1 : WEND
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB44232


QuickBasic Program to Delete Apple Menu from Menu Bar (44233)

Summary

The program examples below demonstrate how to delete the Apple menu from the menu bar in a QuickBasic program on the Apple Macintosh.

Example 1 deletes only the Apple menu, leaving any other existing menus. Example 2 clears the Apple menu plus all existing menus.

This information applies to Microsoft QuickBasic 1.00 for Apple Macintosh.

More information

Example 1

The following program demonstrates a ToolBox call to delete, then restore the Apple Menu:
toolbox "i"
menuhandle& = 0
' Delete Apple Menu:
toolbox "lq", &H949, 1, menuhandle&   ' GetMHandle
toolbox "pq", &H936, 1                ' DeleteMenu
toolbox "pq", &H937                   ' DrawMenuBar
PRINT "Notice that the Apple menu is deleted"
PRINT "Click the mouse button to continue..."
PRINT
WHILE Mouse(0) <> 1 : WEND

' Restore Apple Menu
toolbox "pq", &H935, (menuhandle&), 2  ' InsertMenu
toolbox "pq", &H937                    ' DrawMenuBar
PRINT "Presto, its back!"
PRINT "Click the mouse to exit"
WHILE Mouse(0) <> 1 : WEND

Example 2

The following code example completely erases (clears) the Apple menu plus all the remaining top menu bar items:
ClearMenuBarTrap& = &HA934
DrawMenuBarTrap& = &HA937
ToolBox "I"
ToolBox "PQ",ClearMenuBarTrap&
ToolBox "PQ",DrawMenuBarTrap&
' Now, any QuickBasic Menu definitions can be executed from here on.
' They can be placed in the upper left corner where the Apple
' menu was and stretch across the menu bar.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB44233


BUG: SYSTEM(2) Function Incorrectly Returns 4 Interpreted (44356)

Symptoms

The SYSTEM(2) function should return the QuickBasic number for Microsoft QuickBasic 1.00 for the Macintosh. However, SYSTEM(2) incorrectly returns a value of 4 within QuickBasic's interpreter. The correct value returned should be 1. If the same code is compiled into an application, the correct version number, 1, is returned.

Microsoft has confirmed this to be a bug within the interpreter of QuickBasic 1.00 for the Macintosh. We are researching this problem and will post new information as it becomes available.

More information

The SYSTEM() function in Microsoft QuickBasic 1.00 allows the programmer to obtain useful information about the machine the code is running on.

Refer to Pages 323-324 in the "Microsoft QuickBasic for Apple Macintosh: Language Reference" for more information about the SYSTEM(n) function, where the n argument can be 0, 1, 2, 3, 4, 5, or 6. An additional function, SYSTEM(7), is documented in the Readme file and in separate articles in the Microsoft KnowledgeBase.

Code Example

PRINT SYSTEM(2)   ' Prints 4 interpreted (wrong); 1 compiled (ok)
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB44356


DialoG Status is Not Reset in Interpreter When Program Ends (44495)

Summary

In Macintosh QuickBasic 1.00, the DialoG(1) status is not reset when a program ends. For example, the DialoG(1) function returns the number of the last button that was pushed from the previous run of the program if a new button has not yet been pushed.

This problem occurs only when you make consecutive runs of a program within the QuickBasic editor. This is not a problem with compiled programs.

To work around this behavior, you should first check the value of DialoG(0), which is a "1" if a button was clicked after the program was started. You can then invoke DialoG(1) to see which button number was clicked.

More information

The DialoG(0) function is the central function around which you should design a program to trap a button (or other) event. DialoG(0) returns the next event in the queue of events that occurred since the last invocation of DialoG(0), or since the program began.

Note: DialoG(0) should be invoked only once per cycle in the loop that is polling the value of DialoG(0). For example, you should let x=DialoG(0) in the beginning of the loop, and then use "x" in all subsequent IF statements in that loop cycle. This analyzes one event per loop cycle.

Code Example

The following program demonstrates the behavior of DialoG(1), which works correctly the first time it is run within the editor, but which doesn't work correctly the second time:
   ' initialize the button:
   Button 1,1,"Press to END",(100,100)-(200,200),1
   ' This WHILE LOOP IS Designed TO WAIT UNTIL THE Button IS
   ' Pushed AND THEN EXIT. IT Will NOT Enter THE LOOP IN THE Second
   ' RUN OF THE ProgRAM BECause DialoG(1) Will NOT BE RESET TO 0.
   WHILE DialoG(1) = 0
     initdialog = DialoG(0)
   WEND
   PRINT "END OF ProgRAM"
   END
As a workaround, use the DialoG(0) function instead of DialoG(1) to test for button pushes. For example:
   Button 1,1,"Press to END",(100,100)-(200,200),1
   Button 2,1,"Press to do nothing",(1,30)-(160,60),1
   WHILE NOT ( DialoG(0) = 1 AND DialoG(1)= 1 )
   WEND
   PRINT "Button ";DialoG(1);" WAS Pushed"
   PRINT "END OF ProgRAM"
   END
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB44495


FIX: "Type Mismatch" on Compile When SUBprogram Has >25 Params (44758)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    The program shown below demonstrates that a compiled Macintosh QuickBasic program can pass only 25 parameters to a SUBprogram. If more then 25 parameters are passed, the error message "Type Mismatch" is displayed. The program runs correctly within the environment.

    Possible workarounds for this problem are the following:
    1. Using the ShareD statement in the SUBprogram to allow the program access to the variables, instead of passing them as parameters.
    2. Assigning several of the variables to be passed to an array, then passing the array in place of the variables.
    Microsoft has confirmed this problem in Microsoft QuickBasic 1.00 for Macintosh Systems. This problem is corrected in QuickBasic 1.00b.

    More information

    The following program generates a "Type Mismatch" error at compile time:
    ' Sub Test
DEFINT A-Z

CALL TEST(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
END

SUB TEST(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
   PRINT "Made it!"
END SUB
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB44758


SYSTEM() Function Returns Macintosh Information (44796)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The SYSTEM function in Microsoft QuickBasic 1.00 for the Macintosh can be used to determine information about the system on which the program is running.

    More information

    The SYSTEM(n) function returns a single-precision value representing different information, depending on the value of its numeric argument. The SYSTEM(n) function (where n = 0 to 7) returns the following values:
       Argument (n)    Information Returned
   ------------    --------------------

   0               The Macintosh System version number returned as a
                   real number

   1               The Macintosh computer type returned as an integer
                   code:

                   Returned Value     System Type

                   0                  Unknown
                   1                  Macintosh 512K
                   2                  Macintosh Plus
                   3                  Macintosh SE
                   4                  Macintosh II
                   5                  Macintosh IIx
                   6                  Macintosh IIcx
                   7                  Macintosh SE/30
                  15                  Macintosh Classic

        2               QuickBasic's version number.
                   Note: The call to SYSTEM(2) returns the correct
                   value (1) when compiled, but returns a value of 4
                   when run within the QuickBasic 1.00
                   interpreter. Microsoft is researching this problem
                   and will post new information here as it becomes
                   available.

   3               The math-pack type. A value of 0 indicates binary
                   math; a value of 1 indicates decimal math.

   4               The environment flag. A value of 0 means the
                   program is being run from the QuickBasic
                   environment. A value of 1 indicates the program has
                   been compiled.

   5               The width of the screen on this Macintosh.

   6               The height of the screen on this Macintosh.

   7               The resource file reference number of the currently
                   running compiled application or the currently
                   running interpreted source file. This number can be
                   used by MBLC routines to access resources stored in
                   the resource fork of the current program file.

    Code Example

    The following is a code example with the results of a compiled application running on a Macintosh Plus with the Apple System version 6.00:
       FOR i = 0 TO 6
     PRINT i, SYSTEM(i)
   NEXT i

    OUTPUT:

  0              6
  1              2
  2              1
  3              0
  4              1
  5              512
  6              342
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB44796


INSTR() Function Performs ASCII Compare and Is Case Sensitive (44799)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.01
  • Microsoft QuickBasic 1.02
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 1.0b
  • Microsoft QuickBasic 2.0
  • Microsoft QuickBasic 2.01
  • Microsoft QuickBasic 3.00
  • Microsoft QuickBasic 4.00
  • Microsoft QuickBasic 4.0B
  • Microsoft QuickBasic 4.50
  • Microsoft Basic Compiler for Ms-Dos
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft GW-Basic Interpreter

    • Summary

    The INSTR function (provided in all Microsoft Basics) compares the ASCII values of the search string with the ASCII values of the string to be searched, and is, therefore, case sensitive. For example, when INSTR compares "AB" with "Ab", INSTR returns 0 (zero) because the strings are different.

    This information applies to the following products:

    1. Microsoft QuickBasic 1.00 for the Apple Macintosh
    2. Microsoft Basic Compiler 1.00 for the Apple Macintosh
    3. Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh
    4. Microsoft QuickBasic Compiler 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.0B, and 4.50 for the IBM PC
    5. Microsoft Basic Compiler 5.35 and 5.36 for Ms-Dos
    6. Microsoft Basic Compiler 6.00, and 6.0B for MS OS/2 and Ms-Dos
    7. Microsoft Basic Profesional Development System 7.00 for Ms-Dos and MS OS/2
    8. Microsoft GW-Basic Interpreter Versions 3.20, 3.22, and 3.23

    More information

    The INSTR function returns the character position of the first occurrence of a string in another string. The syntax for INSTR is as follows

    INSTR ( [Start,] string1, string2 )

    where the variables refer to the following:
       Variable  Description

   Start     The [optional] character location to begin searching in
             string1

   string1   The character string to be searched

   string2   The character string to be searched for
    The values returned by the INSTR function are as follows:
       Value     Description

   n         Refers to the character position of string2 in string1.

   0         string2 was not found in string1.

   0         string1 is a null string ("").

   0         The value for Start is greater than the length of string1.
    If string2 is a null string (""), then INSTR returns the value of 1 unless a Start argument was specified, in which case it returns a value equal to Start.

    For more information about the INSTR function, please consult your Basic language reference manual.

    Code Example

       PRINT INSTR("ABCDEF","D")   ' Found in column 4.
   PRINT INSTR("ABCDEF","d")   ' Not found, since case differs
    Output:

    4
    0

    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB44799


BUG: Zero Frequency Still Plays SOUND in Macintosh QuickBasic (45053)

Symptoms

The SOUND statement for Macintosh QuickBasic 1.00 will incorrectly play a very low sound if it is passed a frequency of 0. The syntax for the SOUND statement is as follows:

SOUND frequency,duration,volume,voice

Setting the frequency parameter to zero should either produce an "illegal function call" error message or not produce any sound.

To demonstrate the problem, use the following code example. Make sure the volume is set to high in the Control Panel in the Apple menu:
   PRINT "TYPE Q OR q TO Quit"
   A$ = INKEY$
   WHILE NOT((A$ = "Q") OR (A$ = "q"))
      A$ = INKEY$
      SOUND 0,1,0
   WEND
   END
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB45053


ChangeCursor Changes Macintosh Mouse Cursor to Wristwatch (45056)

Summary

The mouse pointer (cursor) in Macintosh QuickBasic can be changed using the MBLC routine "ChangeCursor id%". The cursor may be returned to the default cursor with the InitCursor routine that is built into QuickBasic. These routines are found on Pages 476 and 410, respectively, in the "Microsoft QuickBasic for Apple Macintosh: Language Reference." Below is a demonstration of how these routines work.

More information

The following sample program changes the mouse cursor shape from the standard arrow to a wristwatch, and then back again:
   id% = 4                      'Wristwatch cursor id number
   PRINT "Press any key to return the cursor to normal"
   ChangeCursor id%
   WHILE INKEY$ = "" : WEND
   CALL InitCursor
   END

Use id% = 1 for Text cursor
          2 for Crosshairs cursor
          3 for Cross-shaped cursor
          4 for Wristwatch cursor
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB45056


Explanation of Top% in ToolBoxSampler Example for QuickBasic (45058)

Summary

This article explains how the variable Top% is used in the ToolBoxSampler sample program. Included are details that explain how the program scrolls a window.

ToolBoxSampler is found in the "QB Demos" folder on the disk for Microsoft QuickBasic for the Apple Macintosh.

More information

The Top% variable is used for two different purposes. The following line determines where to place the window:
   Top% = PEEKW(&HBAA) + (SYSTEM(6)-PEEKW(&HBAA) - 290)\4
PEEK(&HBAA) returns the vertical dimension of the Menu bar. SYSTEM(6) returns the vertical dimension of the screen, so the above code computes a vertical offset that is independent of screen size and starts roughly one-quarter of the way down the screen.

The second use of Top% is part of the "click in scroll box" routine. Its purpose is to determine which line of text was clicked on. The main loop continually calls the ScrollText statement, so that Top% is regularly updated with the actual value of the first line of text currently being displayed in the scroll bar text area. When an item is clicked in the scroll bar text area, the DoMouse routine is called, which includes the following:
   linenum% =(pt%(0) - 6)\21 + Top%
Since the Scroll box rectangle starts at vertical pixel offset 6 [ SetRect src%(0),3,6,114,111 ], the value of pt%(0)-6 is the vertical pixel offset inside the scroll box of the mouse click. The vertical spacing between each of the lines is 21 pixels, so (pt%(0)-6)\21 is the text line offset of the mouse click in the scroll box. Top% contains the offset of the first line of displayed text in the scroll box, so linenum% gets set to the offset into the string that is being displayed in the scroll box.

Note that a backslash (\) is the integer-division operator in Basic.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB45058


No Button Text Using Backpat and TextMode 3 on Macintosh II (45172)

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

Summary

When you invoke the Backpat ROM routine with a black background pattern, the background inside of a type 1 Button turns black and the Button title appears as black letters on white character-sized blocks.

If you invoke TextMode 3 (Black-Is-Changed mode) in addition to the black Backpat, on the Macintosh SE and Macintosh Plus the text defined in the Button is visible as white letters on a black background. However, the text is invisible (black) on a Macintosh II (except while the Button is held down).

This behavior occurs with both the Backpat ROM routine CALL that is built into QuickBasic and also with the ToolBox trap to invoke the Backpat ROM routine. This is not a problem in QuickBasic. This behavior is an aspect of the system and hardware on the Macintosh II.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

TextMode 3 is known as the Black-Is-Changed (BIC) mode. In this mode, black pixels in printed text change to white regardless of the background, and white pixels overlay the background.

Running Example 1 or 2 below on a Macintosh II results in the text within the button not being shown in inverse video, making it unreadable. The Button text is invisible on the Macintosh II. The Button text is visible on the Macintosh Plus and Macintosh SE.

Example 1

The following example calls the Backpat statement that is built into QuickBasic:
OPTION BASE 1                       ' Start Arrays AT 1
WindOW 2,,(2,41)-(200,200),1
DIM pattern%(4)                     ' Array TO Hold Pattern Mask
FOR i%=1 TO 4
pattern%(i%)=&HFFFF                 ' SET ALL Bits ON IN Pattern Mask
NEXT i%

Backpat VARPTR(pattern%(1))      ' QuickBasic's built-in Backpat

TextMode 3                       '    Inverse Text (Black Is Changed)
Button 1,1,"butt",(10,10)-(50,30),1  ' Define Button.
WHILE INKEY$="":WEND

Example 2

The following equivalent example calls the ToolBox statement to invoke the Backpat ROM trap:
OPTION BASE 1                      ' Start Arrays AT 1
WindOW 2,,(2,41)-(200,200),1
DIM pattern%(4)                    ' Array TO Hold Pattern Mask
FOR i%=1 TO 4
pattern%(i%)=&HFFFF                ' SET ALL Bits ON IN Pattern Mask
NEXT i%

ToolBox "i"                        ' Initialize ToolBox
TrapNo%=&HA87C                     ' Trap # FOR Backpat ToolBox CALL
ToolBox "P", TrapNo%, VARPTR(pattern%(1))   ' Perform Backpat CALL

TextMode 3                         ' Inverse Text (Black Is Changed)
Button 1,1,"butt",(10,10)-(50,30),1'
WHILE INKEY$="":WEND
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB45172


QuickBasic AllocTempDesc Gets Descriptor of Last String Used (45173)

Summary

This article describes the AllocTempDesc library support routine, which can be used in interlanguage calling in QuickBasic 1.00 for the Macintosh.

AllocTempDesc is a routine that allocates a temporary Basic string descriptor. The descriptor obtained is the temporary string descriptor for the last string that was assigned a value. For example, if a variable A$ is the last string assigned a value before AllocTempDesc is called, then this is the variable that the temporary string descriptor is allocated for. Temporary descriptors are used by other routines in the support library such as AssignString. AllocTempDesc is documented on Page 458 in the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual.

More information

Library support routines are needed to do interlanguage calling from QuickBasic to Assembly, Pascal, or C language routines. From assembly language routines, library support routines are accessed by using an offset from a jump table pointed to by register A5. Pure-code-resource routines, such as those created in Lightspeed C, must link with the library support routine files provided on the distribution disks in order to use these support routines. More information on library support routines can be found on Pages 457-467 in the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual. The assembly language code for these routines is provided on the QuickBasic 1.00 distribution Examples disk in the User Libraries folder.

Code Example

A sample program, AddString.C, uses AllocTempDesc to add two strings into a third string. This program can be found on the QuickBasic 1.00 Examples disk under the folder path "User Libraries:MBPC Rsrcs:LSC PCR:", where you will find the files "AddString.C" and "AddStrings Proj". You can load this program's source file into the QuickBasic 1.00 editor, but you must have Lightspeed C to compile it into a Pure Code resource.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB45173


ToolBox ForeColor "TYPE Mismatch" Using COL% Instead of COL& (45174)

Summary

The following is a correction for Page 512 of the "Microsoft QuickBasic for the Apple Macintosh: Users Guide." Under the ToolBox routine ForeColor, the example given will produce a "TYPE Mismatch" error because COL% (a short integer) is the wrong type. It should be COL&, a long-integer variable.

More information

The following is a complete, corrected example to invoke the ForeColor ToolBox trap:
   ToolBox "I"
   TrapNo% = &HA862
   col& = 341
   ToolBox "P", TrapNo%, (col&)
   PRINT "This text should be green."
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB45174


How to Eject a Disk in Only One Drive in Macintosh QuickBasic (45175)

Summary

QuickBasic 1.00 for the Apple Macintosh has a built-in routine, Eject (which is an MBPC resource), that allows a program to eject disks at a desired point in the program. The built-in Eject routine ejects disks from both the internal and external drives, but cannot eject only one drive and leave a disk in the other drive.

Instead of using Eject, you can use the following code segment to selectively eject either the internal or external floppy disk.
   ' This program segment will eject the internal drive.
   ' In order to eject the external, you must change
   ' the "1," in the DATA line to a "2,".
   DIM code%(100)    ' DIMmed to 100 for required buffer
   FOR count = 0 TO 6
   READ code%(count)
   NEXT count
   DATA &H41FA, &HC, &H317C, 1, &H16, &HA017, &H4E75
   removedsk = VARPTR(code%(0))
   CALL removedsk
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB45175


BUG: CSRLIN Can Return Incorrect Value for TextSize <> 12 (45419)

Symptoms

The CSRLIN function can return the wrong value when the TextSize is set to other than TextSize 12, which is the default.

Microsoft has confirmed this to be a bug with Macintosh QuickBasic Version 1.00, Macintosh Basic Interpreter Version 3.00 (buglist3.00), and Macintosh Basic Compiler 1.00 (buglist1.00). We are researching this problem and will post new information as it becomes available.

When you use a TextSize other than 12, CSRLIN returns a value of (1 + actual line number) after printing the first print statement. You can work around this behavior by using the LOCATE statement to locate the first PRINT statement.

In the following code example, "Hello" and "world" should be printed on the same line, but they are not. The value for CSRLIN should be 1, but actually is 2:

Code Example

CALL TextSize(9)        ' TextSize (12) works correctly--default
' LOCATE 1,1            ' Add this line to eliminate problem.
PRINT "Hello";
oldCSRLIN%=CSRLIN
LOCATE CSRLIN, POS(0)   ' should locate at current cursor position
PRINT "world"
PRINT "CSRLIN was ";oldCSRLIN%   ' should be 1 -- actually 2
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB45419


Garbage Assigning VAL or Single Precision to Double Precision (45421)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    In the interpreter in QuickBasic (b) for Macintosh, assigning a single-precision constant (directly or through the VAL function) to a double-precision variable can give you extra garbage digits past the seventh significant digit, while the same program gives no garbage digits when compiled. This is not a software problem, but is the way the binary math interpreter implements floating-point type conversion.

    In binary math, to force constants that have a decimal point and seven or fewer digits to higher precision, you must append a number sign (#) character to the constant. Then, assigning that constant to a double-precision variable will convert with double precision (up to 15 significant digits).

    This information applies to the binary math versions of Microsoft Basic (b) Interpreter Versions 2.00, 2.10, and 3.00 and to Microsoft QuickBasic (b) Version 1.00 for the Apple Macintosh.

    More information

    Note: The decimal math (d) version of Basic is more accurate (but slower) than binary math, and type conversions in decimal math are done exactly without showing this behavior.

    To demonstrate the type conversion behavior in binary math, run the following program in the interpreter in QuickBasic (b):
    B$ = "8190.844"   ' Must change to "8190.844#" for better precision.
A# = VAL(B$)
C# = 8190.844     ' Must change to 8190.844# for better precision.
PRINT A#
PRINT C#
PRINT VAL(B$)
    The following results print from the QuickBasic (b) interpreter:
    8190.84423828125    <-- accurate only to 7 digits (single precision)
8190.84423828125    <-- accurate only to 7 digits (single precision)
8190.844            <-- a single-precision constant
    The following results come from the program compiled in QuickBasic (b):
    8190.844            <-- accurate only to 7 digits (single precision)
8190.84375          <-- accurate only to 7 digits (single precision)
8190.844            <-- a single-precision constant
    To avoid accumulation of nonsignificant digits when converting a single-precision constant to double precision, you should type-cast the constant with # or add trailing zeros to make it longer than seven digits.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB45421


Region (Rgn) Routines Not Supported on Apple LaserWriter (45422)

Summary

The Apple LaserWriter does not support Macintosh "regions."

Page 85 of the "Programmer's Introduction to the Macintosh Family" (published by Addison-Wesley, 1988) states "You should never use regions with any image that will be printed. The LaserWriter's firmware does not support regions."

This information applies to Microsoft QuickBasic 1.00 for Apple Macintosh Systems. The WindOW OUTPUT #n statement in QuickBasic cannot be used to redirect regions to the Apple LaserWriter printer.

You can define and manipulate regions with the following MBLC routines, which are built into QuickBasic:
   NewRgn     OpenRgn     CloseRgn    FillRgnHdl   PaintRgn
   FrameRgn   PtInRgn     DiffRgn     InsetRgn     RectRgn
   InvertRgn  SectRgn     MapRgn      DragGrayRgn  SetEmptyRgn
   EmptyRgn   SetRectRgn  EqualRgn    OffsetRgn    EraseRgn
   FillRgn    CopyRgn     DisposeRgn  XorRgn
These MBLC routines are documented in Appendix E.10 on Pages 471 to 497 of "Microsoft QuickBasic for Apple Macintosh: Language Reference." Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB45422


How to Use DisposePtr Toolbox to Release NewPtr Memory Block (45425)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The following information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

    The following code shows how to release memory occupied by a nonrelocatable block of memory that was previously allocated by the NewPtr Toolbox function. How to call the NewPtr Toolbox is described in another article in this knowledgebase (query on NewPtr Toolbox).

    More information

    After the call to the DisposPtr function, all pointers to the released block become invalid and should not be used again. Calling DisposPtr using invalid pointers may damage the master pointer list.

    The following example uses one of two new ToolBox routines, which are explained in a separate article in this knowledgebase (query on ToolBoxNewOS and ToolboxNewTOOL). The NewPtr Toolbox call must be called before the DisposPtr Toolbox call to allocate a block of memory and return a pointer to the variable PointerValue. This variable is then passed to the DisposPtr Toolbox call to free the block of memory. If DisposPtr is successful, the DisposPtr Toolbox call returns an error code of (0) zero.

    Code Example

    DIM RegsArray&(5)
DisposPtr& = &HA01F          'Trap number for the function.
a0& =  PointerValue          'PointerValue is the pointer returned
                             'by the NewPtr function.

ToolBoxNewOS "i"             'initialized the ToolBox call.

ToolBoxNewOS "r",DisposPtr&,RegsArray&(0),(a0&) 'calls DisposPtr
                                                'function.

PRINT "This is the error code: 0 if all goes well", RegsArray(2)
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB45425


How to Allocate a Block of Heap Using NewPtr Toolbox Routine (45426)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The following applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

    The Toolbox routines for allocating and releasing heap space are contained in the Memory Manager. The NewPtr Toolbox function is used to allocate a block of memory from the heap and to return a pointer to that block. The pointer then can be used by your program to reference into that block of memory. When appropriate, the DisposPtr Toolbox function can be used to release the block the memory, as discussed in another article in this knowledgebase (query on DisposPtr and Toolbox).

    More information

    The NewPtr Toolbox routine attempts to allocate a nonrelocatable block of memory from the current heap and if successful, return a pointer to the block. If the block cannot be allocated, NewPtr returns NUL.

    The example below shows how to use the NewPtr Toolbox routine. It requires the use of one of the new ToolBox statements described in a separate article in this knowledgebase (query on "ToolBoxNewTOOL" or "ToolBoxNewOS").

    Code Example

    DIM regsarray&(5)
size& = 1024
Newptr& = &HA11E
ToolboxNewOS "I"
ToolboxNewOS "R",NewPtr&,regsarray&(0),,,(size&)

PRINT HEX$(regsarray&(0))      'print out the pointer
PRINT regsarray&(2)            'print out the error, 0 if none
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB45426


Macintosh QuickBasic Example for PicComment Is Incomplete (45444)

Summary

The example for the PicComment ROM trap on Page 517 in the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual is correct, but is an incomplete code fragment that requires additional statements to work properly. A working example is shown below.

More information

The following are some programming notes for using the PicComment routine on Page 517 of the Macintosh language reference manual:

  1. Note that parentheses (for passing by value) are not required around each of the parameters 190%, 194%, 191%, and 0% when calling the Toolbox routine, since constants are always passed by value (and not by reference). Only variables require parentheses if you wish to pass variables by value.
  2. Note that the QuickBasic editor automatically strips off the percent sign (%) on short-integer constants such as 190%, 194%, 191%, and 0%, which all default to a type of short integer.
  3. The OpenPicture statement gives you a "Type Mismatch" error if you fail to add the statement H&=0 to initialize the H& handle.
  4. You get an "Invalid Function CALL" error if you forget to invoke Toolbox "I" initialization before running this code fragment.

Example 1

Below is a complete, working example of PicComment based upon the example from Page 517 of the Macintosh language reference manual. This program requires an Apple LaserWriter. The program draws a circle and surrounds it with a box drawn around the border of the page using PostScript commands which are embedded in a picture comment.
TrapNo%=&HA8F2   ' This is the address of the PicComment ROM
                 ' trap.
H&=0
DIM rec%(3)
SetRect rec%(0),1,1,638,750   ' Maximum page size put into array
OpenPicture rec%(0),H&  ' Turn on bitmapped picture recording.
   ToolBox "I"  ' Must first Initialize the Toolbox.

   ' Invoke PicComment ROM traps to insert a comment in the
   ' picture:
   ToolBox "P",TrapNo%,190,0,0&
   ToolBox "P",TrapNo%,194,0,0&
   Drawtext "initclip clippath stroke"  ' Postscript commands go
                                        ' here.
   ToolBox "P",TrapNo%,191,0,0&

   ' Draw any graphics you wish to make a picture:
   Circle (100,100),20  ' Draws circle with radius 20.

' Turn off the recording of the picture:
ClosePicture

' Open the printer for graphics mode output:
OPEN "Lpt1:Prompt" FOR OUTPUT AS #1
WindOW OUTPUT #1  ' Redirect window output to the printer.
   DrawPicture H&,rec%(0)   ' Send the picture to the printer.
CLOSE

Example 2

Below is a simpler example of PicComment, which uses QuickBasic's Picture ON and Picture OFF statements (instead of the OpenPicture and ClosePicture MBLC routines used in Example 1). This program requires an Apple LaserWriter.
TrapNo%=&HA8F2   ' This is the address of the PicComment ROM
                 ' trap.
Picture ON  ' Turns on recording of a picture.
   ShowPen   ' Lets you see the picture as it is drawn
             ' (optional).
   ToolBox "I"  ' Must first Initialize the Toolbox.

   ' Invoke PicComment ROM traps to insert a comment in the
   ' picture:
   ToolBox "P",TrapNo%,190,0,0&
   ToolBox "P",TrapNo%,194,0,0&
   DrawText "initclip clippath stroke"  ' Postscript commands go
                                        ' here.
   ToolBox "P",TrapNo%,191,0,0&

   ' Draw any graphics you wish to make a picture:
   Circle (100,100),20  ' Draws circle with radius 20.
Picture OFF ' Turn off the recording of the picture.
a$=Picture$  ' Retrieve QuickDraw-format picture into a string
             ' (a$)

' Open the printer for graphics mode output:
OPEN "Lpt1:Prompt" FOR OUTPUT AS #1
WindOW OUTPUT #1  ' Redirect window output to the printer.
   Picture ,A$   ' Send the picture to the printer.
CLOSE
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB45444


PRINT, LOCATE, then PRINT Misaligned If TextSize Changed (45477)

Summary

After you CALL TextSize to change the output text size, rows of characters that you PRINT on the screen still align on the baseline (pixel row) of the previously printed text size (as shown in Example 3 below). If you subsequently perform a LOCATE statement to change the row position, PRINT rows using that position are misaligned vertically by a few pixels compared to the previously PRINTed text (as shown in Examples 1 and 2).

Thus, to avoid misalignment after CALL TextSize, you should always invoke LOCATE before each PRINT if you plan to use LOCATE at all. LOCATE recalculates the absolute print position (row and column) in a window using the height and width of the character "0" (zero) in the current text size and font.

This information applies to Microsoft QuickBasic 1.00 for Macintosh, the Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for Macintosh, and the Microsoft Basic Compiler 1.00 for Macintosh.

More information

Example 1

In the following code sample, "world" is aligned a few pixel rows above "Hello" unless you add the LOCATE 1,1 statement:
' Note: TextSize 12 starts as the default. Change size as follows:
CALL TextSize(9)
'LOCATE 1,1   ' Add (uncomment) this line to align "Hello world".
PRINT "Hello";
LOCATE 1,6    ' Recalculates cursor position using TextSize 9
PRINT "world"

Example 2

TextSize 20    ' Start at text size 20.
LOCATE 5,1     ' Recalculates printing position using text size 20.
FOR J=1 TO 8   ' Demonstrates 8 different text sizes.
PRINT "CD_ "
TextSize 20-J  ' Make the text size smaller.
' "AB" prints on same pixel row as "CD_", despite changed text size:
PRINT "AB";
LOCATE 5   ' Recalculates the printing row using current text size,
NEXT       ' shifting the next "CD_ AB" combination upwards.
INPUT X$

Example 3

This example shows that changing the TextSize does not move the base line for PRINTing, thus allowing different text sizes to neatly align on the same row. A consequence of this feature is a new alignment different than that used by the LOCATE statement (which recalculates absolute row and column coordinates).
   LOCATE 3,1
   FOR J=1 TO 21 STEP 3
   TextSize 30-J
   PRINT "X_";   ' All these "X_" characters align on the same line.
   NEXT
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB45477


DiffRgn (Region) Example for Macintosh QuickBasic and Basic (45478)

Summary

The following is an example of how to use the DiffRgn toolbox routine in Microsoft QuickBasic 1.00, the Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00, and the Microsoft Basic Compiler Version 1.00 for the Apple Macintosh system.

The DiffRgn routine subtracts two graphics regions to create a third region that is the difference between the two.

More information

Region handles in QuickBasic 1.00 for Macintosh are long integers or single-precision numbers. In the Basic 3.00 interpreter and the Basic 1.00 compiler, they are single-precision numbers.

It is very easy to create a system error when working with any toolbox routine. You should be careful and save your program before any run. Some regions also create SYSTEM errors when DiffRgn is used with them.

The following example is designed to work with the Basic 3.00 interpreter and the Basic 1.00 compiler. To make the example work with QuickBasic, remove the Library statement. When compiling under QuickBasic, compile with the "Include MBPCs & MBLCs" option; otherwise, you get an error 35, "Undefined subprogram."

This program example creates two regions, takes their difference, and displays the result.

Code Example

' This Library is needed for Interpreter 3.00 and Compiler 1.00:
Library "ToolLib"   ' Delete this line to use in QuickBasic 1.00.

' Initialize the region parameters before calling the toolbox routines
' The variables can be long integers in QuickBasic.
picture1! = 0
picture2! = 0
difpic!   = 0

' Define a new region and open it for picture1!
newrgn picture1!
openrgn

' Draw a set of lines in the region.
' Only the LINE command without the bf option can be used for this:
ShowPen
LINE (10,10)-(440,230),,b

'    If the following region is used for picture1! it will create
'    a system error when the diffrgn is taken:
'        FOR i = 1 to 300
'          LINE (0,300-i)-(i,300)
'        NEXT
'    This creates the system error because the toolbox routine
'    does not know how to take the difference of the two regions.

' Close the region:
closergn picture1!

' Define a second new region in picture2!
newrgn picture2!
openrgn

' Draw a figure in the region:
ShowPen
LINE (0,0)-(110,200)
LINE -(130,140)
LINE -(450,150)
LINE -(0,0)

' Close the region:
closergn picture2!

' Define the difference region:
newrgn difpic!

' Take the DiffRgn of picture1! and picture2!.  Picture2! is being
' subtracted from picture2! and the result is put in difpic!
diffrgn picture1!,picture2!,difpic!

' Now clear the screen and display the resultant diffrgn:
CLS
framergn difpic!

' Do a WHILE LOOP to display the picture until a key is pressed:
WHILE INKEY$="":WEND
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB45478


TextWidth "Type Mismatch" Interpreted but Not When Compiled (45479)

Summary

The first reference to a variable cannot be in a toolbox-library routine. All variables used with library (MBLC) routines must be explicitly initialized (assigned to a certain value) before you use them with a library statement. If this is not done, incorrect program behavior may occur. QuickBasic Does NOT explicitly warn you about uninitialized variables passed to toolbox-library routines; thus, you must remember to initialize them.

An example below that uses the TextWidth routine shows the inconsistent symptoms if you fail to initialize passed parameters.

More information

The interpreter in QuickBasic 1.00 for Macintosh gives a "Type Mismatch" error for the following code, but the compiler in QuickBasic fails to give you any error:
     TextWidth a$,size%
     print size%
The proper method to call the TextWidth function is to initialize the variables before invocation. This establishes a region of memory for the variables to be stored. This is also true with all other Toolbox Library Statements. The following code shows proper use of the TextWidth statement:
    a$="A"
     size%=0
     TextWidth a$, size%
     PRINT size%
For a related example, query on the following word in this knowledge base:

GetDirName

The following is taken from Page 420 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual:

E.2.3.1 Initializing Variables

The first reference to a variable cannot be in a ToolBox statement. All variables used with library routines must be explicitly initialized (declared to be a certain value) before you use them with a library statement. This initialization requirement does not apply to array variables, since the elements of an array are automatically initialized to 0 when the array is dimensioned. However, arrays must be dimensioned or referenced in the source code before being referenced in a library call.

Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB45479


How to Draw Border Around Button in QuickBasic for Macintosh (45480)

Summary

This article discusses how to draw bordered buttons in QuickBasic for the Apple Macintosh. The border is drawn in the code example below using the FrameRoundRect statement.

A bordered button has a darker outline than other buttons in a dialog box. A bordered button shows you which button is activated if you just press Enter from the keyboard instead of clicking a button with your mouse.

More information

Note: The technique below doesn't let you make bordered buttons in customized dialog or alert box resources created by ResEdit.

You can see an example of a bordered button within the QuickBasic editor by choosing Options from the Run menu. In the dialog box that appears, the double border on OK shows you that this button will be selected if you press the Enter key on the keyboard.

Code Example

GetButton b,2!
PRINT b

SUB GetButton(actual,Default) STATIC
    WindOW 2,"",(100,100)-(300,200),2
    MakeButton 1!,"1",10!,50!,40!,70!,Default
    MakeButton 2!,"2",60!,50!,90!,70!,Default
    MakeButton 3!,"3",110!,50!,140!,70!,Default
    d=0 : WHILE (d<>6) AND (d<>1) :d=DialoG(0) : WEND
    IF d=6 THEN actual=Default ELSE actual=DialoG(1)
    WindOW CLOSE 2
END SUB

SUB MakeButton(n!,title$,x1,y1,x2,y2,Default) STATIC
    Button n,1,title$,(x1,y1)-(x2,y2)
    IF Default =n! THEN
        Pensize 3,3
        r%(0)=y1-4 : r%(1)=x1-4 : r%(2)=y2+4 : r%(3)=x2+4
        FrameRoundRect VARPTR(r%(0)),16,16
        Pensize 1,1
    END IF
END SUB
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB45480


DrawPicture,,corner%(0) Correction for QuickBasic Page 479 (45482)

Summary

The example for the DrawPicture statement is incorrect on Page 479 of "Microsoft QuickBasic for Apple Macintosh: Language Reference."

If you pass DrawPicture the handle and corner point, you must have two commas separating them. Also, the second sentence describing DrawPicture needs rewording. DrawPicture on Page 479 should be corrected as follows:
   DrawPicture H& [ ,rec%(0) | ,,corner%(0) ]

Draws the picture with handle H&, scaling it to fit in rec%. To draw the picture at a given upper-left point, use the corner% argument, where corner%(0) is a two-element (or point) array, as in the example below:

   DrawPicture H&amp;,,corner%(0)
To draw the picture in its original size and position, use the DrawPicture with only handle H&.

More information

You can draw a picture by passing DrawPicture any of the following three combinations of arguments:

  1. Pass only the handle:
          DrawPicture H&
  2. Pass the handle and the scaling rectangle (determined by two points):
          DrawPicture H&,rec%(0)
  3. Pass the handle and the upper-left corner point to position the picture:
          DrawPicture H&,,corner%(0)
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB45482


File and File Creator Type Can Be Set within Lightspeed C (45484)

Summary

When creating a Pure Code resource in Lightspeed C Version 3.00 for use in a Macintosh QuickBasic 1.00 library, the File type and File Creator type can be set from within the Lightspeed C editor. This is not true for earlier versions of Lightspeed C.

The "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual, Page 451, gives step-by-step instructions for creating a Pure Code resource. Step 6 directs you to leave Lightspeed C, launch ResEdit, and set the File type and File Creator type from within ResEdit.

If you are using Lightspeed C Version 3.00 or later, this can be done from within the Lightspeed C editor by choosing Set Project Type... from the Project menu. A dialog box appears with the option to set the File type and File creator type. For versions earlier than 3.00, Step 6 is still necessary.

"Lightspeed C" is a trademark of the Symantec Corporation. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB45484


BUG: Mouse(0) Doesn't Reset in Reopened WindOW If Compiled (45485)

Symptoms

After closing a WindOW, the Mouse(0) function does not reset to 0 in the next opened WindOW in an application compiled with Microsoft QuickBasic 1.00 for the Macintosh .

The Mouse(0) function should return a 0 (zero) until the mouse button is pressed. When a WindOW is closed and reopened, the first value returned by the Mouse(0) function should be 0. In the QuickBasic interpreter, this is exactly how the Mouse(0) function behaves, but in a compiled application, the first invocation of Mouse(0) improperly returns a 1 when a closed WindOW is reopened.

Microsoft has confirmed this to be a bug in Version 1.00. We are researching this problem and will post new information as it becomes available.

More information

To work around this problem, add the statement x=Mouse(0) to flush the first bad value immediately after the second window is defined, or use the following WHILE statement
     WHILE Mouse(0) <> 1 : WEND
in place of the following:
     WHILE Mouse(0) = 0 : WEND
The following code example waits for a mouse click in the "First Window", but immediately CLOSEs the "Second Window" in a compiled application without an additional click. When run in the interpreter, each WindOW waits for a separate click.

Code Example

WindOW 1,"First Window",(100,100)-(200,200)
   WHILE Mouse(0)=0 : WEND
WindOW CLOSE 1
WindOW 2,"Second Window",(205,205)-(305,305)
' x=Mouse(0)   ' Add this as workaround
   WHILE Mouse(0)=0 : WEND
WindOW CLOSE 1
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB45485


Can't Use Printer Port for Serial COM Input in QuickBasic (45486)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    There are two RS-232 serial communications ports on each Apple Macintosh system that are normally configured as one COM port and one printer port.

    Microsoft QuickBasic 1.00 for the Apple Macintosh uses only one port as the COM port and one as the printer port. Although these two ports are physically and logically identical, QuickBasic recognizes only the first one as the COM port (telephone icon) and the second as the printer port (printer icon).

    You can use only the OPEN "Com1:baud,parity,data,stop" statement to set the communications parameters (for input, output, and random access) on the telephone icon port. On the printer port, marked with the printer icon, QuickBasic cannot change the baud rate, parity, data bits, or stop bits. This limits input possibilities.

    This information also applies to the Microsoft Basic Compiler 1.00 for the Macintosh and the Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Macintosh.

    More information

    When the AppleTalk Network cable is connected to the printer port (normal configuration), then the LLIST and LPRINT statements in QuickBasic send output to the COM port (to a directly connected Apple ImageWriter printer only); and the "LPT1:" and "Lpt1:Prompt" device names send output to the AppleTalk Network printer that is currently selected in the Chooser (in the Apple menu).
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB45486


How to Round Up a Fraction to Its Integral Ceiling in Basic (45686)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.01
  • Microsoft QuickBasic 1.02
  • Microsoft QuickBasic 2.0
  • Microsoft QuickBasic 2.01
  • Microsoft QuickBasic 3.00
  • Microsoft QuickBasic 4.00
  • Microsoft QuickBasic 4.0B
  • Microsoft QuickBasic 4.50
  • Microsoft Basic Compiler
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.10
  • Microsoft GW-Basic 3.2
  • Microsoft GW-Basic 3.22
  • Microsoft GW-Basic 3.23

    • Summary

    The mathematical ceiling function (which rounds up to the next higher integral value for any fraction) is not built into the Basic language. To compute the ceiling, use the following function:
       DEF FNceil#(x#) = -INT(-x#)

   x# = 50.0001
   PRINT FNceil#(x#)    ' Prints 51
    This function is equivalent to the ceil() function in the C language.

    This function works in the following products:

    1. Microsoft QuickBasic 1.00 for the Macintosh
    2. Microsoft Basic Compiler 1.00 for the Macintosh
    3. Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Macintosh
    4. Microsoft QuickBasic Compiler 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.0B, 4.50 for the IBM PC
    5. Microsoft Basic Compiler 5.35 and 5.36 for Ms-Dos
    6. Microsoft Basic Compiler 6.00 and 6.0B and Microsoft Basic PDS 7.00 for MS OS/2 and Ms-Dos
    7. Microsoft GW-Basic Interpreter Versions 3.20, 3.22, and 3.23 for Ms-Dos

    More information

    The code example below can be used in Microsoft QuickBasic 4.00, 4.0B, and 4.50 for Ms-Dos and in Microsoft Basic Compiler Versions 6.00 and 6.0B and Microsoft Basic PDS 7.00 for Ms-Dos and MS OS/2, but not in earlier versions:
    DECLARE FUNCTION ce& (x#)   ' Function returns long integer
DECLARE FUNCTION ceil# (x#) ' Function returns double precision
CLS
x# = 40000005.001#
y# = 50.000000000001#
PRINT ceil#(x#)  ' Prints 40000006
PRINT ceil#(y#)  ' Prints 51
PRINT ce&(y#)    ' Prints 51
PRINT ce&(x#)    ' Prints 40000006
FUNCTION ceil# (x#) STATIC
ceil# = -INT(-x#)  ' Can pass values of x# in double-precision range
END FUNCTION

FUNCTION ce& (x#) STATIC
ce& = -INT(-x#)    ' Values of x# outside -2147483648 to 2147483647
END FUNCTION       ' will give a long-integer overflow error.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB45686


Communications OPEN "Com1: " Also Supports Random Access (45689)

Summary

The "Microsoft QuickBasic for Macintosh: User's Guide," "Microsoft QuickBasic for Macintosh: Language Reference," and the "Microsoft Basic Compiler for Macintosh" manuals all correctly state that the Com1: port can be opened in input and output modes.

However, these manuals also need to state that the Com1: device can also be opened in random access mode.

The sample program Terminal on the QuickBasic, Basic Compiler, and Basic Interpreter release disks correctly demonstrates OPEN "Com1:" with random access.

More information

The following changes need to be reflected in the above manuals.

The third paragraph from the bottom on Page 269 of the "Microsoft Basic Compiler for Macintosh" and the first paragraph on Page 240 of the "Microsoft QuickBasic for Macintosh: Language Reference" needs to be changed from the following

Most Devices are sequential and can be accessed only in sequential modes. Devices that can be opened for sequential input include Kybd:, Clip:, and Com1:. Devices that can be opened for sequential output include SCRN:, LPT1:, Clip1:, and Com1:.

to the following

Most Devices are sequential and can be accessed only in sequential modes. Devices that can be opened for sequential input include Kybd: and Clip:. Devices that can be opened for sequential output include SCRN:, LPT1:, and Clip:. The Com1: device can be opened in random mode, in addition to both sequential input and output modes.

The first paragraph on Page 124 of the "Microsoft QuickBasic for Macintosh: User's Guide" also needs to be changed from the following
   Com1:      Files can be opened to this device for input or output.
              Com1: accesses the asynchronous (modem) port for
              external communication.
to the following
   Com1:      Files can be opened to this device for input, output, or
              random access. Com1: accesses the asynchronous (modem)
              port for external communication.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB45689


Compiled Picture ON Statement Renders WindOW Border Invisible (45691)

Summary

In an application compiled in QuickBasic 1.00 for the Apple Macintosh, executing a Picture ON statement (with no subsequent Picture OFF statement) prior to a WindOW statement may cause problems such as loss of window borders and background, or even system bombs.

If your program invokes Picture ON, it must always invoke Picture OFF before activating another window with a WindOW statement.

More information

The Picture ON and Picture OFF statements were intended to capture output sent to the one current window. This means that changing the current window with another WindOW statement before you use Picture OFF will not capture subsequent output to that window and may cause problems such as loss of graphics, systems bombs, or disabling of MultiFinder. The following program demonstrates the incorrect use of Picture ON, Picture OFF, and WindOW:

Code Example

Picture ON
ShowPen    ' IF This LINE IS Removed, THE WindOW Will BE
           ' Invisible When Compiled

WindOW 1,"",(30,50)-(476,309),2

REM THE Code Below Shows THE Capture DID NOT Work
PRINT "hi"
Circle (50,100),50
Picture OFF
image$=Picture$
WindOW 2   ' Invokes default Untitled window size and type.
Picture (30,50)-(476,309) ,image$
CLOSE 1
WHILE INKEY$="":WEND
STOP
To correct this program, move the first two statements, Picture ON and ShowPen, to be right after the WindOW 1 statement.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB45691


BUG: List Window May Not Update Correctly When Using Bookmark (45893)

Symptoms

The Microsoft QuickBasic 1.00 editor has a problem displaying inserted text when the insertion point is on the same page as a Bookmark.

If you scroll one or more lines after selecting a Bookmark and then select the Next Bookmark option from the Search menu to scroll back to the Bookmark, the text typed at this point can display on the wrong line or fail to display at all.

To refresh the display back to normal, backspace as many characters as you typed and then select List from the Windows menu (or press Command+L), or click the mouse on a different line.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic Version 1.00 for the Macintosh system. We are researching this problem and will post new information as it becomes available.

To avoid this problem when scrolling and using Bookmarks, click the desired insertion point in the Listing window once before inserting characters.

More information

The following steps reproduce this editing display problem:

  1. Run Microsoft QuickBasic (b) or (d).
  2. Load any program with two or more Listing pages.
  3. Click a line, then select Set Bookmark from the Search menu (or press Command+M).
  4. With the mouse, click the scroll bar anywhere to scroll one or more lines.
  5. Select Next Bookmark from the Search menu (or press Command+') This returns you to the Bookmark.
  6. Type any characters to demonstrate the problem. Symptoms include the following:

    1. Characters appear separate from the insertion point.
    2. No characters appear, but the insertion point moves.
To work around this problem, refresh the display back to normal, backspace as many characters as you typed, and select List from the Windows menu (or press Command+L).
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB45893


Edit$ Returns "Invalid Function Call" in Nonactive Window (45894)

Summary

The Edit$ function gives an "Invalid Function Call" (error 5) in Microsoft QuickBasic 1.00 for the Apple Macintosh when trying to retrieve the contents of an Edit FIELD that is not in the active window.

More information

The Edit$ function can be used to return the current contents of an edit field only within the active window. You must first make the Edit FIELD's window active before invoking Edit$. The syntax is as follows, where fieldnumber is the number of the field that was previously defined with an Edit FIELD statement:

Edit$(fieldnumber)

The above statement returns the user's input for a specific field.

If you open a window, define Edit FIELDs, receive input into these fields, change your active window, and try to retrieve the information in the previous Edit FIELDs, you generate an "Invalid Function Call" (error 5).

For more information on the Edit$ function and the Edit FIELD statement, consult the "Microsoft QuickBasic for Apple Macintosh: User's Guide," Pages 113-117.

Code Example

WindOW 1, "Current Edit Window",(50,50)-(320,160),1
Edit FIELD 1,"",(5,10)-(250,100),1
WHILE Mouse(0) = 0 : WEND
names$ = Edit$(1)
WindOW 2, "This is NOW the Current window",(100,200)-(370,300),1
' This next line will generate an "Invalid Function Call"
names$ = Edit$(1)
PRINT names$
WHILE Mouse(0) = 0 : WEND
END
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB45894


Variable Names Starting with "FN" Give "Syntax Error" (45896)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    Using a variable name that begins with the letters "FN" (capital or lowercase) results in a "Syntax Error" when you run the program or when you attempt to compile the program. To avoid this situation, use a different variable name.

    This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh System, Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh System, and Microsoft Basic Compiler 1.00 for the Apple Macintosh System.

    This is not considered a problem of any of these Microsoft products.

    More information

    A variable that begins with the letters FN or fn is assumed to be a function that was previously defined with the DEF FN statement.

    This is not directly stated in the manual, but it is implied in the DEF FN statement documentation (as on Page 98 of "Microsoft QuickBasic for Apple Macintosh: Language Reference."

    To demonstrate a "Syntax Error," enter a line of code that references a variable name that begins with "FN". If you enter the variable name in lowercase letters, the "FN" is automatically capitalized by QuickBasic. Run the program, and the line containing that variable name will be flagged as a "Syntax Error"; for example, the following statement generates the error:
            FNxt$ = "hello"
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB45896


CHAIN Merge Can Repeatedly Append Second Program to First (45899)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft GW-Basic Interpreter 3.20
  • Microsoft GW-Basic Interpreter 3.20 and later
  • Microsoft GW-Basic Interpreter 3.22
  • Microsoft GW-Basic Interpreter 3.23

    • Summary

    When using the CHAIN Merge "filename" statement, you must specify the line number where execution is to begin; otherwise, the program restarts from the beginning and reruns the same CHAIN Merge statement (unless program logic avoids it) in a repeating cycle.

    This information applies to the interpreter in Microsoft QuickBasic Version 1.00 for Apple Macintosh, Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for Apple Macintosh, and Microsoft GW-Basic Interpreter Versions 3.20, 3.22, and 3.23 for Ms-Dos.

    More information

    Note that in QuickBasic 1.00 for Macintosh and in the Basic interpreter Versions 2.00, 2.10, and 3.00 for Macintosh, the CHAIN Merge statement does not merge numbered lines in numerical order, since line numbers, like labels, can be in any order. Instead, CHAIN Merge appends the CHAINed program to the end of the CHAINing program.

    In Microsoft GW-Basic Interpreter for Ms-Dos and in the Basic interpreter Versions 1.00 and 1.01 for Macintosh, line numbers are required on every line, and the CHAIN Merge statement interleaves (rearranges) line numbers in numerical order.

    Code Example

    When the first program below is run, it prints "it1", appends the second program to the first, restarts execution at the first line of the first program, and prints "it1" again. This process repeats without stopping, reappending the second program and printing "it1" each time.

    To have this program run and stop without repeating itself, add a starting line number to the CHAIN Merge statement so it starts on the first line in the second (merged) program.

    The following is program "it1" (which must be saved in ASCII text mode):
       10 PRINT "it1"
   20 CHAIN Merge "it2"
   ' 30 CHAIN Merge "it1", 100    ' use this command instead
    The following is program "it2" (which must be saved in ASCII text mode):
       90 PRINT "it2"
   ' 100 PRINT "it2"           ' use this PRINT line instead
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB45899


Correction for StuffHex, ToolBox Trap Example on Page 523 (45910)

Summary

On Page 523 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference," the example for the StuffHex ToolBox ROM call is incorrect. Several statements are incomplete or missing.

The following is the corrected example:
   Toolbox "i"
   DIM HexPat%(3)
   TrapNo% = &HA866
   MyPat$ = "AA55AA55AA55AA55"
   PasPat$ = ""
   B2PStr MyPat$, PasPat$
   ToolBox "P", TrapNo%, VARPTR(HexPat%(0)), PasPat$ + ""
   END
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB45910


FIX: x MOD 65536& Gives System Error ID=2 in Interpreter (45947)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    Using the MOD operator (modulo arithmetic) with a divisor of 65,536 causes a "Division by Zero Error" and a System Bomb with system error ID=02. Other long integer or integer divisors show no problem. This error occurs in both the Binary and Decimal versions of QuickBasic's environment. The problem does not appear in compiled applications.

    Microsoft has confirmed this to be a bug with the interpreter in Microsoft QuickBasic 1.00 for the Macintosh . This problem is corrected in QuickBasic 1.00b.

    Code Example

       PRINT 10 MOD 65536&  ' Should print 10, but crashes interpreter.
    Note that the QuickBasic editor is designed to automatically append an ampersand (&) character to long-integer constants. 65,536 is equal to 64K (64 times 1024).
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: kbbug KB45947


GET Info Version Number Data Can Be Changed Using ResEdit (45949)

Summary

This information applies to all Macintosh applications.

Prior to the System file Version 6.00, there was no version data ("vers" resource) available from the System Get Info command in the File menu. Programs that were designed to run on earlier Systems therefore did not include a version ("vers") resource. If you have upgraded to System 6.00, you may want to create a resource that will display the version data for a particular application.

The version data ("vers" resource) is typically a string that gives the name, version number, and date of the application, but it can in fact be any data at all. The resource ID of the version data is 0 (zero) by convention.

More information

If you want to add a version resource for an application, use ResEdit. The following are step-by-step instructions of how to use ResEdit to create a version resource and to change the information in an existing version resource.

Do the following to create a version ("vers") resource:
  1. Launch ResEdit.
  2. Open (double-click) the application that you want to modify.
  3. Create a new "vers" resource (use only lowercase letters) with an id =1 and enter the desired text.
Do the following to change the existing information in a version ("vers") resource:
  1. Launch ResEdit.
  2. Open (double-click) the application that you want to modify.
  3. Open (double-click) the resource named "vers".
  4. You will see the hexadecimal code for the version resource in the center of the window. To the right, you will see the ASCII equivalent. You can edit the desired ASCII text by using the Edit Menu to cut out the information you want to change; then, type the information you desire.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB45949


Definition of a Macintosh "Pure Code" Resource (45950)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Microsoft QuickBasic 1.00 for the Apple Macintosh can call "Pure Code" resource routines contained in a Library.

    The following definition of a pure code resource is based on information from Page 82 of "Think's Lightspeed C: User's Manual":

    Pure code resources do not have the complex structure of a device driver or application. They contain code which is called from an entry point. When CALLed from a QuickBasic program, the Basic program loads pure code resources into memory and CALLs them at their entry point.

    More information

    Pure code resources have the following uses:

    1. Routines can be written in other languages, such as C, Pascal, or Assembly. These routines make the features of those languages available to a Basic program. Pure code resources are stored in a Library as MBPC resources. When the Library statement is executed in a Basic program, the external Library file is opened and the MBPC resources are loaded into memory. The Basic program can then call each MBPC by its individual name. (If you store the MBPC routines in the resource fork of QuickBasic itself, or of the compiled application, then the routines are automatically available and callable without executing a Library statement.)

      Libraries make it possible to develop a common set of routines, which can be used in many different Basic programs.
    2. Pure code resources can be used to make Inits. This function of pure code resources does not involve the use of Basic. This is because QuickBasic 1.00 for the Macintosh cannot create pure code resources, it can only CALL them.
    For information about using pure code resource libraries with QuickBasic, please refer to Pages 446-451, Appendix E, of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual.

    Additional information concerning pure code resources can be found in Macintosh reference material such as "Inside Macintosh" (by Apple Computer, published by Addison-Wesley) or "Macintosh Revealed" (by Stephen Chernicoff, published by Hayden Books, a division of Howard Sams & Company) under device drivers and code resources.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB45950


BUG: QuickBasic Can't Print Lightspeed C's Sane Floating-Point (46030)

Symptoms

QuickBasic's NumToASCII and PrintNumber routines for support of pure code (MBPC) libraries cannot use Think's LightspeedC floating-point numbers.

Microsoft has confirmed this limitation in Microsoft QuickBasic Version 1.00 for the Macintosh system. Microsoft is researching this problem and will post new information as it becomes available.

More information

There are two reasons for this incompatibility. First, QuickBasic 1.00 uses the IEEE floating-point format. LightspeedC uses Sane (Standard Apple Numeric Environment), a common floating-point format for Macintosh languages. Second, because a pure code resource must be totally self contained, the C startup code cannot be included and, therefore, is not executed when these routines are CALLed. Part of the function of the C startup code is to initialize floating-point literals.

The support library provided for inter-language calling from QuickBasic is called BasicLib.Lib. Two routines in this library, NumToASCII and PrintNumber, correctly use C's integer and long integer types but cannot correctly convert either the float or the double.

NumToASCII and PrintNumber are documented on Pages 465 and 466 of "Microsoft QuickBasic for Macintosh : Language Reference."

The following code example uses Think's LightspeedC (sold by Symantec Corporation) to create a "Code Resource" that demonstrates the problem. In LightspeedC, the Code Resource should be named "PrintTheNumber" and the library should be named "PrintTheNumber" as well.

Code Example

/*******
  PrintNum.c
*********/

#include <BasicLSC.h>
#define Long_Type   6
#define Double_TYPE 5
#define Sngle_Type  4
#define Int_Type    3

PUBLIC Void main()
{
/* dimension the variables */
/* Variant records and their pointers. */
  NumRec thelongptr,thesingleptr,thedoubleptr;

/* Local work varialbes. */
  StringPtr thestring;
  short int_var;
  long  long_var;
  float single_var;
  double double_var;

  SaveRegs();

/* Initialize the pointers. */
   theintptr = &theint;
   thelongptr = &thelong;
   thesingleptr = &thesingle;
   thedoubleptr = &thedouble;

/* Assign them some values */

  int_var = 32700;
  theint.Int= int_var;

  long_var = 500000;
  thelong.Long = long_var;

  single_var = (float)12.3456789;
  thesingle.Sngle = single_var;

  double_var = (double)12.3456789;
  thedouble.Doble = double_var;

/*******************************************************/
/* Print the numbers using NumToASCII and PrintCString */
/*******************************************************/

  NumToASCII(Int_Type,(NumRecPTR)theintptr,&thestring);
  OutNewLine();

  NumToASCII(Long_Type,(NumRecPTR)thelongptr,&thestring);
  OutNewLine();

  NumToASCII(Sngle_Type,(NumRecPTR)thesingleptr,&thestring);
  OutNewLine();

  NumToASCII(Double_TYPE,(NumRecPTR)thedoubleptr,&thestring);
  OutNewLine();

/**************************************************/
/* Print them out using the PrintNumber function. */
/**************************************************/

  PrintNumber(Int_Type,theintptr);
  OutNewLine();

  PrintNumber(Long_Type,thelongptr);
  OutNewLine();

  PrintNumber(Sngle_Type,thesingleptr);
  OutNewLine();

  PrintNumber(Double_TYPE,thedoubleptr);
  OutNewLine();

  RESTRegs();
}
/*********************** END C ProgRAM *************/

'**********************************************
'*                MBPC test                   *
'* Basic program to call MBPC routine above.  *
'* This program calls the C pure code library *
'* routine to test the PrintNumber and        *
'* NumToASCII functions contained in the      *
'* BasicLib.Lib library.                      *
'**********************************************
Library "PrintTheNumber"
IF SYSTEM(4) THEN CALL Libinit
CALL PrintTheNumber
END
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB46030


"Text editor" Index Entry Doesn't Belong in Language Reference (46373)

Summary

Page 570 in the Index of "Microsoft QuickBasic for Apple Macintosh: Language Reference" misleadingly lists an entry for "Text editor" with the cross-reference "See also Edit".

The cross-reference should actually refer to the "Apple text editor (Edit)" entry on Page 169 of the Index in the "Microsoft QuickBasic for Apple Macintosh: User's Guide." Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB46373


Sending Control Codes to ImageWriter I, II, LQ from QuickBasic (46815)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article discusses how to control printing to an Apple ImageWriter I, II, or LQ from Microsoft QuickBasic 1.00 for the Apple Macintosh.

    A QuickBasic program can either open a printer device name or the communications ("Com1:") port for output. These methods have the advantages and disadvantages described below.

    More information

    The following features allow a QuickBasic program to print to the Apple ImageWriter I, II, and LQ printers:

    1. The Print item in the File menu (to print a source listing)
    2. OPEN "LPT1:" FOR OUTPUT AS #n
    3. OPEN "Lpt1:Prompt" FOR OUTPUT AS #n
    4. OPEN "Com1:baud,parity,data,stop" FOR OUTPUT AS #n
    The first three features above (Print from the File menu, "LPT1:", and "Lpt1:Prompt") work with either a direct connection or a connection through the AppleTalk Network. However, output to "Com1:" requires a direct connection and does not work over an AppleTalk Network.

    Note that the LPRINT statement, "Lpt1:Direct" device name, and "Lpt1:Bin" (which all support sending control characters byte by byte) work only on a directly connected ImageWriter I or II and do not print to an ImageWriter LQ or to the AppleTalk Network.

    There are two alternatives to change the print style or invoke special printing modes for the ImageWriter I, II, and LQ:

    1. Use the OPEN statement to open "LPT1:" or "Lpt1:Prompt" as #n. At this point, a PRINT#n or WRITE#n statement uses the default application text font and size.

      If you now invoke the WindOW OUTPUT #n statement, you can redirect the window output of most ROM routines to the printer. This is one of the most useful features in QuickBasic. Subsequent ROM routines (such as TextFont, TextSize, TextMode, TextFace, and TextMode) can change the text appearance printed by subsequent PRINT statements. (Be sure to use PRINT, not PRINT#n, when WindOW OUTPUT #n is in effect.) The CLOSE#n statement, or filling up a full page, sends the bitmapped output to the printer.

      A disadvantage of the "LPT1:" and "Lpt1:Prompt" device names is that they don't support ImageWriter-specific control characters. Apple's ImageWriter printer driver converts the output to a bitmap. This process is incompatible with byte-by-byte printer control codes or "escape" sequences.
    2. Use the OPEN statement to open "Com1:" as #n. At this point, a PRINT#n statement can optionally send byte-by-byte printer control codes (or "escape" sequences), which are listed in the back cover of Apple's user's guide for the ImageWriter I, II, or LQ.

      When opening the Com1: port for printing to the ImageWriter LQ, you must use a baud rate of 19,200, no parity, 8 data bits, and 1 stop bit.

      When opening the Com1: port for printing to the ImageWriter I or II, you must use a baud rate of 9600, no parity, 8 data bits, and 1 stop bit.

      When printing to Com1:, you must also send carriage return and linefeed characters at the end of each line, i.e., CHR$(13)+CHR$(10).

      A disadvantage of Com1: output is that it does not support the WindOW OUTPUT #n statement.

    Code Example 1

    This code example demonstrates how to print to an ImageWriter I, II, or LQ through the LPT1: port.
    OPEN "Lpt1:Prompt" FOR OUTPUT AS #1
' WindOW OUTPUT #n allows TextFont, TextSize, LINE, Circle,
' and other ROM graphics:
WindOW OUTPUT #1   ' Important: the # character is required here.
TextFont 4
TextSize 9
FOR i = 1 TO 10
   PRINT "This is number ", i
NEXT i
CLOSE #1
END

    Code Example 2

    This code example demonstrates how to print to a directly connected ImageWriter LQ through the Com1: port. This program requires a directly connected printer and will not work over the AppleTalk Network.

    To print to a directly connected ImageWriter I or II, you must change the baud rate from 19,200 to 9600 in the program below. Better yet, don't use this program for a directly connected ImageWriter I or II. Instead, use the LPRINT statement, or WRITE# or PRINT# to the "Lpt1:Direct" or "Lpt1:Bin" device name (which are not supported to the LQ).
    OPEN "Com1:19200,n,8,1" FOR OUTPUT AS #1
' Send ImageWriter escape sequences for bold-faced, ultracondensed:
GOSUB Handshake  ' Turn on hardware handshaking to prevent overflow
PRINT #1, CHR$(27)+CHR$(33)
PRINT #1, CHR$(27)+CHR$(81)
' Send some characters:
FOR i = 1 TO 10
   PRINT #1, "This is number ", i
   ' Send a carriage return and line feed sequence
   PRINT #1, CHR$(10)+CHR$(13)
NEXT i
CLOSE #1
END
' To avoid possible Com1: buffer overflow, you must turn on
' hardware handshaking as follows:
Handshake:
   DIM Code%(100)  ' Array size must be at least 100.
   n=0 : hdhs=0
   FOR j=0 TO 15
     READ n  ' This loop READs machine language code into an array.
     Code%(j)=n
   NEXT
   hdhs=VARPTR(Code%(0))    ' Get address of array.
   CALL hdhs  ' Call machine language instructions (stored in array).
   RETURN
' Below are machine language instructions (represented as
' hexadecimal constants) that invoke the _ContROL ROM routine.
DATA &H41FA,&H001E
DATA &H317C,&HFFF9,&H18
DATA &H317C,&H000A,&H001A
DATA &H217C,&H001,&H1113,&H1C
DATA &H42A8,&H0020
DATA &HA004
DATA &H4E75
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB46815


FIX: Can't Nest SELECT CASE After CASE ELSE in Mac QuickBasic (47059)

Symptoms

The program shown below demonstrates that the error "CASE after CASE ELSE" displays at run time if a second SELECT CASE construct is nested inside another SELECT CASE after the CASE ELSE statement.

Microsoft has confirmed this to be a bug that occurs in the interpreter in Microsoft QuickBasic 1.00 for Macintosh . The problem does not occur in a compiled application.

This problem is corrected in QuickBasic 1.00b.

More information

The following program demonstrates the problem:
INPUT a
SELECT CASE a
   CASE 1
      PRINT "one"
   CASE 2
      PRINT "two"
   CASE ELSE
      INPUT b
      SELECT CASE b
         CASE 1
            PRINT "sub one"
         CASE 2
            PRINT "sub two"
      END SELECT
END SELECT
When the program is run in the interpreter, a "CASE after CASE ELSE" error message displays.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB47059


Font Table Correction for QuickBasic: Helvetica=21, Courier=22 (47061)

Summary

The following two corrections apply to Table D.5, "Fonts Accessible from Basic," on Page 397 of "Microsoft QuickBasic for Apple Macintosh: Language Reference":

  1. The font number for Courier is 22 (not 21).
  2. The font number for Helvetica is 21 (not 22).
This information applies to Microsoft QuickBasic for Apple Macintosh Version 1.00.

More information

For a program that lists the names and sizes of all currently installed fonts, look for a separate article by searching on the following word:

RealFont

The corrected table is shown below, with a few font numbers added for reference. Changes are marked with an asterisk.
   Table D.5

   Fonts Accessible from Basic
   ---------------------------
   Font No.    Font Name
   --------    ---------

    0          System font
    1          Application font
    2          New York
    3          Geneva
    4          Monaco
    5          Venice
    6          London
    7          Athens
    8          San Francisco
    9          Toronto
   10          Seattle
   11          Cairo
   12          Los Angeles    (* Added for reference)
   20          Times          (* Added for reference)
   21          Helvetica      (* number switch)
   22          Courier        (* number switch)
You must run Apple's "Font/DA Mover" program (where DA=Desk Accessory) to install most of these fonts, since only a few of them are installed in the System file, which comes on the Apple System disk for your Macintosh. Note that Microsoft QuickBasic is not shipped with System or Finder files. Font numbers are assigned by Apple.

If you CALL TextFont(n) and font n is not currently installed, then QuickBasic uses the default application font (font 1, Geneva size 12).

Below is an illustration of using various fonts. The fonts first need to be installed with Apple's Font/DA Mover program.
PRINT "This is the default application font."
CALL TextFont(1)
PRINT "This is also the default application font."
CALL TextFont(12)
PRINT "This is Los Angeles font."
CALL TextFont(20)
PRINT "This is Times font."
CALL TextFont(21)
PRINT "This is Helvetica. Helvetica is 21, not 22."
CALL TextFont(22)
PRINT "This is Courier. Courier is 22, not 21. Courier is"
PRINT "      monospaced and columns should line up."
PRINT "Press any key to end."
WHILE INKEY$="" : WEND
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB47061


QuickBasic Page 375 "rograms" Should Say "programs" (47121)

Summary

On Page 375 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual, the third line of the last paragraph should say "programs" instead of "rograms."

This information applies to Microsoft QuickBasic for Apple Macintosh Version 1.00. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB47121


Table 7.1 Reference Should Be 2.1 on QuickBasic Page 126 (47123)

Summary

On Page 126 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual, the last line under "Remarks" incorrectly refers to Table 7.1 ("... as explained in Table 7.1."). This should be changed to Table 2.1.

This information applies to Microsoft QuickBasic for Apple Macintosh Version 1.00. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB47123


Double-Clicking Text File Runs Program of Chosen Creator Code (47352)

Summary

On the Apple Macintosh desktop, double-clicking on a file causes the Finder to run the application that created the file, and the application then loads in the file.

You can change which application runs when you double-click on a file by changing the file's Creator. You can change a file's Creator using QuickBasic's SetCreate toolbox (MBLC) routine, or using ResEdit, as shown farther below. Normally, this change is appropriate only for files of Type "Text" (ASCII only).

To view (or change) the Creator of a file, you can run ResEdit, select the file, and choose Get Info from the File menu. The "Creator" is the four-character code representing the program that created the file. The "Type" is a four-character code describing the save format for a file created under the application. Creator and Type codes are case-sensitive.

Apple's ResEdit program comes with Microsoft QuickBasic 1.00 for Apple Macintosh.

More information

How QuickBasic Assigns the Creator and Type of Files

Microsoft QuickBasic (b) (binary math) version 1.00 for Apple Macintosh saves all Types of source files with a Creator code of "MSBB". Microsoft QuickBasic (d) (decimal math) version 1.00 for Apple Macintosh saves all source files with a Creator code of "MSBA".

If you double-click a file that has a Creator value of "MSBB" or "MSBA", the Finder loads Microsoft QuickBasic (b) or (d), respectively, and then loads the file you double-clicked.

To make a double-clicked text file load itself into a QuickBasic compiled program and to customize the icons, just look in the Readme file for QuickBasic, or search for a separate article with the following words:

Creating and Custom and Icon and BNDL

The following is a table of Creator codes and file Types:
   Method of File Creation               Creator Code   File Type
   -----------------------               ------------   ---------

   Saved in QuickBasic (b) as Text           MSBB         Text
   Saved in QuickBasic (b) as Compressed     MSBB         MSBC
   Saved in QuickBasic (b) as Protected      MSBB         MSBD
   Programs compiled in QuickBasic (b)       MBCB         Appl
   --------------------------------------------------------------
   Saved in QuickBasic (d) as Text           MSBA         Text
   Saved in QuickBasic (d) as Compressed     MSBA         MSBB
   Saved in QuickBasic (d) as Protected      MSBA         MSBP
   Programs compiled in QuickBasic (d)       MBCD         Appl
   --------------------------------------------------------------
   Random and Sequential access files       (blank)       Text
      created by QuickBasic programs
   --------------------------------------------------------------
The Open command on the File menu in QuickBasic displays and opens source files created in that version (decimal or binary) of QuickBasic, plus all files of Type "Text" (regardless of the Creator).

The FILES$(1) function displays files of a given Type (but not of a given Creator). By default, FILES$(1) shows only files of Type "Text" and "Appl" For an example, run the following statement
   PRINT FILES$(1)
To see a list of files of all file Types that QuickBasic (b) makes, type the following:

PRINT FILES$(1,"TextApplMSBCMSBD")

Creator and Type Codes for Common Applications

                                 Type for      Type for Files Saved
Application            Creator  Application      in Application
-----------            -------  -----------    --------------------

Finder                   MACS       FNDR         Not applicable
System                   MACS       Zsys         Not applicable
Mouse (driver)           CDEV       mous         Not applicable
Desk accessories         Dmov       Dfil         Not applicable
Fonts                    Dmov       Ffil         Not applicable
Desktop (a hidden file)  Erik       FNDR         Not applicable
Microsoft Word           MSWD       Appl         WDBN (default)
                                                 Text (optional)
MacWrite                 Word       Appl         MACA (default)
                                                 Text (optional)
WriteNow                 nX^n       Appl         nX^d
PageMaker 2.0            Ald2       Appl         PUBF
Microsoft Excel          Xcel       Appl         XLBN
FileMaker Plus           FMKR       Appl         FMKD
Cricket Draw             CRDW       Appl         CKDT
FullPaint                Pant       Appl         PNTG
Graphics Works           MMCB       Appl         CBOK
Adobe Illustrator        Arty       Appl         Text
MacDraft                 MDFT       Appl         DRWG
SuperPaint               SPNT       Appl         SPTG
Video Works II           MMVW       Appl         VW2P
Macintosh Applications, including QuickBasic and programs compiled in QuickBasic, usually have the Type "Appl".

Below are three methods to alter the Creator and Type codes of a file:

Method 1: Change Creator by Resaving in Desired Application

First, run the original application and save a file as "text only." Then, run the destination application and load the alien text file. If the text file can be loaded, most applications will change the file's Creator field when you save the file. For example, if you create a file in Apple's Edit program and load and save it in Microsoft Word for the Macintosh, that file will then load into Word the next time you double-click it from the desktop.

Note: QuickBasic's editor should be used only to edit the Basic language, not non-Basic text or data. QuickBasic's editor parses and reformats numbers and statements in text files as if they composed a QuickBasic program. A subsequent Save writes the reformatted text file.

Method 2: Change Creator with SetCreate

SetCreate, a toolbox (MBLC) routine built into QuickBasic, can change any file's Creator code as follows:
   filename$="myname"
   creator$="MSWD"    ' Creator code for Microsoft Word 4.00
   SetCreate filename$,creator$
In QuickBasic, save the above program with a filename of "myname" in Text format (NOT compressed or protected). Run myname, and then exit Without resaving. When you next double-click myname, it will load into Microsoft Word (if present).

To load the file back into QuickBasic, run QuickBasic itself, and reopen the file. Resaving in QuickBasic changes the Creator back to QuickBasic ("MSBB" or "MSBA").

The NAME statement in QuickBasic can be used to change the file Type (but not the Creator) of any file:
   filename$="myname"
   type$="Text"
   NAME filename$ AS filename$,type$
However, changing the Type is usually unnecessary.

Method 3: Change Creator in ResEdit

The following steps show how to change a file's Creator (and optionally its Type) in ResEdit:

  1. Before changing a file's Creator and Type, determine what Creator and Type you want to substitute. One way to determine this is to first load into ResEdit a file that was created under the destination application. Write down the four-character Creator and Type codes of this file.

    For each application there may be different Type codes for different methods of saving (and loading) the file. For example, in Microsoft QuickBasic, there are three methods of saving files -- text, compressed, and protected. It would be undesirable to change a file with Type "Text" to Type "MSBD," which labels a protected file, or to Type "MSBC," which labels a compressed file. Normally, you would want to change only file types for files that have the same physical data format in their data fork.
  2. Start ResEdit by double-clicking on its icon. ResEdit comes with Microsoft QuickBasic 1.00 on the Examples Disk and is located in the Tools folder.
  3. Select a file created by the destination application.
  4. From ResEdit's File menu, choose Get Info.
  5. An Info dialog box should appear and the two fields, Creator and Type, should have four-character codes filled in. Write down at least the Creator code.
  6. Close the dialog box.
  7. Select the file you want to change.
  8. Choose Get Info from the File menu.
  9. Change the Creator field to the new four-character code that you had previously written down. You can also change the Type field if the file's data format and new Type coincide with the destination application.
  10. Close the dialog window.
  11. Select Yes to save the Info for the file.
  12. To return to the Desktop, choose Quit from the File menu.
  13. Close the Desktop window that contains the name of the file you just changed.
  14. Reopen the Desktop window that contains the changed file to see that the information under the Kind field now reflects your changes. (Select By Name or By Kind from the Finder's View menu).

    You should now be able to double-click the file to load the corresponding application that you encoded in the Creator field.
Again, if you encounter any problems with changing the ownership of the file, make sure that the file's data format and Type are compatible with the destination application.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB47352


"Invalid Function Call" BitTst Toolbox Example Error, Page 507 (47564)

Summary

On Page 507 in the "Microsoft QuickBasic for Apple Macintosh: Language Reference," the example for the BitTst ROM Toolbox call incorrectly calls the routine with a "P" call type rather than a "B" call type as specified in the Calltype on Page 506. You will get an "Invalid function call" using the example as shown on Page 506.

Note that you must also always invoke the ToolBox "i" statement (to initialize) before you can begin to use the ToolBox statement.

The following is the correct example:
a% = 0
bResult% = 0
ToolBox "i"
TrapNo% = &HA85D
bitOffset& = 3
bytePtr& = VARPTR(a%)
ToolBox "B", TrapNo%, (bytePtr&), (BitOffset&), bResult%
IF bResult% THEN ...
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB47564


BUG: Lcopy Prints Mouse Cursor after HideCursor (47567)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    The Lcopy statement in QuickBasic for Macintosh incorrectly prints the mouse's "watch" cursor (pointer) after a CALL to the ROM routine HideCursor.

    Microsoft has confirmed this to be a bug in Microsoft QuickBasic Version 1.00 for Macintosh . Microsoft is researching this problem and will post new information as it becomes available.

    In earlier versions, such as Microsoft Basic Interpreter 3.00 or Microsoft Basic Compiler 1.00, Lcopy correctly does not print the mouse's "watch" cursor after a CALL to the ROM routine HideCursor.

    More information

    Workaround

    The following program, which contains the subprogram PrintScreen, is a modification of the sample program on Page 172 of "Microsoft QuickBasic for Macintosh : Language Reference." This routine, which uses the graphics GET statement, is not affected by the ROM routines HideCursor and ShowCursor. The cursor will be correctly hidden and restored without appearing on the printout.

    The PrintScreen subprogram (along with a PrintWindow subprogram) is also found as part of the Utility Subprograms file in the QB Demos folder on the Examples disk for QuickBasic 1.00 for Macintosh. Unlike Lcopy, PrintScreen works for color screens and LaserWriters.

    Code Example

    ' You may run this program interpreted or compiled.
' Since this program uses a dynamic array, it must be compiled
' without the "Make All Arrays Static" option.
PRINT "Press RETURN to hide the mouse cursor"
INPUT "and PRINT the screen";a$
HideCursor
'  The PrintScreen subprogram works correctly.
'  The mouse cursor will NOT be printed.
'   *** Uncomment the following line to show the workaround:
' PrintScreen 0,0,0

'  Lcopy will cause the mouse cursor to appear both on
'  the screen and the printout.
'  *** Comment out the following line to demonstrate the
'      workaround above.
Lcopy
PRINT "Right now, the cursor will not be hidden if Lcopy"
PRINT "was used but will be hidden if PrintScreen was used."
INPUT "Hit RETURN to continue.";a$
ShowCursor
END

SUB PrintScreen(scale%,x%,y%) STATIC
  max&=(4+(SYSTEM(6)+1)*2*INT((SYSTEM(5)+16)/16))/8+1
  IF FRE(0) < max&*8+26 OR max&>32767 THEN
     BEEP:EXIT SUB
  END IF
  DIM origin%(1),Screen#(max&)
  LocalToGlobal pt%(0)
  x2 = SYSTEM(5)-origin%(1)
  y2 = SYSTEM(6) - origin%(0)
  GET (-origin%(1),-origin%(0))-(x2,y2),Screen#
  OPEN "lpt1:" FOR OUTPUT AS #10
  WindOW OUTPUT #10
  IF scale% THEN PUT (0,0)-(x%,y%),Screen# ELSE PUT (0,0),Screen#
  CLOSE #10
  ERASE origin%,Screen#
END SUB
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: kbbug KB47567


BUG: FILES$(1) Fails in Interpreter on Mac II, IIcx, SE/30 (47662)

Symptoms

Normally the FILES$(1) function displays all files of type Text and Appl. However, the FILES$(1) function fails to display any files (only folders display) in the QuickBasic 1.0 or 1.0a interpreter (environment) on the Macintosh II, Macintosh IIci, Macintosh IIcx, and Macintosh SE/30 when running under the Finder.

The FILES$(1) function works correctly on the Macintosh II, IIci, IIcx, and SE/30 in the interpreter under MultiFinder.

FILES$(1) works correctly on a Macintosh Plus or normal Macintosh SE, or in QuickBasic compiled programs (on Finder or MultiFinder).

Microsoft has confirmed this problem in Microsoft QuickBasic 1.0 and 1.0a for the Macintosh . This problem is corrected in QuickBasic binary math (b) version 1.0b. However, the problem still occurs on a Macintosh IIci in QuickBasic decimal math (d) version 1.0b.

To work around this problem in 1.0 or 1.0a, or in the 1.0b decimal math interpreter, invoke FILES$(1,"TextAppl") instead of FILES$(1) to allow selection of file types Text and Appl. For example:
   X$ = FILES$(1,"TextAppl")
   PRINT X$
You can also invoke either FILES$(1,"Text") to allow the user to select just Text files, or FILES$(1,"Appl") to select just Appl files.

Note: The prompt string (second argument of FILES$) is case sensitive. "Text" and "Appl" must be all uppercase.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB47662


BUG: AlertMover's Alert->New File Option Doesn't Make New File (47751)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    In Microsoft QuickBasic 1.00 for the Macintosh, the "Alert->New File..." option in the File menu of the AlertMover sample program fails to create a file. Three lines of code can be added and one line deleted in AlertMover to correct this problem, so that you can then create a new file.

    More information

    The following are the steps needed to add the three new lines:

    1. Run QuickBasic (b) and open the AlertMover program, which is found in the Tools folder.
    2. Choose the List option in the Windows menu.
    3. Select the Jump To... option from QuickBasic's Search menu.
    4. Enter line number 91, and the cursor will be located after the doMenu label and on the CASE 2 line of the SELECT CASE statement.
    5. Enter the following two lines, which will be part of CASE 1:
          OPEN res$ FOR OUTPUT AS #1
    CLOSE #1
    6. Again select the Jump To... option from QuickBasic's Search menu.
    7. Enter line number 111 and the cursor will be located at the line that reads as follows:
          ToolBox "WQ",&H997",dest$,rf%
    8. Delete that line.
    9. In its place, add the following line:
          OpenResFile dest$,rf%
    10. Select QuickBasic's File menu and Save the program.

    Code Example

    The following is what the finished code should look like in the areas changed in AlertMover:
    ...
doMenu:
  Menu
  menu.id=Menu(1)
  SELECT CASE menu.id
  CASE 1 :res$=FILES$(0,"Name of New File")

     OPEN res$ FOR OUTPUT AS #1  ' 1. These two lines
     CLOSE #1                    ' 2. need to be added.

  CASE 2 :res$=FILES$(1)
  CASE 4 :END
  CASE ELSE
  END SELECT
...

SUB moveRes(source%,dest$,type$,id%) STATIC
  handle&=0 : rf%=0
  GetRes source%,type$,id%,handle&
  LockRes handle&
  DetachRes handle&

  OpenResFile dest$,rf%   ' 3. This line needs to be added.

  me%=PEEKW(&H900):Toolbox "PQ",&H998,(me%)
...
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB47751


FIX: QuickBasic CopyFile Routine May Return Bad Error Code (47752)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a

    • Symptoms

    The CopyFile routine (an MBLC) supplied with Microsoft QuickBasic versions 1.0 and 1.0a for the Macintosh returns incorrect error codes in some cases.

    Microsoft has confirmed this to be a bug in QuickBasic 1.0 and 1.0a. This problem is corrected in QuickBasic 1.0b.

    More information

    The following is a list of CopyFile error messages that Microsoft has confirmed to be incorrect:
       Incorrect CopyFile Error     Correct Error
   ------------------------     -------------

   57 Device I/O error          61 Disk Full
   53 File not found            70 Disk write-protected
    5 Invalid function call     74 Unknown disk name
    Any CopyFile operation that should produce one of these correct errors instead displays the corresponding incorrect error message.

    How to Use CopyFile

    The syntax of the CopyFile command is the following:
       CopyFile "file", "destination file"
    CopyFile is useful because it copies both the data and resource forks of a file to a destination file. CopyFile is documented only in the Readme file on the QuickBasic 1.0 release disk (not in the manual).

    If an error occurs during CopyFile, the file that was being created stays open. If the disk containing the CopyFile's destination file is ejected after an error occurs, the disk icon is still displayed. This is because the system keeps track of the open file. To remove the disk icon from the screen, run another application or reboot. When that application is finished running, the disk icon is gone.

    CopyFile copies files correctly if an error is not encountered. If you check for the possible errors before you use CopyFile, you guarantee CopyFile's success. Those errors are listed on page 559 of "Microsoft QuickBasic for Macintosh : Language Reference."
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: kbbug KB47752


QuickBasic for Macintosh Not Supported under the Switcher (47757)

The information in this article applies to:
  • Microsoft QuickBasic 1.00

    • Summary

    Switcher is a program that allows multiple applications to reside in memory at the same time. This is similar to MultiFinder; however, no background processing is done under Switcher. Switcher was written by Andy Hertzfeld, and Version 5.00 is copyright 1986 by Apple Computer, Inc.

    Running QuickBasic under Switcher Version 5.00 on a Macintosh II, Macintosh SE/30, or Macintosh IIcx results in a system error or a hang. Older Macintoshes with enough memory to run multiple applications may run QuickBasic with fewer or no problems under the Switcher.

    Microsoft has not tested QuickBasic for the Macintosh under the Switcher. Microsoft does not guarantee compatibilty.

    This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh. Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB47757


How to Create Pop-Up Menus in Macintosh QuickBasic (47782)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article describes how to call ToolBox and ToolBoxNEWTOOL routines to define pop-up/pull-down menus anywhere on the screen (unlike normal menus, which appear only in the menu bar at the top of the screen).

    One limitation to QuickBasic is that the menu items defined with this technique can be selected only with the mouse; Command+key equivalents (such as those defined with the CmdKey MBLC routine) do not function.

    This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

    More information

    The easiest way to define and use menus in the QuickBasic language is through the Menu statement, Menu() function, Menu ON/OFF/STOP statements, and ON Menu GOSUB statement.

    However, advanced programmers can also define pop-up menus through the use of ToolBox calls within Microsoft QuickBasic 1.00 for the Apple Macintosh. The menu definitions can either be created within the program or be stored as a resource.

    The sample code below illustrates the creation of a pop-up menu. The program requires the use of various ToolBox calls along with some ToolBoxNEWTOOL calls. The ToolBoxNEWTOOL MBLC routine is a modified version of the ToolBox MBLC routine in QuickBasic and must be created as described in a separate article. To search for that article, query on the following word:

    ToolBoxNEWTOOL

    The ToolBoxNEWTOOL MBLC should be added as a resource to Microsoft QuickBasic (b) or (d) so it is available for the programs running in the environment. ToolBoxNEWTOOL can then be added to a compiled application by selecting the "Include MBPCs & MBLCs" option when compiling. This option pastes into the compiled application all MBPC and MBLC resources stored within the source program and QuickBasic itself. The "Extra MBLC Remover" sample program can then be used to reduce the size of the file by removing unnecessary MBLC resources from the application.

    Either ResEdit or the "Statement Mover" sample program can be used to add the ToolBoxNEWTOOL MBLC resource to the source program, to the compiled application, or to QuickBasic itself.

    Detecting which menu option was selected must be done by polling the mouse position with a QuickBasic statement, such as GetMouse, instead of invoking a system event-trapping routine such as GetNextEvent. QuickBasic does not allow programs to use the Macintosh ROM routine GetNextEvent because QuickBasic traps all events and empties out the event queue before it allows a ToolBox GetNextEvent call to act upon them. GetNextEvent always returns a value of FALSE (zero) because the event queue is cleared by QuickBasic.

    The code example below makes use of the following ToolBox routines: InsertMenu, PopUpMenuSelect, NewMenu, and AppendMenu. The PopUpMenu SUBprogram handles drawing the user-created menu at specified (x,y) coordinates on the screen and also returns the number of the option the user selected. Then, that value can be acted upon with a simple SELECT CASE structure. A MenuID of -1 tells InsertMenu that the subsequent menu is either a pop-up menu or a hierarchical menu.

    (By calling ToolBoxNEWTOOL, you may also be able to define "hierarchical menus," where selecting a menu item pops up a submenu that branches off to the side. Microsoft has not tested or developed any QuickBasic program examples that perform hierarchical menus, but you can try using the techniques in the program in this article as a base for attempting this.)

    Code Example

    ' ******************************
' Pop-up Menus FOR THE Macintosh
' Written IN QuickBasic 1.00
' August, 1989
' ******************************
DIM ShareD MenuRect%(3)              ' Target box coordinates
DIM ShareD Border%(3)                ' Screen border coordinates
DIM ShareD Pt%(1)                    ' Screen coordinates for menu
DIM ShareD Mpt%(1)
DIM ShareD MH&, MenuID%, X%, Y%      ' Misc. variables
' ******************************
MenuID% = 200                        ' Menu ID number, cannot be
                                     ' negative
MH& = 0                              ' Initialize menu handle
True = -1                            ' Initialize Boolean variable
ToolBox "I"                          ' ToolBox initialization routines
ToolBoxNEWTOOL "I"
X% = 200                        ' Set initial pop-up menu coordinates
Y% = 100
' ******************************
BuildTargetBox
BuildUserMenus                   ' Build the user's menus
WHILE True                       ' Loop while True
  GetMousePosition Bool%         ' Determine mouse position
  IF Bool% THEN                  ' If in target box, continue
    PopUpMenu Result&            ' Pop up user's menu if mouse is down
    Choice% =Result& AND &HFF&   ' Determine which choice they
                                 ' selected
    SELECT CASE Choice%          ' Select the appropriate routine
      CASE 1                     ' Print Hello 10 times
        Times% = 10
        Col = 30
        PrintHello Times%,Col
      CASE 2                         ' Print Hello 20 times
        Times% = 20
        Col = 26
        PrintHello Times%,Col
      CASE 3                         ' Print Hello 30 times
        Times%=30
        Col = 23
        PrintHello Times%,Col
      CASE 4                         ' Print Hello 40 times
        Times%= 40
        Col = 20
        PrintHello Times%,Col
      CASE 6                         ' Change target box location
        CLS
        ChangeCoordinates            ' Get new coordinates
      CASE 8                         ' Quit
        DoEnd
      CASE ELSE           ' CASE ELSE executes if mouse didn't select
    END SELECT            ' an item.
  END IF
WEND                                 ' End While Loop
' ******************************
SUB PopUpMenu (Result&) STATIC
  ' *** Draw the pop up menu and determine the selected choice
  PopUpTrap& = &HA80B
  InsertMenuTrap& = &HA935
  Result& = 0
  Item% = 0
  BeforeID% = -1                    ' Signifies pop-up menu to
  Pt%(0) = MenuRect%(0)             ' InsertMenu routine
  Pt%(1) = MenuRect%(1)
  LocalToGlobal Pt%(0)
  ToolBoxNEWTOOL "PQ",InsertMenuTrap&,(MH&),(BeforeID%)
  ToolBoxNEWTOOL "LQ",PopUpTrap&,(MH&),(Pt%(0)),(Pt%(1)),(Item%),Result&
END SUB
' ******************************
SUB ChangeCoordinates STATIC
  ' *** Let the user determine screen locations for pop-up menu
  MaxX% = SYSTEM(5) - 110
  MaxY% = SYSTEM(6) - 100
  LOCATE 8,17: PRINT "Enter X Value ( 0 < X <"; MaxX%;") "; : INPUT X%
  LOCATE 10,17:PRINT "Enter Y Value ( 0 < Y <"; MaxY%;") "; : INPUT Y%
  BuildTargetBox
END SUB
' ******************************
SUB PrintHello (Times%, Col) STATIC
  ' *** Print Hello x many times
  CLS
  Row = 3
  FOR i = 1 TO Times%
    IF Row > 12 THEN
      Row = 3
      Col = Col + 7
    END IF
    LOCATE Row,Col : PRINT "Hello"
    Row = Row + 1
  NEXT i
  LOCATE 18,20 : PRINT "Hit the Mouse Button To Continue";
  WHILE Mouse(0) <> 1 : WEND
  BuildTargetBox
END SUB
' ******************************
SUB BuildTargetBox STATIC
  ' *** Put Up Target Box
  MenuRect% (0) = Y%
  MenuRect% (1) = X%
  MenuRect% (2) = Y% + 20
  MenuRect% (3) = X% + 78
  CLS
  CALL FrameRect(VARPTR(MenuRect%(0)))
  TextFace 1
  MoveTo X%+2,Y% +15
  PRINT "Click Here";
  TextFace 0
END SUB
' ******************************
SUB BuildUserMenus STATIC
  ' *** Build user's menu
  AddResMenuTrap& = &HA94D
  NewMenuTrap&  = &HA931
  AppendMenuTrap& = &HA933
  ClearMenuTrap& = &HA934
  DrawMenuTrap& = &HA937
  ToolBox "PQ",ClearMenuTrap&          ' Clear top menu bar
  ToolBox "PQ",DrawMenuTrap&           ' Draw empty menu bar
  ToolBox "LQ",NewMenuTrap&, (MenuID%),("Hello"),MH&
  ' You may change the face of menu items as follows:
  ' <I means Italic item.    <B means Bold item.
  ' <O means Outlined item.  <S means Outlined and Bold
  temp$="Hello 10 Times;Hello 20 Times<I"
  ToolBox "PQ",AppendMenuTrap&,(MH&),(temp$)
  temp2$="Hello 30 Times< U;Hello 40 Times<B"
  ToolBox "PQ",AppendMenuTrap&,(MH&),(temp2$)
  ToolBox "PQ",AppendMenuTrap&,(MH&),("(--------------;Change X,Y <O")
  ToolBox "PQ",AppendMenuTrap&,(MH&),("(--------------;Quit<S")
  ' *** This line can be added to include the Apple menu options:
  ' ToolBoxNEWTOOL "PQ",AddResMenuTrap&,(MH&),(&H44525652&)
  ' *** This line is a translation of the previous line:
  ' ToolBoxNEWTOOL "PQ",AddResMenuTrap&,(MH&),("DRVR")
END SUB
' ******************************
SUB GetMousePosition (Bool%) STATIC
  ' *** Determine mouse position, then check to see if it
  ' *** is in the target box
  Bool%  = 0
  GetMouse mpt%(0)
  PtInRect mpt%(0),MenuRect%(0),Bool%
END SUB
' ******************************
SUB DoEnd STATIC
  ' Clear our menu handle and reset menus, then end
  IF MH& <> 0 THEN DisposeHandle MH&
  Menu RESET
  END
END SUB
' ******************************
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB47782


"Syntax ERROR" Correction for QuickBasic PrintScreen Example (47891)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    On Page 172 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual, the PrintScreen example is missing a left parenthesis, "(", on line number 13. The line reads
       max& = (4+(SYSTEM(6)+1)*2*INT(SYSTEM(5)+16)/16))/4+1
    and it should read as follows:
       max& = (4+(SYSTEM(6)+1)*2*INT((SYSTEM(5)+16)/16))/4+1
                                 ^
                                 |
                        added missing parenthesis
    If the program is entered as listed in the manual, a "Syntax ERROR" message is generated during program execution. Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB47891


Common MBLC Toolbox Programming Errors in Macintosh QuickBasic (47970)

Summary

The following are the most prevalent error messages received when programming with MBLC Toolbox Library routines in Microsoft QuickBasic Version 1.00 for the Apple Macintosh:

  1. "Invalid Function Call" (Error 5)
  2. "Type Mismatch" (Error 13)
  3. "Undefined Subprogram" (Error 35)
Common programming mistakes that cause these errors are described further below. This information is taken from Page 524 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual.

More information

  1. "Invalid Function Call" (Error 5) This error can occur when you try to retrieve a nonexistent resource from a resource file.
       ' ************************************************************
   ' Run the following program and an Invalid Function Call error
   ' should be generated because there is no resource "12345".
   ' ************************************************************
   Type$ = "12345"
   Num% = 0
   CountRes Type$, Num%
   PRINT Num%
   END
  2. "Type Mismatch" (Error 13)

    This error can occur under any of the following conditions:

    1. You invoke an MBLC library statement and pass a variable that hasn't been previously defined (initialized).
    2. Not enough variables follow the routine name.
    3. A library statement name is incorrectly declared as a string with a DEFSTR statement.
    4. A passed parameter is of the wrong type.
    You must initialize all parameters in the library routine, whether values are passed or returned. Initializing the variables means giving them a value, whether it be 0 (zero) for numbers or a null string ("") for string variables.
       ' ************************************************************
   ' This program gives a Type Mismatch error because the
   ' Num% is not initialized to 0 before making the call.
   ' ************************************************************
   Type$ = "Icon"
   '  Num% = 0         ' This line needs to be uncommented (added)
   CountRes Type$, Num%
   PRINT Num%
   END
  3. "Undefined Subprogram" (Error 35)

    The error occurs under either of the following conditions:

    1. You invoke a library routine in your listing that is not in the file that you opened with the Library statement or in the resource fork of the currently open QuickBasic source file or application.
    2. A wrong trap number is used for the ToolBox statement.
    When compiling your program, the INCLUDE MBPCs & MBLCs option must be selected if you are using any routines within the Toolbox Library.
       ' ***********************************************************
   ' Compile this program without the INCLUDE MBPCs & MBLCs
   ' option selected, and the Error 35 should be generated when
   ' running the compiled application.
   ' ***********************************************************
   Type$ = "Icon"
   Num% = 0
   CountRes Type$, Num%
   PRINT Num%
   END
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB47970


How to Read "LPT1: Prompt" Dialog Record, Macintosh QuickBasic (47971)

Summary

When you open the printer device from your QuickBasic program with OPEN "Lpt1:Prompt" FOR OUTPUT AS #n, two dialog boxes appear that allow you to set printer options at run time.

The sample program below shows how to read the "Lpt1:Prompt" options selected in the dialog boxes.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

Page II-147 of "Inside Macintosh, Volume II" (published by Addison-Wesley, 1985) describes the Print Manager and shows the record structure for the Print Record and Dialogs. Your application should not change the data in the Print Record. Attempting to set other values directly in the Print Record can produce unexpected results.

Code Example

OPEN "lpt1:prompt" FOR OUTPUT AS #1
CALL GetPrintRecord
CALL ShowPrintRecord
CLOSE
WHILE Mouse(0)<> 1 :WEND
END

SUB GetPrintRecord STATIC
ShareD hPrint&, fLaser, iVRes, iHRes, iFstPage, iLstPage, iCopies
    IF SYSTEM(4) = 0 THEN
       IF SYSTEM(2) <> 4 THEN
          PRINT "Must use Microsoft QuickBasic 1.00"
          BEEP : STOP
       END IF
       PrintHandle& = -6180
       GloblPtr& = PEEKL(&H904)
    ELSE
       DIM GlobalCode%(4)
       GlobalCode%(0) = &H226F             'MoveA.L 4(A7),A1
       GlobalCode%(1) = &H4
       GlobalCode%(2) = &H2288             'Move.L A0,(A1)
       GlobalCode%(3) = &h4E75             'RTS
       GetGlobal& = VARPTR(GlobalCode%(0))
       CALL GetGlobal&(VARPTR(GloblPtr&))   'Get base of global storage
       PrintHandle& = 3626                  'Offset to printer variable
       ERASE GlobalCode%
    END IF

    hPrint& = PEEKL(GloblPtr&+PrintHandle&)
    IF hPrint& <> 0 THEN
        pPrint& = PEEKL(hPrint&)
        iPrVersion = PEEKW(pPrint&)
        iDev = PEEKW(pPrint& + 2)
        iVRes = PEEKW(pPrint& + 4)
        iHRes = PEEKW(pPrint& + 6)
        rPageTop  = PEEKW(pPrint& +  8)
        rPageLeft = PEEKW(pPrint& + 10)
        rPageBottom = PEEKW(pPrint& +  12)
        rPageRight =  PEEKW(pPrint& + 14)
        rPaperTop = PEEKW(pPrint& +  16)
        rPaperLeft = PEEKW(pPrint& + 18)
        rPaperBottom = PEEKW(pPrint& + 20)
        rPaperRight = PEEKW(pPrint& + 22)
        wDev = PEEKW(pPrint& + 24)
        fLaser = 0
        IF (wDev AND &HF00) = &H300 THEN fLaser = -1
        prJob& = pPrint& + 62
        iFstPage = PEEKW(prJob&)
        iLstPage = PEEKW(prJob& + 2)
        IF fLaser THEN
           iCopies = PEEKW(pPrint& +  46)
        ELSE
           iCopies = PEEKW(pPrint&+ 66)
        END IF
    END IF
END SUB

SUB ShowPrintRecord STATIC
ShareD hPrint&, fLaser, iVRes, iHRes, iFstPage, iLstPage, iCopies
    IF hPrint& <> 0 THEN
        PRINT "Print Manager Version = ";iPrVersion
        PRINT "Printer is ";
        IF fLaser THEN
           PRINT "a LaserWriter"
        ELSE
           PRINT "an ImageWriter"
        END IF
        PRINT "Vertical resolution = ";iVRes
        PRINT "Horizontal resolution = ";iHRes
        PRINT "First page = "; iFstPage
        PRINT "Last page  = "; iLstPage
        PRINT "# Copies = ";iCopies
    ELSE
        PRINT "No Print Record allocated"
    END IF
END SUB
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB47971


Foreign Alphabets, OPTION Key, Extended ASCII on Macintosh (47986)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article describes how to display special characters on the Macintosh using the CHR$ function, or using the OPTION or Shift+Option keys to embed characters into quoted strings. You can use special symbols, as well as characters from international alphabets with accents and diacritical marks.

    This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

    More information

    The Apple Macintosh System offers several methods to generate special characters. QuickBasic can take advantage of the special Macintosh characters as follows:

    1. Below are four special symbols assigned to ASCII values 17 through 20, available in TextFont 0. These are detailed on Page I-220 of "Inside Macintosh" Volume I (by Apple Computer, published by Addison-Wesley, 1985):
            Symbol           Character Code
      ------           --------------

      commandMark      17  (Command key symbol)
      checkMark        18  (Check mark)
      diamondMark      19  (Filled-diamond symbol)
      appleMark        20  (Apple symbol)
      The following program displays these symbols:
         TextFont 0
   FOR x = 17 TO 20
      PRINT CHR$(x)
   NEXT
    2. The following program uses the CHR$ function to display the special Macintosh characters assigned to extended ASCII values 128 through 216, which include miscellaneous symbols and Greek and foreign-language characters:
         WIDTH 40   ' Changes screen width to wrap at 40 characters.
   FOR x = 128 to 216
      PRINT CHR$(x);
   NEXT
   WIDTH 255  ' Changes screen back to no automatic wrapping.
      Note that standard ASCII characters are values 32 through 126.
    3. You can also hold down OPTION or Shift+Option and type special symbols into quoted strings or REMarks. (For a map of these characters, select Key Caps from the Apple menu, and press the OPTION key alone, or the Shift and OPTION keys together.) Example:
         A$ = "Hold down OPTION or Shift+Option and type: <option-chars>"
   PRINT A$    ' PRINT the characters to the output window.
    4. The OPTION key can also be used in a two-character sequence to enter the accents or diacritical marks for international language characters. You may type these characters into quoted strings or REMarks. [If a character cannot be accented by the mark you've chosen, you get the mark, followed by the character. Typing the OPTION+key combination followed by a space gives you the diacritical mark alone. Many capital letters don't support accents or diacritical marks on the Macintosh.]:

      For a grave accent (`), type OPTION+` then type the vowel you want to accent (a, e, i, o, u).

      For an acute accent (which slants the opposite of a grave accent), type OPTION+e then type the vowel you want to accent (a, e, i, o, u).

      For a circumflex (^), type OPTION+i then type the vowel you want to accent (a, e, i, o, u).

      For the diacritical mark for an umlaut vowel, type OPTION+u then type the character you want to accent (a, e, i, o, u).

      For a tilde (~) over an n, type OPTION+n then type the character n.

      For a c with a cedilla, type OPTION+c.

      (This information is taken from the "Macintosh System Software Version 6.0: User's Guide", from Apple Computer, Inc.)
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB47986


How to Center the Printing of Any Font in QuickBasic (48013)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article describes how to center a text string in the current output window. This information applies to Microsoft QuickBasic Version 1.00 for the Apple Macintosh.

    More information

    You can invoke the WIDTH(x$) function to automatically determine the width in pixels of any text string (x$) in the current font. You can divide this width by 2 to find the center of any string to be printed.

    The WindOW(2) function determines the width of the current output window in pixels. You can divide this width by 2 to find the center of the current output window. WindOW(3) is the height of current output window in pixels.

    Use CALL MoveTo(X,Y) to position the print position to any desired pixel, then PRINT the string (or use Drawtext, which is faster than PRINT).

    The code example below works for any proportional or nonproportional font.

    Each character in a nonproportional (monospaced) font is exactly the same width in pixels. WIDTH(x$) returns the same width for every character in a nonproportional font. Monaco (TextFont 4) and Courier (TextFont 22, if installed in the System) are examples of nonproportional fonts. (Note that Page 397 of "Microsoft QuickBasic for Macintosh: Basic Language Reference" should be corrected to show Courier as font 22, and Helvetica as font 21.)

    However, most Macintosh fonts are proportional fonts. Each character in a proportional font can have a different width (in pixels), and WIDTH(x$) can return different widths for different characters.

    Code Example

    The following program varies the text size and centers the string printed in the current output window:
    a$="This is centered."
TextFace 1          ' Turns on bold face.
ww=WindOW(2)        ' Width of the current output window in pixels.
hw=WindOW(3)        ' Height of the current output window in pixels.
y=hw/2              ' Start printing halfway down the output window.
FOR j=21 TO 6 STEP -2
TextSize j          ' j varies the text size.
wa = WIDTH(a$)      ' Width of the string contents of a$ in pixels.
x = ww/2 - wa/2     ' x pixel position.
y = y + j           ' y pixel position.
CALL MoveTo(x, y)   ' Move the printing position.
drawtext a$         ' The Drawtext MBLC routine is faster than PRINT.
NEXT
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB48013


Adding ToolBox Type Checking to QuickBasic's MBTS Resource (48057)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article describes how to add argument type-checking in QuickBasic's "MBTS" resource for additional routines so that the Q option can be left off of the ToolBox call. This article expands upon Section E.10.3.3, "Argument Checking" on pages 502 to 503 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual.

    This information applies to Microsoft QuickBasic 1.00 for Apple Macintosh systems.

    More information

    The "MBTS" resource in Microsoft QuickBasic 1.00 currently comes with the trap numbers, call types, and variable types defined for 29 ROM routine calls. You can add argument checking for more (or all) of the Macintosh ROM routines to this resource by using ResEdit supplied with Microsoft QuickBasic.

    Note: Use ResEdit, supplied with Microsoft QuickBasic 1.00. It can be found on the Examples disk in the Tools folder.

    By adding commonly-used ToolBox calls to the "MBTS" resource stored in both the binary and decimal versions of QuickBasic, you can avoid the necessity of adding a "Q" in the Toolbox call argument.

    As mentioned on page 499, you normally add a"Q" to the calltype$ string of the ToolBox statement to skip argument checking and call routines not listed in QuickBasic's "MBTS" resource. If you know exactly what parameters to pass, using "Q" is not a problem; however, one danger of using "Q" is that improperly passed parameters are not trapped, and can make the ToolBox statement hang or crash with a System Error.

    Steps and Code Examples

    The following example program invokes ToolBox statements with a "Q" to avoid type checking for four ROM traps. Below that is a series of steps showing how to use ResEdit to add argument-checking to QuickBasic's MBTS resource so the four ROM traps can be invoked without the "Q".
       MenuID% = 100
   MH& = 0
   NewTrap& = &HA931
   AppendTrap& = &HA933
   InsertTrap& = &HA935
   DrawTrap& = &HA937
   ToolBox "i"
   ToolBox "LQ", NewTrap&,(MenuID%),("OPTIONS"),MH&
   ToolBox "PQ", AppendTrap&,(MH&),("Option 1;Option 2")
   ToolBox "PQ", InsertTrap&,(MH&),(0)
   ToolBox "PQ", DrawTrap&
   WHILE Mouse(0) <> 1 : WEND
   END
    Before starting, it is best to gather all the information needed prior to entering ResEdit to add the argument-checking information. You first need the trap number (in Hex), the call type, and the argument types for each ROM call. The call types and argument types can be obtained from the two charts on page 503. For this example, the information is listed below:
       Procedure        Trap       Call Type        Argument Type(s)
   ---------        ----       ---------        ----------------

   AppendMenu       A933           0              2  4
   InsertMenu       A935           0              2  0
   NewTrap          A931           4              0  4  3
   DrawMenu         A937           0              (no arguments)
    1. Double click on ResEdit (i.e., run ResEdit).
    2. Double click on QuickBasic (either Binary or Decimal).
    3. Scroll down to the "MBTS" resource.
    4. Double click on "MBTS".
    5. Double click on 'MBTS "ToolBox Args" ID = 1'.
    6. This will bring up a window containing the initial listing of the 29 predefined procedures.
    7. Click once on the five (5) asterisks (*****).
    8. Select New from the File menu (or press Command+N).
    9. A new trap number and call type should become available.
    10. Click on the trap number box and enter the first trap number you want to define (A933). This number must be entered in the Pascal format for Hex numbers (that is, $A933).
    11. Click on the call type box and enter a value for the call type needed. In this example, 0 would be entered.
    12. Click on the five (5) dashes (-----).
    13. From the File menu, select New (or press Command+N).
    14. Click on the argument type box and enter the argument type for the first parameter. In this example, enter 2.
    15. If more argument types are needed, go back and repeat steps 11 through 13 for each parameter being passed. In this example, you would repeat the process one more time and enter a 4.
    16. One ToolBox call has been added so far to the "MBTS" resource. If you need to add more routines to the "MBTS" resource, as in the example, you would need to repeat steps 6 through 14 three more times.
    17. Once you are completed adding routines, you can close this window.
    18. Close the next window.
    19. Close the next window.
    20. Answer Yes to the dialog box if you would like your changes to be saved, or No if not.
    21. From the File menu, choose Quit to end ResEdit.
    22. Now all of these routines entered can be called from within this version of QuickBasic without having to add the "Q" on the ToolBox call.
    When running code that makes calls to these newly added routines and errors result, you can check your entries and edit them by using the same process and go under ResEdit and bring up QuickBasic again.

    The example program could now be coded as follows:
       MenuID% = 100
   MH& = 0
   NewTrap& = &HA931
   AppendTrap& = &HA933
   InsertTrap& = &HA935
   DrawTrap& = &HA937
   ToolBox "i"
   ToolBox "L", NewTrap&,(MenuID%),("OPTIONS"),MH&
   ToolBox "P", AppendTrap&,(MH&),("Option 1;Option 2")
   ToolBox "P", InsertTrap&,(MH&),(0)
   ToolBox "P", DrawTrap&
   WHILE Mouse(0) <> 1 : WEND
   END
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB48057


Macintosh Basic MS Press Book References No Longer Published (48726)

Summary

The following Microsoft Press book references, found on Pages 8 and 9 of "Microsoft QuickBasic for the Apple Macintosh: User's Guide," are no longer in publication:

  1. Lambert, Steve. "Creative Programming in Microsoft Basic: For Optimal Macintosh Performance." Redmond, Washington: Microsoft Press, 1985.
  2. Waite, Mitchell, Robert Lafore, and Ira Lansing (The Waite Group). "Microsoft Macinations: An Introduction to Microsoft Basic for the Apple Macintosh." Redmond, Washington: Microsoft Press, 1985.
  3. Waite, Mitchell, Dan Putterman, Con Urquhart, and Chuck Blanchard (The Waite Group). "Macintosh Midnight Madness: Utilities, Games & Other Grand Diversions in Microsoft Basic for the Apple Macintosh." Redmond, Washington: Microsoft Press, 1985.
These books can be obtained in your local public library, college library, or used-book store. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB48726


PRB: ScrollText & Improper RETURN from ON Event GOSUB Can Bomb (48727)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    In Microsoft QuickBasic 1.00 for the Macintosh, system bombs or machine hangs can result from returning improperly from GOSUB subroutines for event-trapping when the ScrollText MBLC routine is used. This can occur in compiled applications and in the QuickBasic interpreter. Different system bomb ID numbers can result, but the most common one encountered is "System Error ID = 02."

    Resolution

    To avoid problems when you perform ON Event GOSUB statements (such as ON Menu GOSUB), be sure to RETURN from handling the event before attempting to handle the next event.

    More information

    Below is an example of an incorrectly designed QuickBasic program that does not return properly from an ON Menu GOSUB routine. The program is condensed from a customer's larger program. The problem occurs from doing an ON Menu GOSUB statement followed by a GOSUB to a routine that turns Menu ON (mistakenly), invokes ScrollText, and is improperly exited by trapping the user-defined Quit menu option.

    The program needs restructuring so that Menu remains OFF while handling a Menu event (between the ON Menu GOSUB and the RETURN). Also, the ScrollText routine should be moved to a loop at the main level code so Menu events can be used in proper conjunction. You should also execute DisposeScroll when finished using the ScrollText statement.

    The necessary program revisions are not written in the program below. Please refer to the ToolBoxSampler program in the "QB Demos" folder on the QuickBasic 1.00 release disk for a similar working example. ToolBoxSampler polls the Menu() function instead of trapping Menu events with the ON Menu GOSUB statement.

    Example of Incorrect Programming

    To encounter the system bomb, choose the Quit option under the OPTION One menu two times. This produces a system bomb the first time when run as a compiled application, but in the environment you might have to run it a few times to get a system bomb.
    DEFINT a-z
DIM HILOW$(31)
QuitFlag=1
GOSUB restoreall
ON Menu GOSUB doMenu: Menu ON
WHILE 1 : WEND

doMenu:
     MenuID = Menu(0)
     MenuItem = Menu(1)  'SELECT CASE MenuID
     CLS
     SELECT CASE MenuID
           CASE 1  'FILE  menu
               SELECT CASE MenuItem
                   CASE 1 : GOSUB Quitsub
               END   SELECT
           CASE 2
               SELECT CASE MenuItem
                   CASE 2 : GOSUB HiLowList
               END SELECT
     CASE ELSE
     END SELECT
     Menu
RETURN

HiLowList:
   Menu ON   ' Bad program design: should be no Menu ON here,
             ' and you can't expect to trap Menu selection events in
             ' the ScrollText loop below, since you haven't yet
             ' RETURNed from the Menu event which got you here.
   linenum% =0:  top%=0:  S&=0:  in%=0:  SS&=0
   SetRect scr%(1),3,60,275,270
   FrameRect VARPTR (scr%(1))
   SetRect Bar%(1),274,60,290,270
   NewScroll S&,Bar%(1),1,1,20,1: 'verticle
   QuitFlag=3
   WHILE Mouse (0)<>1  'This Loop is only exited by the Menu Option
        ScrollText S&,scr%(1),HILOW$(1),top%,31,linenum%
   WEND
RETURN                 'This RETURN is never executed.

restoreall:
   Menu 1,0,1,"File"
   Menu 1,1,1,"Quit":cmdkey 1,1,"Q"
   Menu 2,0,1,"OPTION ONE"
   Menu 2,2,1,"OPTION TWO":cmdkey 2,2,"H"
RETURN

hilowend:
     DisposeScroll S&
     WindOW CLOSE 1
     WindOW 1
RETURN

Quitsub:
   IF QuitFlag=1 THEN GOSUB restoreall : PRINT "the end" : END
   IF QuitFlag = 3 THEN QuitFlag=1 : GOSUB hilowend : GOSUB restoreall
RETURN
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbprb KB48727


BUG: QuickBasic WindOW Type 2 Disable Switching w/ MultiFinder (49129)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    In Macintosh QuickBasic 1.00, using a WindOW of type 2, which has a double border, disables the ability to switch among applications with MultiFinder. If the current output window is a type 2 WindOW, then clicking on the MultiFinder icon produces no results.

    Microsoft has confirmed this to be a bug in QuickBasic 1.00 for the Macintosh . We are researching this problem and will post new information as it becomes available.

    More information

    You can work around this problem by using WindOW type 3, which does not disable MultiFinder, instead of WindOW type 2. WindOW type 2 has a double border and WindOW type 3 has a single border, but the effect of WindOW type 2 can be simulated with one of the following workarounds:

    1. Create a WindOW of type 3, draw the appropriate borders, and then use the WindOW. The disadvantage to this method is that the program must constantly control output to the WindOW and detect refresh events to ensure that the borders are not overwritten or overlayed.
    2. Use two WindOWs of type 3, making the first WindOW larger and having a wide border around the edge. Make the second slightly smaller and place it directly "inside" of the first without covering WindOW #1's borders. This gives the effect of a double border window.

    Code Example

    The second workaround is demonstrated in the following code example:
    '*****************************
'* Double Border Window      *
'*****************************
DIM Win1Rect%(4) ' This will hold the coordinates for the border.
ON DialoG GOSUB dlghandler
ON Menu GOSUB MenuHandler
Menu 1, 0,1, "File"
Menu 1,1,1,"Quit"

Message$ = "This is the current output window!"
ScreenW% = SYSTEM(5) - 50 ' Set window width (with margin).
ScreenH% = SYSTEM(6) - 50 ' Window Height (minus margin).
Corner% = 40  ' This is x and y coordinate for top corner of window.
Indent% = 8 ' This is the amount to indent the second window

WindOW 1,,(Corner%,Corner%)-(ScreenW%,ScreenH%),3
x1%=Corner%+Indent%
y1%=Corner%+Indent%
x2%=ScreenW%-Indent%
y2%=ScreenH%-Indent%
WindOW 2,,(x1%,y1%)-(x2%,y2%),3

' The following two statements draw the window for the first time:
RefreshFlag% = 5
GOSUB firsttime
LOCATE 5, 5
PRINT
' Turn on the event trapping:
DialoG ON
Menu ON
WindOW OUTPUT 2
' **** Main program loop ****
WHILE 1   ' Sits and waits for dialogs or menus to happen.
WEND

terminate:
   END

MenuHandler:
   ' If user chooses to Quit from the File menu.
   IF Menu (0) = 1 AND Menu(1) = 1 THEN
         ' Close windows before quitting.
         WindOW CLOSE 1
         WindOW CLOSE 2
         RETURN terminate
    END IF
    ' Otherwise, continue.
    RETURN

dlghandler:
   RefreshFlag% = DialoG(0)
firsttime:
   IF RefreshFlag% = 5 THEN
      RefreshFlag% = 0 ' Reset the flag.
      WindOW OUTPUT 1
      x2% = WindOW(2)      ' Width of the window.
      y2% = WindOW(3)      ' Height of the window.
      SetRect Win1Rect%(0),0,0,x2%,y2%
      CALL Pensize (3,3) ' Make the border fatter.
      FrameRect VARPTR(Win1Rect%(0)) ' Refresh the border.
      ' Return control back to the other window.
      WindOW OUTPUT 2
      ' Refresh the message.
      LOCATE 5,5 : PRINT Message$
   END IF
RETURN
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: kbbug KB49129


BUG: When Compiled, LINE INPUT Fails/Hangs w/ 341 Iterations (49211)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    The LINE INPUT statement, in a compiled application, fails after 341 iterations. The system hangs for a moment, then displays random ASCII characters on the screen. On the newer Macintoshes (i.e., Macintosh II, Macintosh IIcx, Macintosh SE/30), the machine will just hang. In the QuickBasic interpreter environment, the problem doesn't occur.

    Microsoft has confirmed this to be a bug in Microsoft QuickBasic Version 1.00 for the Macintosh . We are researching this problem and will post new information as it becomes available.

    Code Example

    1000  LINE INPUT "Part No?"; a$
      l% = l% + 1
      PRINT l%
      GOTO 1000
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB49211


No Watch in Debug Menu of QBI.exe Interpreter Academic Edition (49258)

Summary

Microsoft QuickBasic Interpreter (QBI) Academic Edition Version 1.00 was shipped in a box that mistakenly shows a picture of Microsoft QuickBasic 4.50 screen menus. The Debug menu in QuickBasic 4.50 has Watch... features that are not available in the QuickBasic Academic Edition Interpreter (QBI.exe) Version 1.00.

The Watch... features shown on the Academic Edition (QBI.exe) 1.00 package are available in QuickBasic 4.50, which is a more complete and powerful product.

More information

The QuickBasic Academic Edition Interpreter (QBI.exe) Version 1.00 doesn't have any of the following Debug menu features, but QuickBasic (QB.exe) Version 4.50 does have them:

Add Watch...
Instant Watch...
Delete Watch...

Where these menu items appear in the Debug menu on the package picture, QBI.exe actually has Step and Procedure Step options. The Debug menu in QBI.exe actually displays as follows:
   Step                    F8
   Procedure Step          F10
   Trace On
   Toggle Breakpoint       F9
   Clear All Breakpoints
   Set Next Statement
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB49258


VAL Function Concatenates Digits That Have Embedded Spaces (49709)

Summary

The VAL function concatenates all digits that are separated by a space, a tab, or a linefeed character in the string argument.

In other words, VAL ignores space, tab, and linefeed characters that are embedded (leading or trailing) in the string argument. For example, the following code prints a value of 345678 (not 34):
   a$ = "  34  56  78"
   PRINT VAL(a$)
This behavior applies to Microsoft Basic on most operating systems, including the following products:

  1. Microsoft QuickBasic 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.0B, and 4.50 for the IBM PC
  2. Microsoft Basic Compiler 6.0, and 6.0B for Ms-Dos and MS OS/2
  3. Microsoft Basic Profesional Development System 7.00 for Ms-Dos.
  4. Microsoft Basic Compiler 5.35 and 5.36 for Ms-Dos
  5. Microsoft GW-Basic Interpreter Versions 3.20, 3.22, and 3.23
  6. Microsoft QuickBasic 1.00 for the Apple Macintosh
  7. Microsoft Basic Compiler 1.00 for the Apple Macintosh
  8. Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh

More information

The following code prints a value of 123.45 (not just 12) because spaces are ignored. The first decimal point is treated as part of the number, and the second decimal point acts as a delimiter:
   a$ = "12  3.4  5.6"
   PRINT VAL(a$)
The following examples also print 123.45, thus showing that tab and linefeed characters, as well as spaces, are ignored by the VAL function:
   a$="12"+CHR$(9)+" 3.4  5.6")    ' CHR$(9) is a tab character.
   PRINT VAL(a$)    ' PRINTs 123.45
   a$="12"+CHR$(10)+" 3.4  5.6")   ' CHR$(10) is linefeed character.
   PRINT VAL(a$)    ' PRINTs 123.45
To work around this behavior, make sure to separate with commas the numbers passed to VAL in a string. You can also parse the string into a new string before invoking VAL, such as in the following workaround.

Workaround

Workaround Example

This program parses a string a$ such that the first trailing blank delimits the end of a number.
This program parses a string a$ such that the first trailing blank
delimits the end of a number.

PRINT "Enter the numeric string to parse ";
LINE INPUT a$
x = 1
b$ = ""
c$ = ""
DO UNTIL x > LEN(a$)
   c$ = MID$(a$, x, 1)    ' Puts character at column x into c$
   IF c$ <> CHR$(32) THEN
      b$ = b$ + c$        ' Build a string with no spaces.
   ELSEIF LEN(b$) > 0 THEN
      PRINT VAL(b$)
      EXIT DO             ' Stop parsing if trailing blank is found.
   END IF
   x = x + 1
LOOP
Programming note: The above example uses the DO...Loop statement, which requires QuickBasic 3.00 or later. For other products, use a different looping structure.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB49709


INKEY$ Can't Distinguish F1-F15 on Macintosh Extended Keyboard (49710)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft Basic Compiler

    • Summary

    The INKEY$ function returns the same value, decimal 16 (or hexadecimal 10), when any function key from F1 through F15 is pressed on a Macintosh Extended Keyboard. This means that you can trap the function keys F1 through F15, but you cannot distinguish one from another. This is a design limitation, as explained further below.

    More information

    The only way for a program to trap keys in Macintosh QuickBasic 1.00 is to use the INKEY$ function. This means that a program that requires key trapping must be designed to have one or more small loops that poll for keyboard input using the INKEY$ function waiting for the user to press a key. INKEY$ traps the function keys F1 through F15 but always returns the same value, decimal 16.

    This behavior is a result both of how keyboard input is designed on the Macintosh and of how Basic handles keyboard input. Key events on the Macintosh return two representations for the key:

    1. The character code, which is essentially the ASCII representation.
    2. The key code, which represents a specific key on the keyboard. The key code is different for different models of the keyboard, and it isn't affected by any of the modifier keys like the Shift, OPTION, or Command key.
    Basic queues the character codes and ignores the key code. Because Apple designed function keys so that they always return a decimal 16 for the character code, a Basic program cannot distinguish among the function keys by using the character code. The function keys can be differentiated only by looking at their key codes, but that information cannot be obtained in a Basic program.

    To distinguish among the function keys, you must be able to call the Toolbox routine GetNextEvent. However, GetNextEvent doesn't work from QuickBasic (or Basic) because QuickBasic itself intercepts all system events before GetNextEvent can receive them. For more information on why GetNextEvent does not work from QuickBasic, search for the word GetNextEvent.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB49710


LocalToGlobal/GlobalToLocal Convert Window/Screen Coordinates (49753)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article gives examples of how to use LocalToGlobal and GlobalToLocal, which are Microsoft Basic Library Code (MBLC) routines built into Microsoft QuickBasic 1.00 for the Apple Macintosh.

    LocalToGlobal and GlobalToLocal are useful to coordinate graphics statements that use screen coordinates with those that use window coordinates.

    LocalToGlobal takes a point, measured in y and x coordinates in pixels relative to the current output window, and returns its current coordinates relative to the Macintosh screen.

    GlobalToLocal takes a point, measured in y and x coordinates in pixels relative to the Macintosh screen, and returns its current coordinates relative to the current output window.

    More information

    On the Macintosh, a point at coordinates (0,0) is at the upper-left corner (of the screen or window). Pixels in the y direction are positive when below the upper-left corner. Pixels in the x direction are positive when to the right of the upper-left corner.

    LocalToGlobal Example

    The following program shows how the global screen coordinates of a fixed local window point change as the window is dragged:
    WindOW 1,"Move this window",(100,100)-(400,200),1
localx = 3            ' x coordinate relative to window
localy = 30           ' y coordinate relative to window
PRINT "y="; localy; "x="; localx; " in window coordinates is..."
DIM p%(1)   ' First element of p% array is y coordinate, second is x.
WHILE INKEY$ = ""     ' Loop until any key is pressed.
  p%(0) = localy      ' Reassign window y coordinate.
  p%(1) = localx      ' Reassign window x coordinate.

  ' LocalToGlobal converts localx,localy window coordinates to
  ' global (screen) coordinates:
  LocalToGlobal p%(0)

  LOCATE 3,1
  MoveTo localx,localy
  PRINT CHR$(165)    ' Prints a dot at position fixed within window.
  PRINT "y="; p%(0); "x="; p%(1); " in screen coordinates      "
WEND
WindOW CLOSE 1

    GlobalToLocal Example

    The following program shows how the local window coordinates of a fixed global screen point change as the window is dragged:
    WindOW 1,"Move this window",(100,100)-(400,300),1
globalx = 250
globaly = 150
DIM p%(1)  ' First element of p% array is y coordinate, second is x.
PRINT "y="; globaly; "x="; globalx; " in global coordinates is..."
WHILE INKEY$=""    ' Loop until any key is pressed.
  p%(0) = globaly   ' Reassign fixed global y coordinate
  p%(1) = globalx   ' Reassign fixed global x coordinate

  ' GlobalToLocal converts global screen coordinates to
  ' local x, local y coordinates for the current output window:
  GlobalToLocal p%(0)

  LOCATE 2,1
  PRINT "y="; p%(0); "x="; p%(1)" in window coordinates     "
  ' The following PRINTs a big dot (extended-ASCII character 165)
  ' at screen coordinates globalx,globaly. If you put one finger on
  ' the dot, and drag the window around with the other hand, you will
  ' see that the dot is drawn at the same screen position but at
  ' different coordinates relative to WindOW 1.
  MoveTo p%(1),p%(0)   ' Move pen to local window coordinates.
  PRINT CHR$(165);
WEND
WindOW CLOSE 1
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB49753


How QuickBasic Can Use the 38 Patterns in System PAT# Resource (49888)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article describes how to access all the patterns in the System resource PAT#. The sample program shows all the patterns on the screen and gives the corresponding pattern number in the list of patterns.

    This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

    More information

    The example below gets the resource handle for the PAT# resource from the System file. The handle is used to point to where the system patterns are loaded in memory.

    PEEKing at the first word at this location gives you the number of patterns located in the System resource PAT#. The next eight bytes contain the first pattern, and each following eight bytes contains a pattern until all the patterns are looked at.

    Each pattern can be put into a four-dimensional integer array and can be displayed using the FillRect routine. Once the pattern is in the array, you could then put it in any resource file with a new handle.

    Sample Code

    id% = 0      ' The Systems Pattern has an ID of zero.
h& = 0       ' Initialize h&.
sysref%=0    ' Zero can be used as the System's reference number.
             ' No OpenResFile statement is necessary, since the
             ' the resource fork of the System file is always open.
getres sysref%,"PAT#",id%,h&  ' Get the handle to resource PAT#.
lockRes h&
StartPatternList&=PEEKL(h&)   ' Get the starting address of where
                              ' resource PAT# is located in memory.

NumOfPattern%= PEEKW(StartPatternList&)  ' Get the number of patterns
                                         ' stored in the PAT# list.

DIM pat%(3)  ' An array to hold the current pattern being displayed.
             ' It takes only 8 bytes to store a pattern.

DIM rect%(4*NumOfPattern%)  'An array to hold the dimensions of the
                            'rectangle to be filled with the pattern

' The following FOR loop sets up all the rectangle regions.  Each
' rectangle region is 50 x 50 pixels and each will be filled with one
' pattern.

XCount% = 1
YCount% = 1
FOR i = 1 TO NumOfPattern%
   IF XCount%= 10 THEN
      YCount% = YCount% + 1
      XCount% = 1
   END IF
SetRect rect%(i*4-4),XCount%*50-50+1,YCount%*50-50+1,XCount%*50,YCount%*50
   XCount% = XCount% + 1
NEXT i

' The following FOR loop loads a different pattern into each
' rectangular region. As each rectangle is filled with a pattern,
' it will be displayed on the screen.

FOR i = 1 TO NumOfPattern%
   PatternOffset% = (i * 8) - 8  '  Each pattern is 8 bytes long.
   pat%(0) = PEEKW(StartPatternList& + 2 + PatternOffset%)
   pat%(1) = PEEKW(StartPatternList& + 4 + PatternOffset%)
   pat%(2) = PEEKW(StartPatternList& + 6 + PatternOffset%)
   pat%(3) = PEEKW(StartPatternList& + 8 + PatternOffset%)
   CALL FillRect(VARPTR(rect%(i*4-4)),VARPTR(pat%(0)))
NEXT i

' The following FOR loop puts the pattern number of each pattern
' in the corner of the rectangle containing the pattern.
XCount% = 1
YCount% = 1
FOR i = 1 TO NumOfPattern%
   IF XCount%= 10 THEN
      YCount% = YCount% + 1
      XCount% = 1
   END IF
   CALL MoveTo (XCount%*50-50+1,YCount%*50-3)
   XCount% = XCount% + 1
   PRINT i;
NEXT i
LOCATE 15,20
PRINT "Here is the list of all the system patterns";
LOCATE 16,20
PRINT "and their corresponding pattern Number";
WHILE Mouse(0) <> 1 :WEND
END
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB49888


BUG: Bad Values Returned in Compiled Decimal QuickBasic (49891)

Symptoms

The following program demonstrates a case where incorrect results are generated from an application compiled in Microsoft QuickBasic (d) Version 1.00 (decimal math version) for the Macintosh . The program works correctly in the interpreter but fails as a compiled application.

Microsoft has confirmed this to be a bug in Version 1.00 (d). We are researching this problem and will post new information here as it becomes available.

More information

The following program demonstrates the problem in a compiled application:
X# =  .06666666653334#
y# = -.066666666400014#
z# = 3.3333333327#

AA# = X# + Y# ' The result here is 1000 times too large. If the
PRINT AA#     ' correct or incorrect result is put into AA#
              ' directly, then the next error is avoided.
              ' The incorrect result is :
              '    AA# = .000000133326#
              ' The correct result is   :
              '    AA# = .000000000133326#

AB# = Z#/AA#  ' This generates an ERROR #6 (OverFlow) when
              ' compiled unless AA# is assigned a literal
PRINT AB#     ' result from AA# = X# + Y#
              ' ( AA# = .000000000133326# )

WHILE INKEY$ = ""
WEND
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB49891


Microsoft Can't Update Apple ResEdit for Macintosh Customers (50307)

Summary

Microsoft ships Version 1.1b3 (dated April 5, 1988) of ResEdit (Apple Computer, Inc., resource editor) with Microsoft QuickBasic 1.00 for the Apple Macintosh.

Microsoft is licensed to distribute only this version and is not licensed to distribute any new versions of ResEdit.

The latest version of ResEdit (as of October 1989) is Version 1.20. This version can be purchased from Apple Computer, Inc., for $30. It comes with 125 pages of documentation.

To obtain ResEdit, call Apple Programmers and Developers Association (Apda) at one of the following numbers:

In United States: Toll Free (800) 282-2732

or (408) 562-3910

In Canada: Toll Free (800) 637-0029

Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB50307


Example of Finding a File's Type in Macintosh QuickBasic (50468)

Summary

To find the file type of a Macintosh file, you can make a call to GetFileInfo, an MBLC routine built into Microsoft QuickBasic 1.00 for the Apple Macintosh system. GetFileInfo will tell you if a file is of type "Appl", "Text", etc.

More information

The GetFileInfo routine returns an array with information about a file. The 32nd through 35th bytes contain the filename. Each byte contains one character of the 4-byte name. The explanation of the contents of the entire array can be found on Page 116 of "Inside Macintosh" Volume II (by Apple Computer, Inc., published by Addison-Wesley, 1985). The GetFileInfo MBLC routine in QuickBasic calls the GetFileInfo routine built into the Macintosh ROM toolbox.

The following sample program uses the FILES$() function to let you choose a file of type "Appl" or "Text". It then prints out the file type.
DEFINT A-Z
DIM fileinfo(40)
  REM  Prompt user for the name of the file for which to get the type:
filename$ = FILES$(1,"ApplText")
  REM  Make call to GetFileInfo (an MBLC routine in QuickBasic):
GetFileInfo filename$,fileinfo(0)
  REM  Parse the Array to get the TYPE:
NameString$ = ""
FOR i = 16 TO 17
   NameString$ = NameString$ + CHR$(fileinfo(i) \ 256)
   NameString$ = NameString$ + CHR$(fileinfo(i) AND 255)
NEXT
  REM  Print the TYPE:
PRINT NameString$
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB50468


FIX: CopyFile Changes File Type to "Text" in Mac QuickBasic (50469)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    The CopyFile MBLC routine, which is built into QuickBasic, changes the file type of any file copied to type "Text" (instead of retaining the type of the copied file).

    Microsoft has confirmed this to be a bug in QuickBasic 1.00 for the Macintosh . This problem is corrected in QuickBasic version 1.00b.

    To work around the problem, you can use the NAME statement to reassign the type of the file after you copy it.

    More information

    The CopyFile MBLC routine is not documented in the QuickBasic manual, but it is documented in the Readme file on the release disk. For additional important information about using CopyFile, query on the following words:

    CopyFile and QuickBasic and Macintosh

    Example of Workaround

    The following SUBprogram copies a source file to a destination file. The SUBprogram finds out what type the source file is, copies the file, and then makes the destination file the same type as the source file.
    REM   The following Call to MyCopyFile will copy "File Browser"
REM   to "File Searcher", and "File Searcher" will be the same
REM   type as "File Browser".
DEFINT A-Z
Source$ = "File Browser"
Dest$ = "File Searcher"
CALL MyCopyFile(Source$,Dest$)

SUB MyCopyFile(SourceFile$,DestinationFile$) STATIC

  REM  Get the file type of SourceFile$ using the GetFileInfo routine.
  REM  More information about GetFileInfo can be found by querying
  REM  under "GetFileInfo and type" in the Microsoft Knowledge Base.

  DIM fileinfo(40)
  GetFileInfo SourceFile$,fileinfo(0)
  FILETYPE$ = ""
  FOR i = 16 TO 17
    FILETYPE$ = FILETYPE$ + CHR$(fileinfo(i) \ 256)
    FILETYPE$ = FILETYPE$ + CHR$(fileinfo(i) AND 255)
  NEXT i

  REM   Call CopyFile:

  CopyFile SourceFile$,DestinationFile$

  REM   Change the type back to the original:

  NAME DestinationFile$ AS DestinationFile$, FILETYPE$
END SUB
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB50469


Picture ON Does Not Capture Picture after WindOW Change (50806)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    The Picture ON/OFF statements cannot capture graphics sent to several different WindOWs. Picture ON only captures a graphics image in the WindOW that is active when the Picture ON statement is executed. If the WindOW being output to is changed, or another WindOW is created after the Picture ON statement, any graphics output to that other WindOW is not captured.

    More information

    The correct order of statements for capturing a Picture$ with Picture ON/OFF is as follows:

    1. Create the WindOW you want to use with the WindOW statement, or make an already existing WindOW active with the WindOW OUTPUT statement. Either one of these actions will set the currently active output WindOW. If the program is just using the default WindOW, this step is not necessary.
    2. Use Picture ON to begin recording graphics output to the WindOW you just made active.
    3. Normally, Picture ON issues a CALL to HidePen. This means that to watch the graphics as they are being drawn and recorded, you must invoke ShowPen immediately after the Picture ON statement.
    4. While the graphics are being drawn, do not make any other WindOW active by issuing a WindOW statement or WindOW OUTPUT statement. Any graphics output to a WindOW other than the one that was active when the Picture ON was activated will not be recorded.
    5. When the graphics are complete, use the Picture OFF statement to terminate recording of graphics.
    6. You now can invoke the Picture$ function to return a string containing the graphics information [ x$=Picture$ ]. You can redraw the stored picture with the Picture statement [ Picture,x$ ].

    Code Example

    The following code example demonstrates the correct steps described above:
    ScrW% = SYSTEM(5) ' Get the screen width and height.
ScrH% = SYSTEM(6)
' Create and set an active WindOW.
WindOW 2,"Recording Picture",(10,40)-(ScrW%-20,ScrH%-20),5
Picture ON    ' Start recording graphics.
ShowPen          ' View the graphics as they draw.

FOR W=9 TO 20.3 STEP .01
     a=60
     x=R*COS(W)
     y=R*SIN(W)
     dr=R-R*SIN(W-.05)
     dy=y-R*SIN(W-.05)
     dx=x-R*COS(W-.1)
     R=a
     PSET(300+x-x*SIN(W/2)*dx,200+y+y*COS(W/2)*dy)
NEXT W
scrn:
Picture OFF
x$=Picture$
WindOW CLOSE 2
' Output now goes to the default WindOW.
Picture(1,1)-(ScrW%,ScrH%),x$    ' Scales the size of output
LOCATE 10, 10
INPUT "Hit any key to end the program.", a$
END
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB50806


How to Make Text Gray with Penpat in Macintosh QuickBasic (50807)

Summary

The following article gives an example of how to print gray text in Macintosh QuickBasic and Basic. A gray pen pattern can be used as a bit mask to overlay solid text to make it gray.

Gray text is used in Macintosh programs to indicate that a certain choice no longer applies or has been made inactive. An example of this is when a menu is grayed to indicate that it is no longer an allowed choice, but the grayed text is still shown as a "place holder" to show what choice might be possible under other conditions.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh, Microsoft Basic Compiler 1.00 for the Apple Macintosh, and Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh.

More information

The key to creating gray text is to make a gray pen pattern that can be used as a bit mask to overlay solid text, as follows:

  1. Use an eight-by-eight (8 x 8) template or grid to create the gray pattern. Each slot in the grid represents one of the pixels in a normal character. Setting every other pixel makes a gray pattern. In the following grid, a 1 (one) represents a black pixel and a 0 (zero) represents a white pixel. Start with 0, since starting with 1 creates a gray pattern mask different than that used by the Macintosh System.
          Pattern   Translates to    Hex Byte Equivalent    2-Byte Value
      -------   -------------    -------------------    ------------

      01010101    --------->     &H55    -----\
      10101010    --------->     &HAA    -----/ ----->  &H55AA
      01010101    --------->     &H55    -----\
      10101010    --------->     &HAA    -----/ ----->  &H55AA
      01010101    --------->     &H55    -----\
      10101010    --------->     &HAA    -----/ ----->  &H55AA
      01010101    --------->     &H55    -----\
      10101010    --------->     &HAA    -----/ ----->  &H55AA
  2. Convert the binary codes in the patterns into hexadecimal codes.
  3. Group the codes into pairs to form four-digit hexadecimal numbers. An integer in Basic can hold exactly a four-digit hexadecimal number. The Penpat ROM routine requires exactly four integers, as created above.
The steps above are described in detail on Page 390 of the "Microsoft QuickBasic for the Apple Macintosh Systems: Basic Language Reference" manual, Appendix D, Section D.3.5, "Changing the Pen Pattern."

Three other steps are required to correctly create grayed text:

  1. A TextFace other than 2 must be used. Each of the other TextFace choices work well with gray text, but TextFace 2, which is italicized, does not created readable gray text. Bold text works best because it has more black pixels, which allows for some pixels to be turned to white creating a gray appearance but leaving the character readable.
  2. A PenMode of 11 must be used. This causes the PEN to paint in BIC or "Black is Changed" mode.
  3. TextFont 0, which is the default system font, should be used.
All of the above steps will create gray text. However, the text will not appear exactly as the gray text in the menu items created by the Macintosh Menu Manager. If this effect is desired, you should use TextFace 64. TextFace 64 creates "extended" characters, which causes more space between characters. The example below combines all of these methods to create gray text that should appear just as it does in grayed menu items.

Code Example

' Invoke Chicago font, the font used by Macintosh System menus:
TextFont  0
' Invoke the wider-spaced Textface used in the System menus:
TextFace  64
PRINT "This Should be gray   "; ' "S" appears as in System menu items
' Print the apple, check, diamond, and Command key symbols:
PRINT CHR$(17);CHR$(18);CHR$(19);CHR$(20)
PRINT  "This is NOT gray"
SetArray pat%(0), &H55AA, &H55AA, &H55AA, &H55AA
Penpat VARPTR(pat%(0))
setarray r%(0), 0, 0, 16, 250
PenMode 11 ' Sets the penmode to BIC (Black Is Changed)
' Paint over the previously printed text to make it gray.
PaintRect VARPTR(r%(0))
END
[Note: Basic interpreter Versions 2.00 and 2.10 don't support SetArray, so you need to assign pat%(0) through pat%(3) individually to &H55AA in these older versions.]
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB50807


How Basic's Graphics GET Statement Stores Graphics in an Array (51412)

The information in this article applies to:
  • Microsoft GW-Basic 3.2, when used with:
  • the operating system: Ms-Dos
  • Microsoft GW-Basic 3.22, when used with:
  • the operating system: Ms-Dos
  • Microsoft GW-Basic 3.23, when used with:
  • the operating system: Ms-Dos
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft QuickBasic 1.0, when used with:
  • the operating system: Ms-Dos
  • Microsoft QuickBasic 1.01, when used with:
  • the operating system: Ms-Dos
  • Microsoft QuickBasic 1.02, when used with:
  • the operating system: Ms-Dos
  • Microsoft QuickBasic 2.0, when used with:
  • the operating system: Ms-Dos
  • Microsoft QuickBasic 2.01, when used with:
  • the operating system: Ms-Dos
  • Microsoft QuickBasic 3.0, when used with:
  • the operating system: Ms-Dos
  • Microsoft QuickBasic 4.0, when used with:
  • the operating system: Ms-Dos
  • Microsoft QuickBasic 4.0b, when used with:
  • the operating system: Ms-Dos
  • Microsoft QuickBasic 4.5, when used with:
  • the operating system: Ms-Dos
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Compiler 1.0, when used with:
  • the operating system: Mac OS (all versions)
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    This article describes the format with which the graphics GET statement stores graphics in an array.

    This article applies to Microsoft GW-Basic Interpreter Versions 3.20, 3.22, 3.23 for Ms-Dos, Microsoft Basic Compiler 6.00 and 6.00b for Ms-Dos and MS OS/2, Microsoft QuickBasic 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.0B and 4.50 for Ms-Dos, Microsoft QuickBasic 1.00 for the Apple Macintosh, Microsoft Basic Compiler 1.00 for the Apple Macintosh, and Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh.

    This internal product information is provided as is, and may be subject to change or nondisclosure in future versions of Basic.

    More information

    The graphics GET statement transfers a screen image into a specified array. The first 4 bytes in the array are two integers which specify how wide and long the stored image is in pixels, while the rest of the data stored in the array is a binary representation of the stored screen image, as shown in the following diagram:
       +------------+------------+
   | image width, in pixels  |  <-- 2-byte integer number
   +------------+------------+
   | image length, in pixels |  <-- 2-byte integer number
   +--------+--------+--------+--------+--------+--------+
   |        |        |   < binary image data >  |        |
   +--------+--------+--------+--------+--------+--------+
    byte #5   byte #6  byte #7
    The binary image data depends on the screen mode of the graphic image and is stored linearly in memory by pixel rows and columns. The GET statement scans the screen image by row from left to right and stores the bit representation of each pixel. Each row of the stored data will be padded out to an even byte boundary by Null bytes (ASCII 0). The following is an example.

    Take a square box drawn on the screen and stored with the following program:

          Screen 2   ' Delete this statement for Macintosh Basics
      DIM box%(1 to 5)
      LINE (1, 1)-(10, 3), ,B
      GET (1, 1)-(10, 3), box%
    The first 4 bytes of box% will be as follows:
          box%(1) = 10  ' The box is 10 pixels wide
      box%(2) = 3   ' The box is 3 pixels long
    The binary representation of the remaining bytes in the box% array is as follows:

    box%(3) = 11111111 11000000 <- Note padding of each row of bits
    box%(4) = 10000000 01000000 <- Also note how the 1's form a box.
    box%(5) = 11111111 11000000

    How GET Stores Color on an IBM PC or Compatible

    On an IBM PC or compatible, the way the graphics GET statement stores color information depends upon the characteristics of the display mode. For screen modes with a single color plane (Screens 1, 2, 3, 11, and 13), each pixel is represented by the number of bits per pixel per plane for the particular display mode. The following is an example.

    If the square box given above were drawn in Screen mode 1 (2 bits per pixel per plane) with the following program,

          Screen 1
      DIM box%(1 to 7)
      LINE (1, 1)-(10, 3), ,B
      GET (1, 1)-(10, 3), box%
    then the binary representation of the image data bytes (after the 4-byte width and length header) would be as follows:

    11111111 11111111 11110000
    11000000 00000000 00110000 <- Notice 2 bits per pixel
    11111111 11111111 11110000

    Since no color was specified, the default color (white) was used (thus all of the color bits were turned on).

    For Screen modes with multiple color pages (Screens 7, 8, 9, 10, and 12), GET stores each display page separately by screen row. GET stores the binary information for one row of the graphics on the first color page and then the same row of graphics on the next color page, padding each row of color page information to an even byte boundary. The following is an example:

    If the same square box were drawn in Screen mode 12 (four color planes) in red with the following program,

          Screen 12
      COLOR 4   ' select red color
      DIM box%(1 to 14)
      LINE (1, 1)-(10, 3), ,B
      GET (1, 1)-(10, 3), box%
    then the binary representation of the image data bytes (again after the 4-byte header) would be as follows:

    00000000 00000000 <- blue plane
    00000000 00000000 <- green plane
    11111111 11000000 <- red plane (note padding to byte boundary)
    00000000 00000000 <- intensity plane - first row finished

    00000000 00000000 <- blue
    00000000 00000000 <- green
    10000000 01000000 <- red
    00000000 00000000 < - intensity - second row

    00000000 00000000
    00000000 00000000
    11111111 11000000
    00000000 00000000 <- last row

    GET Doesn't Preserve Color in QuickBasic for the Macintosh

    The graphics GET statement in Microsoft QuickBasic 1.00 for the Macintosh does not preserve the colors of graphics in its array argument, and a subsequent graphics PUT using that array will draw in monochrome, using only the current foreground and background colors.

    The following list shows how the GET statement translates pixel colors on the screen and stores them in the array:
    1. White (or current background color) <= yellow, magenta, cyan, white
    2. Black (or current foreground color) <= red, green, blue, black
    The GET statement captures screen information as a bitmap only. Only the on or off status of each pixel -- not the color information -- is stored in the array.

    The ForeColor and BackColor MBLC routines built into QuickBasic let you change the color used by subsequent graphics statements. Invoking ForeColor and BackColor will cause a subsequent graphics PUT to use that new foreground and background for all pixels drawn.

    Note that the earlier products, Microsoft Basic Compiler 1.00 for the Apple Macintosh and Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh, do not support ForeColor or BackColor, or any color capabilities.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB51412


ResEdit Can't Change Some System Fonts; Macintosh QuickBasic (51593)

Summary

Apple's ResEdit Version 1.1B3 that is supplied with Microsoft QuickBasic 1.00 for the Apple Macintosh does not allow you to change some installed system fonts. Which fonts you can change depends on the machine on which ResEdit is being used. This is a problem with ResEdit tool itself.

This information applies only if you wish to change the appearance of letters in a font.

More information

Version 1.1B3 is not the most current version of ResEdit. Apple ResEdit Version 1.20 (the latest as of November 1989) does not correct the problem with editing certain fonts. However, future versions of ResEdit may correct this problem.

ResEdit is not a Microsoft product but is a product of Apple Computer Corporation. To order an update for ResEdit, contact Apple Computer at (800) 282-2732.

This problem with editing certain fonts occurs on all versions of System and Finder up to releases of System 6.0.3 and Finder 6.1 (which are the latest as of November 1989).

The following is a list of fonts that cannot be changed under ResEdit, and the machines that the problem occurs on:
   Macintosh II and SE/30     Macintosh Plus
   ----------------------     --------------
   Chicago 12                 Chicago 12
   Geneva   9
   Geneva  12
   Monaco   9
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB51593


How to PEEK Status of Command, Shift, Caps LOCK, OPTION Keys (51658)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00

    • Summary

    This article provides a sample program where the PEEK function returns the up (inactive) or down (active) status of the Command, Shift, Caps LOCK, and OPTION keys for Apple Macintosh computers. You can poll the PEEK function in a loop to detect the changing status of these keys.

    More information

    PEEKing address 378, found in low Macintosh memory, returns a 128 if the Command key is currently down (active), or 0 (zero) if the Command key is currently up (not active).

    PEEKing address 379 returns 1 if Shift is down, 2 if Caps LOCK is down, or 4 if OPTION is down. The values are added together if more than one key is down at once. A key that is up (not active) adds nothing (zero). For example, if the Shift (value 1) and Caps LOCK (value 2) keys are both down, and the OPTION key is up (value 0), then PEEK(379) returns a 3 (since 1, 2, and 0 are added together).

    Code Example

    LOCATE 1,1 : PRINT "Command key is";
LOCATE 2,1 : PRINT "Shift key is";
LOCATE 3,1 : PRINT "Caps LOCK key is";
LOCATE 4,1 : PRINT "OPTION key is";
LOCATE 6,1 : PRINT "PEEK(378)=";
LOCATE 6,1 : PRINT "PEEK(379)=";
' Loop until user presses any key other than the above four:
WHILE INKEY$ = ""

   p1 = PEEK(378)
   p2 = PEEK(379)
   LOCATE 1,15   ' PRINT the setting of the Command key:
   IF p1=128 THEN PRINT "down"; ELSE PRINT "up";
   LOCATE 2,15   ' PRINT the setting of the Shift key:
   IF p2=1 OR p2=3 OR p2=5 OR p2=7 THEN PRINT "down"; ELSE PRINT 'up";
   LOCATE 3,15   ' PRINT the setting of the Caps LOCK key:
   IF p2=2 OR p2=3 OR p2=6 OR p2=7 THEN PRINT "down"; ELSE PRINT 'up";
   LOCATE 4,15   ' PRINT the setting of the OPTION key:
   IF p2=4 OR p2=5 OR p2=6 OR p2=7 THEN PRINT "down"; ELSE PRINT 'up";
   LOCATE 6,10 : PRINT p1;   ' Prints value of PEEK(378)
   LOCATE 7,10 : PRINT p2;   ' Prints value of PEEK(379)
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB51658


How to List All STR# Resources as GetIndString & GetString Do (51731)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article describes how to access all the strings in the STR# resource in the System file. The sample program displays all the strings in a given ID number to the screen. The program uses GetRes (an MBLC routine built into QuickBasic) and PEEK functions.

    The program below gives you an alternative to executing the GetString and GetIndString toolbox calls, which are listed in Apple's "Inside Macintosh" Volume I (published by Addison-Wesley). You cannot directly call GetString and GetIndString from QuickBasic, because QuickBasic's ToolBox statement can't call routines that are not in ROM. ("Inside Macintosh" indicates which routines are or aren't in ROM.) You would normally need to call C or another language from QuickBasic to invoke GetString and GetIndString.

    More information

    The example below gets the resource handle for the STR# resource from the System file. The handle is used to point to where the strings are loaded into memory. Instead of using the System file, you could open a file's resource fork to obtain access to a file's STR# resource(s).

    PEEKing at the first word at the handle's location obtains the number of strings located in the STR# ID opened. PEEKing at two bytes after the handle obtains the length of the first string. The string will be stored right after its length. Subsequent strings are stored in the same manner, following the first string.

    Sample Code

    ref% = 0    ' Zero can be used as the System's file-reference number.
            ' No OpenResFile statement is necessary, since the
            ' resource fork of the System file is always open.
id% = IDNumber ' The ID number associated with the STR# you wish to
               ' look at.
H& = 0
'OpenResFile "File Name",ref%  ' You can open a file resource instead
                               ' of using the System's.
GetRes ref%,"STR#",id%,H&      ' Get handle to the resource STR#.
LockRes H&                     ' Lock the Handle to STR#, so another
                               ' application cannot use it.
PRINT "This is the list of the strings in the resource STR#"
PRINT  "---------------------------------------------------"
PRINT
StartSTR&=PEEKL(H&)            ' Get the starting address of where
                               ' resource STR# is located in memory.
NumStrings% =  PEEKW( StartSTR& ) ' Get the number of strings
                                  ' stored in the STR# list.
OffSet% =0
TheString$= ""
IF NumStrings% > 1 THEN        ' Get each string and print it
  FOR i% = 1 TO NumStrings%    ' on the screen.
     TheString$  =""
     Length% = PEEK( StartSTR& +2+OffSet%)  ' The length of the string
     FOR j% = 1 TO PEEK( StartSTR& + 2 + OffSet%)
      TheString$ = TheString$ + CHR$(PEEK(StartSTR& +2+ OffSet%+ j% ))
     NEXT j%
     OffSet%=OffSet% + Length% + 1
     PRINT TheString$
  NEXT i%
END IF
PRINT
PRINT "---------------------------"
PRINT "Click on the Mouse to Continue"
WHILE Mouse(0) <> 1 : WEND
ReleaseRes H&                  ' Release the STR# handle.
'CloseResFile ref%   ' Only use this if you used OpenResFile above.
END
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB51731


Can't Increase Stack in Interpreter (Macintosh QuickBasic) (52048)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    In the interpreter environment in Microsoft QuickBasic for Macintosh, the stack is set to its maximum by default. In the interpreter, the CLEAR statement can only make the stack smaller. The only reason you would want to set the stack smaller in the interpreter would be to make more heap space.

    Note that this article does not apply to compiled programs in QuickBasic, just to interpreted programs. The stack is handled completely differently in compiled programs and can be larger than 32K, as explained in a separate article that can be found by querying on the following words:

    Macintosh and QuickBasic and compiled and memory and map and correction

    More information

    The stack in the QuickBasic interpreter environment is also used by the Macintosh System, thus making the stack difficult to predict or control from your program. Normally, you should never need to change the stack in the interpreter -- the stack is handled automatically.

    If your goal is to increase heap space (with the CLEAR statement) in the interpreter, it is better to decrease the data space and leave the stack space alone. This is because if the stack ever runs into the heap at run time and you decreased the stack size with CLEAR, you may get a System Error ID=28 and must reboot. If you instead leave the stack size at its default and the stack runs into the heap, then the interpreter gracefully gives an "Out of Memory", Error 7 (which can optionally be trapped with the ON ERROR GOTO statement), and no reboot is needed.

    The CLEAR statement can change the stack size as follows:
       CLEAR ,datasegmentsize,stacksize
    or
       CLEAR ,,stacksize
    The stacksize parameter of the CLEAR statement must be from 1K to 32K in the interpreter. Attempting to use a size larger than 32K gives an "Overflow" error for the CLEAR. In the interpreter, the default stack size is about 40K (but may vary on different Macintosh System versions) and cannot be made larger.

    If you CLEAR the stack size once in an interpreted program, you cannot CLEAR the stack larger, only smaller. (In a compiled program, you can define the stack larger or smaller than the previous CLEAR; however, Microsoft advises using the CLEAR statement only once at the beginning of a compiled or interpreted program.)

    The FRE(-2) function returns the number of bytes never used by the stack since the program started. FRE(-2) is not very useful, except when FRE(-2) approaches zero, which means that stack space almost ran out at some previous point in the program. The values returned by FRE(-2) always decrease (or stay the same) during the course of a program and never increase.

    According to a test program using the default stack, the interpreter can perform 2748 GOSUB statements without RETURNing, after which you receive "Out of Memory" (Error 7).

    If you CLEAR,,32760 then you can perform about 2039 GOSUBs without RETURN, after which you get System Error ID=28 (Stack Ran into Heap). If you CLEAR,,8000 then you can perform only about 492 GOSUBs without RETURN, after which you get System Error ID=28.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB52048


Correction to LINE Statement Example in Macintosh QuickBasic (52098)

Summary

The program example for the LINE statement, on Page 179 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" for QuickBasic 1.00, contains a typographical error on the second line of the program, which reads as follows:
   mx=WindOW(2): my=WindOW(3): cx=mx2: cy=my2
It should be changed to read as follows:
   mx=WindOW(2): my=WindOW(3): cx=mx/2: cy=my/2
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB52098


Transferring Files Between Macintosh and Ms-Dos Computers (57345)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic for Ms-Dos 4.00
  • Microsoft QuickBasic for Ms-Dos 4.0B
  • Microsoft QuickBasic for Ms-Dos 4.50
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00

    • Summary

    There are several methods that can be used to transfer text files from Ms-Dos-based computers to Macintosh computers. Binary data files can sometimes be transferred, depending on the format of the information they contain. It is useless to transfer binary executable program files, as the machine code of Ms-Dos computers (based on the Intel chip set) and the Macintosh computers (based on the Motorola chip set) is very different.

    This information applies to Microsoft QuickBasic for the Macintosh Version 1.00, to Microsoft QuickBasic 4.00, 4.0B, and 4.50 for Ms-Dos, to Microsoft Basic Compiler 6.00 and 6.0B for Ms-Dos and MS OS/2, and to Microsoft Basic PDS 7.00 for Ms-Dos and MS OS/2.

    More information

    The following are several methods for transferring files between the Macintosh and Ms-Dos-based computers:

    1. Newer Macintoshes (current versions of the SE and all models introduced after the IIx, including the Macintosh IIci, IIcx, and the Macintosh portable) include the super drive. This drive is able to read from and write to Ms-Dos-formatted disks with the addition of a special Init.

      A company called Dayna Communications produces an Init called DOS Mounter that allows super-drive-equipped computers to read from and write to Ms-Dos formatted disks. Dayna Communications can be reached at (801) 531-0600.
    2. Files can also be transferred between Ms-Dos machines and Macintoshes by hooking them together through serial ports and using communication programs to transfer the information.

      A special null-modem cable that is specially designed to connect Macintoshes and Ms-Dos-based computers must be used.
    3. Modems can be attached to both computers, and the modems can be hooked together to transfer data. This requires using a communications program on both machines and having a modem connected to both the Macintosh and the Ms-Dos-based machine.
    4. The Tops Network can be used to hook IBM-compatible computers and Apple Macintosh computers together. Files can then be transferred over this network. A Tops FlashCard network card is required for the IBM-compatible computer, and both the IBM-compatible and Macintosh computers need special network driver software.

      The Tops Network is produced by Tops, a Sun Microsystems company. Tops can be reached at (408) 562-6000.
    5. A company called Micro Solutions produces an IBM compatible card and disk drive called MatchMaker that allows IBM-compatible computers to read from and write to Macintosh disks. Micro Solutions can be reached at the following address and phone number:

      Micro Solutions
      132 W Lincoln Hwy
      Dekalb, IL 60115
      (815) 756-3411

    Records in Macintosh text files are delimited just by carriage returns and not by carriage return plus linefeed sequences as on Ms-Dos computers. This can cause problems when transferring Ms-Dos text files to the Macintosh and vice versa. The following two sections discuss this issue.

    Transferring Text Files from IBM to Macintosh

    The interpreter environment in Microsoft QuickBasic for the Apple Macintosh automatically accepts source code files that have linefeeds at the end of lines.

    When reading a text data file that was created on an IBM into a Macintosh program, the extra linefeeds may appear as small square boxes. The square box is the Macintosh's representation for the linefeed. The linefeeds need to be stripped from the file for the Macintosh to work with the file.

    After transferring a file from IBM to Macintosh, you might want to change the file's type to Text if the transfer utility (program) does not do it for you. The following are two ways to change a file's type to Text:

    1. Run the following statements in QuickBasic:
            x$="filename"
      NAME x$ AS x$, "Text"
    2. Run ResEdit and select the file that you transferred. Press Command+I or choose Get Info from the File menu. In the box that pops up, change whatever is in the TYPE box to "Text" or the appropriate type. Close the box and choose to save the changes.
    If you also want to change the creator type to determine which application loads when you double-click the text file, query in this Knowledge Base for the following words:

    SetCreate and creator and double-click

    Transferring Text Files from Macintosh to IBM

    When text files created on the Macintosh are displayed on an Ms-Dos computer, they will have all the lines of data on one line. This is a result of the Macintosh not appending a linefeed to the end of each line of text. This problem can be solved by writing a program on the Macintosh that will append the required linefeed onto the end of each line of text (as shown in the Code Example below). The file can then be transferred over to the Ms-Dos computer.

    The following source code, written for Microsoft QuickBasic 1.00 for the Apple Macintosh, will read in a text file and output another text file that is in a suitable format (carriage return plus linefeed terminating each line) for reading on an Ms-Dos-based machine:
       INPUT "Source file name: "; SFILE$
   INPUT "Output file name: "; OFILE$
   OPEN SFILE$ FOR INPUT AS #1
   OPEN OFILE$ FOR OUTPUT AS #2
   WHILE NOT(EOF(1))
      LINE INPUT #1, A$
      PRINT #2, A$     ' Don't use a semicolon after A$.
      PRINT #2, CHR$(10);  ' Appends a linefeed character on each line.
   WEND
   CLOSE #1
   CLOSE #2
   PRINT "All Done!"
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB57345 kbAudDeveloper


Passing Long Integers Between QuickBasic and MPW Pascal 3.00 (57347)

Summary

The two programs shown below demonstrate how a Microsoft QuickBasic program can pass long integer numbers to and from Apple Macintosh Programmer's Workshop (MPW) Pascal version 3.00 pure code resources.

This information about interlanguage calling applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

When doing interlanguage calling with Microsoft QuickBasic, the other language can make calls to the Basic run time to get the address of passed arguments. This is accomplished with the GetNextLibArg statement.

GetNextLibArg returns a pointer to a variant record containing another pointer to each possible type of QuickBasic variable (single precision, double precision, integer, etc.). Usually, a double indirection of pointers is used to get the actual passed data.

Using double indirection of pointers with Apple MPW Pascal, however, does not return the correct value. This is a QuickBasic header file problem. The routine below demonstrates how an inline assembly-language routine can be used in place of the double indirection to work around the problem.

More information on interlanguage calling with Microsoft QuickBasic can be found in the "Microsoft QuickBasic for Apple Macintosh: Language Reference," starting on page 444.

Compile and link PrintLng.p from Apple MPW Pascal version 3.00 as follows:
   pascal -p PrintLng.p
   link -p -rt MBPC=999 PrintLng.p.o BasicLib.a.o -o PrintLng
Note: The file BasicLib.a.o comes with Microsoft QuickBasic for Apple Macintosh systems, on the Examples disk, in the User Libraries:MBPC Rsrcs:MPWP PCR Folder.

Once PrintLng is compiled and linked, use ResEdit to change parameters in PrintLng as follows:

  1. In ResEdit find the newly created file PrintLng, and click once on the name so that it is highlighted.
  2. While holding down the Command key, press the "I" key. This is the same as choosing Get Info from the File menu. Change the following in the dialog box that appears:

    1. Change the File field to "PrintLng".
    2. Change the Type field to "MBPC".
    3. Change the Creator field to "MSBB".
  3. Close the dialog box, and click Yes when asked if you want to save.
  4. Double-click on PrintLng to open it. There should be one resource of MBPC displayed; double-click on this also. Single-click the displayed MBPC and press Command+I. In the Get Info dialog box that is brought up, change the Name field to PrintLng.
PrintLng is now a pure code resource that can be used with the RetLng QuickBasic program.

Code Example

The following QuickBasic program is RetLng, which invokes an Apple MPW Pascal routine to return a series of long integer numbers:
   Library "PrintLng"

   A& = 0 : B& = 0
   CALL PrintDouble(A&, B&)
   PRINT A&; B&

   WHILE INKEY$ = "" : WEND
The following Apple MPW Pascal routine is PrintLng.p, which accepts a series of passed long integer numbers from a Microsoft QuickBasic program and returns a constant value in them:
{**************************************************************}
{* PrintLng.p (c) 1989 Microsoft Corporation                  *}
{**************************************************************}
{* Description: Example to show how to pass long integer      *}
{*              number from QuickBasic to MPW Pascal and back.*}
{**************************************************************}
{$R-}   { Turn off range checking}
Unit PrintVerRec;

{*======================== INCLUDE FILES======================*}
Uses
   {$U MemTypes.p }      MemTypes,
   {$U BasicLibMPWP.p }  BasicLib;

   procedure AssignLng (ptr: LibArgPtr; val: LongInt);
   inline
      $225f,  { movea.l (a7)+,a1                             }
      $2e19,  { move.l  (a1)+,d7   ;get Long value           }
      $205f,  { movea.l (a7)+,a0   ;get ptr to Int variable  }
      $20C7;  { move.l   d7, (a0)+ ;assign the Int value     }

Procedure Main;

{$S Main}
{*------------------------------------------------------------*
 * A routine to pass back to Basic long integer constants     *
 *    Called from Basic as:                                   *
 *    CALL PrintLng (< long integer argument list >)          *
 *------------------------------------------------------------*}
Procedure Main;
VAR
   tempflag,argtype: INT16;
   valptr:  LibArgPtr;
   templng: LongInt;

Begin
   argtype := GetNextLibArg(valptr,tempflag);

   WHILE (argtype <> _ARGSEND) DO
      Begin
         if (argtype = _LongARG) THEN
            Begin
               templng := 4321;
               AssignLng(valptr, BigRec(templng));
            END;
         argtype := GetNextLibArg(valptr,tempflag);
      END;

END; {* of Main *}
Running RetLng produces the following output:
   4321  4321
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB57347


Passing Single Precision Between QuickBasic and MPW Pascal (57348)

Summary

The two programs shown below demonstrate how a Microsoft QuickBasic program can pass single precision numbers to and from Apple MPW Pascal version 3.00 pure code resources.

This information about interlanguage calling applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

When doing interlanguage calling with Microsoft QuickBasic, the other language can make calls to the Basic run time to get the address of passed arguments. This is accomplished with the GetNextLibArg statement.

GetNextLibArg returns a pointer to a variant record containing another pointer to each possible type of QuickBasic variable (single precision, double precision, integer, etc.). Usually a double indirection of pointers is used to get the actual passed data.

Using double indirection of pointers with Apple MPW (Macintosh Programmer's Workshop) Pascal, however, does not return the correct value. This is a QuickBasic header file problem. The routine below demonstrates how an inline assembly-language routine can be used in place of the double indirection to work around the problem.

More information on interlanguage calling with Microsoft QuickBasic can be found in the "Microsoft QuickBasic for Apple Macintosh: Language Reference," starting on page 444.

Compile and link PrintSng.p from Apple MPW Pascal version 3.00 as follows:
   pascal -p PrintSng.p
   link -p -rt MBPC=999 PrintSng.p.o BasicLib.a.o -o PrintDbl
Note: The file BasicLib.a.o comes with Microsoft QuickBasic for the Apple Macintosh on the Examples disk in the User Libraries:MBPC Rsrcs:MPWP PCR Folder.

Once PrintSng is compiled and linked, ResEdit should be used to change parameters in PrintSng as follows:

  1. In ResEdit, find the newly created file PrintSng, and click once on the name so that it is highlighted.
  2. While holding down the Command key, press the "I" key. This is the same as choosing Get Info from the File menu. Change the following in the dialog box that appears:

    1. Change the File field to "PrintSng".
    2. Change the Type field to "MBPC".
    3. Change the Creator field to "MSBB".
  3. Close the dialog box, and click Yes when asked if you want to save.
  4. Double-click PrintSng to open it. There should be one resource of MBPC displayed; double-click this also. Single-click the displayed MBPC and press Command+I. In the Get Info dialog box that is brought up, change the Name field to PrintSng.
PrintSng is now a pure code resource that can be used with the RetSng QuickBasic program.

It should be noted that PrintSng uses the record structure BigRec to pass the single precision number to the assembly language subroutine. This is because MPW Pascal automatically converts single and double precision numbers to an extended 10 byte format when passing them. Using the record structure stops MPW Pascal from performing this conversion.

Code Example

The following QuickBasic program is RetSng, which invokes an Apple MPW Pascal routine to return a series of single precision numbers:
   Library "PrintSng"

   A! = 0 : B! = 0 : C! = 0
   CALL PrintDouble(A!, B!, C!)
   PRINT A!; B!; C!

   WHILE INKEY$ = "" : WEND
The following Apple MPW Pascal routine is PrintSng.p, which accepts a series of passed single precision numbers from a Microsoft QuickBasic program and returns a constant value in them:
{**************************************************************}
{* PrintSng.p (c) 1989 Microsoft Corporation                  *}
{**************************************************************}
{* Description: Example to show how to pass single precision  *}
{*              number from QuickBasic to MPW Pascal and back.*}
{**************************************************************}
{$R-}   { Turn off range checking}
Unit PrintVerRec;

{*======================== INCLUDE FILE=======================*}
Uses
   {$U MemTypes.p }      MemTypes,
   {$U BasicLibMPWP.p }  BasicLib;

TYPE
    BigRec = Record
       singnum: Single;
    END;

   procedure AssignSng (ptr: LibArgPtr; val: BigRec);
   inline
      $225f,  { movea.l (a7)+,a1                             }
      $2e19,  { move.l  (a1)+,d7   ;get Long value           }
      $205f,  { movea.l (a7)+,a0   ;get ptr to Int variable  }
      $20C7;  { move.l   d7, (a0)+ ;assign the Int value     }

Procedure Main;

{$S Main}
{*------------------------------------------------------------*
 * A routine to pass back to Basic single precision constants *
 *    Called from Basic as:                                   *
 *    CALL PrintSng (< single precision argument list >)      *
 *------------------------------------------------------------*}
Procedure Main;
VAR
   tempflag,argtype: INT16;
   valptr:  LibArgPtr;
   tempsng: Single;

Begin
   argtype := GetNextLibArg(valptr,tempflag);

   WHILE (argtype <> _ARGSEND) DO
      Begin
         if (argtype = _SINGARG) THEN
            Begin
               tempsng := 20.25;
               AssignSng(valptr, BigRec(tempsng));
            END;
         argtype := GetNextLibArg(valptr,tempflag);
      END;

END; {* of Main *}
Running RetSng produces the following output:
   20.25  20.25  20.25
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB57348


Passing Double Precision Data Between QuickBasic & MPW Pascal (57349)

Summary

The two programs shown below demonstrate how a Microsoft QuickBasic program can pass double precision numbers to and from Apple MPW Pascal version 3.00 pure code resources.

This information about interlanguage calling applies to Microsoft QuickBasic for the Apple Macintosh version 1.00.

More information

When doing interlanguage calling with Microsoft QuickBasic, the other language can make calls to the Basic run time to get the address of passed arguments. This is accomplished with the GetNextLibArg statement.

GetNextLibArg returns a pointer to a variant record containing another pointer to each possible type of QuickBasic variable (single precision, double precision, integer, etc.). Usually a double indirection of pointers is used to get the actual passed data.

Using double indirection of pointers with Apple MPW (Macintosh Programmer's Workshop) Pascal, however, does not return the correct value. This is a QuickBasic header file problem. The routine below demonstrates how an inline assembly-language routine can be used in place of the double indirection to work around the problem.

More information on interlanguage calling with Microsoft QuickBasic can be found in the "Microsoft QuickBasic for Apple Macintosh: Language Reference," starting on page 444.

Compile and link PrintDbl.p from Apple MPW Pascal version 3.00 as follows:
   pascal -p PrintDbl.p
   link -p -rt MBPC=999 PrintDbl.p.o BasicLib.a.o -o PrintDbl
Note: The file BasicLib.a.o comes with Microsoft QuickBasic for the Apple Macintosh on the Examples disk in the User Libraries:MBPC Rsrcs:MPWP PCR Folder.

Once PrintDbl is compiled and linked, ResEdit should be used to change parameters in PrintDbl as follows:

  1. In ResEdit, find the newly created file PrintDbl and click once on the name so that it is highlighted.
  2. While holding down the Command key, press the "I" key. This is the same as choosing Get Info from the File menu. Change the following in the dialog box that appears:

    1. Change the File field to "PrintDbl".
    2. Change the Type field to "MBPC".
    3. Change the Creator field to "MSBB".
  3. Close the dialog box and click Yes when asked if you want to save.
  4. Double-click PrintDbl to open it. There should be one resource of MBPC displayed; double-click this also. Single-click the displayed MBPC and press Command+I. In the Get Info dialog box that is brought up, change the Name field to PrintDbl.
PrintDbl is now a pure code resource that can be used with the RetDbl QuickBasic program.

It should be noted that PrintDbl uses the record structure BigRec to pass the double precision number to the assembly language subroutine. This is because MPW Pascal automatically converts single and double precision numbers to an extended 10 byte format when passing them. Using the record structure stops MPW Pascal from performing this conversion.

Code Example

The following QuickBasic program is RetDbl, which invokes an Apple MPW Pascal routine to return series of double precision numbers:
   Library "PrintDbl"

   A# = 0 : B# = 0 : C# = 0
   CALL PrintDouble(A#, B#, C#)
   PRINT A#; B#; C#

   WHILE INKEY$ = "" : WEND
The following Apple MPW Pascal routine is PrintDbl.p, which accepts a series of passed double precision numbers from a Microsoft QuickBasic program and returns a constant value in them:
{**************************************************************}
{* PrintDbl.p (c) 1989 Microsoft Corporation                  *}
{**************************************************************}
{* Description: Example to show how to pass double precision  *}
{*              number from QuickBasic to MPW Pascal and back.*}
{**************************************************************}
{$R-}   { Turn off range checking}
Unit PrintVerRec;

{*======================== INCLUDE FILE=======================*}
Uses
   {$U MemTypes.p }      MemTypes,
   {$U BasicLibMPWP.p }  BasicLib;

TYPE
    BigRec = Record
       singnum: Double;
    END;

   procedure AssignDbl (ptr: LibArgPtr; val: BigRec);
   inline
      $225f,  { movea.l (a7)+,a1                             }
      $2e19,  { move.l  (a1)+,d7   ;get Long value           }
      $2c19,  { move.l  (a1)+,d6   ; get second part         }
      $205f,  { movea.l (a7)+,a0   ;get ptr to Int variable  }
      $20C7,  { move.l   d7, (a0)+ ;assign the Int value     }
      $20C6;  { move.l   d6, (a0)+ ;assign the Int value     }

Procedure Main;

{$S Main}
{*------------------------------------------------------------*
 * A routine to pass back to Basic double precision constants *
 *    Called from Basic as:                                   *
 *    CALL PrintDbl (< double precision argument list >)      *
 *------------------------------------------------------------*}
Procedure Main;
VAR
   tempflag,argtype: INT16;
   valptr:  LibArgPtr;
   tempdbl: Double;

Begin
   argtype := GetNextLibArg(valptr,tempflag);

   WHILE (argtype <> _ARGSEND) DO
      Begin
         if (argtype = _DBLEARG) THEN
            Begin
               tempdbl := 20.25;
               AssignDbl(valptr, BigRec(tempdbl));
            END;
         argtype := GetNextLibArg(valptr,tempflag);
      END;

END; {* of Main *}
Running RetDbl produces the following output:
   20.25  20.25  20.25
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB57349


Passing Integers Between QuickBasic and MPW Pascal 3.00 (57350)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The two programs shown below demonstrate how a Microsoft QuickBasic program can pass integers to and from Apple MPW Pascal version 3.00 pure code resources.

    This information about interlanguage calling applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

    More information

    When doing interlanguage calling with Microsoft QuickBasic, the other language can make calls to the Basic run time to get the address of passed arguments. This is accomplished with the GetNextLibArg statement.

    GetNextLibArg returns a pointer to a variant record containing another pointer to each possible type of QuickBasic variable (single precision, double precision, integer, etc.). Usually a double indirection of pointers is used to get the actual passed data.

    Using double indirection of pointers with Apple MPW (Macintosh Programmer's Workshop) Pascal, however, does not return the correct value. This is a QuickBasic header file problem. The routine below demonstrates how an inline assembly-language routine can be used in place of the double indirection to work around the problem.

    More information on interlanguage calling with Microsoft QuickBasic can be found in the "Microsoft QuickBasic for Apple Macintosh: Language Reference," starting on page 444.

    Compile and link SumIntArgs.p from Apple MPW Pascal version 3.00 as follows:

    pascal -p SumIntArgs.p
    link -p -rt MBPC=999 SumIntArgs.p.o BasicLib.a.o -o SumIntArgs

    Note: The file BasicLib.a.o comes with Microsoft QuickBasic for the Apple Macintosh on the Examples disk in the User Libraries:MBPC Rsrcs:MPWP PCR Folder.

    Once SumIntArgs is compiled and linked, ResEdit should be used to change parameters in SumIntArgs as follows:

    1. In ResEdit, find the newly created file SumIntArgs and click once on the name so that it is highlighted.
    2. While holding down the Command key, press the "I" key. This is the same as choosing Get Info from the File menu. Change the following in the dialog box that appears:

      1. Change the File field to "SumIntArgs".
      2. Change the Type field to "MBPC".
      3. Change the Creator field to "MSBB".
    3. Close the dialog box and click Yes when asked if you want to save.
    4. Double-click SumIntArgs to open it. There should be one resource of MBPC displayed; double-click this also. Single-click the displayed MBPC and press Command+I. In the Get Info dialog box that is brought up, change the Name field to SumIntArgs.
    SumIntArgs is now a pure code resource that can be used with the SumInt QuickBasic program.

    Code Example

    The following QuickBasic program is SumInt, which invokes an Apple MPW Pascal routine to sum a series of passed integers:
       DEFINT a-z
   Library "SumIntArgs"

   a = 0     ' Initialize passed values
   b = 2
   c = 4
   d = 8
   CALL PrintIntArgs(a, b, c, d)        ' CALL Pascal routine
   PRINT "Sum of: "  b;" ";c;" and ";d  ' Display returned
                                        ' values
   PRINT "Is: "a
   WHILE INKEY$ = "" : WEND             ' Wait for keypress
    The following Apple MPW Pascal routine is SumIntArgs.p, which accepts a series of passed integers from a Microsoft QuickBasic program and returns the sum of the integers:
    {**************************************************************}
{ * IntSum.p (c) 1989 Microsoft Corporation                   *}
{**************************************************************}
{ * Description:  Example to show how to pass integers from   *}
{ *               QuickBasic to MPW Pascal and back.          *}
{**************************************************************}
{$R-}     { Turn off range checking}
unit IntSum;

interface

{*======================== INCLUDE FILES
======================*}
   uses
   {$U MemTypes.p }
      MemTypes,
   {$U BasicLibMPWP.p }
   {$U BasicLibMPWP.p }
      BasicLib;

   procedure AssignInt (ptr: LibArgPtr; val: INT16);
   inline
      $3e1f,   { move.w  (a7)+,d7  ;get int value           }
      $205f,   { movea.l (a7)+,a0  ;get ptr to Int variable }
      $3087;   { move.w   d7, (a0) ;assign the Int value    }

   procedure Main;

implementation

{$S Main}

{--------------------------------------------------------------}
{  A routine to find the sum of the argument list              }
{    Called from Basic as:                                     }
{    CALL IntSum (Sum, < Integer argument list >)              }
{--------------------------------------------------------------}
   procedure Main;
      var
          Sum, tempflag, argtype, NextInt: INT16;
          valptr, pSum: LibArgPtr;

   begin
      Sum := 0;
      argtype := GetNextLibArg(pSum, tempflag);
      argtype := GetNextLibArg(valptr, tempflag);

      while (argtype <> _ARGSEND) do
         begin
            if (argtype <> _NullARG) then
               begin
                 if (argtype = _STRGARG) then
                     BasicError(13)
                  else
                     begin
                        NextInt := IntegerArg;
                        Sum := Sum + NextInt;
                     end;
               end;
            argtype := GetNextLibArg(valptr, tempflag);
         end;

      AssignInt(pSum, Sum);
  end; {* of Main *}
    Running SumInt produces the following output:
       Sum of:  2   4 and 8
   Is:  14
    Modification Type: Major
    Last Reviewed: 5/4/2001
    Keywords: KB57350


BUG: SerialPrinter Driver from Word 3.x Causes System Error (57372)

Symptoms

Selecting the "SerialPrinter" driver that comes with Microsoft Word Versions 3.00, 3.01, and 3.02 from the Chooser causes a System Bomb ID=01 when you try to run Microsoft QuickBasic 1.00 for the Macintosh .

Both the binary and decimal versions of QuickBasic demonstrate this problem.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic for the Macintosh Version 1.00. We are researching this problem and will post new information here when it becomes available.

Deselecting this driver from the Chooser and using a different printer driver works around this problem.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB57372


BUG: Cursor from INPUT Statement Incorrectly Displayed (57373)

Symptoms

The cursor incorrectly displays in a compiled program when using the INPUT statement in Microsoft QuickBasic 1.00 for the Apple Macintosh.

During INPUT, a blinking cursor is supposed to be displayed showing the place where the next character typed will appear. However, in a compiled application, the cursor does appear on the screen indicating where the next character be will placed, but it is not flashing. When you start typing your input, the cursor disappears completely. It then reappears (without flashing) and disappears as you type in more input. This sequence is repeated as you type.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic for the Macintosh Version 1.00. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB57373


BUG: Boolean Expression Using VAL Function Returns Wrong Value (57374)

Symptoms

A Boolean expression returns an incorrect value if the VAL function is part of the Boolean expression.

This problem applies only to the binary version of Microsoft QuickBasic 1.00 for the Macintosh .

To work around this problem, first evaluate the VAL function and assign this to a temporary variable. You can then use the temporary variable in the Boolean expression.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic for the Macintosh Version 1.00. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

More information

Code Example

The following code example demonstrates the problem:
   a$ = "3.33"
   variable! = 3.33
   PRINT (variable! = VAL(a$))

   OUTPUT --> 0
The following code is a possible workaround:
   a$ = "3.33"
   variable! = 3.33
   temp! = VAL(a$)
   PRINT (variable! = temp!)

   OUTPUT --> -1
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB57374


How to Create a Folder Using HFSDispatch in Mac QuickBasic (57375)

Summary

The program below demonstrates how to use the HFSDispatch library CALL to create a new folder from a QuickBasic application.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

DirCreate is not a trap macro (it doesn't have an individual trap address) and therefore expands to invoke the trap macro _HFSDispatch. The File Manager determines which routine to execute from the "routine selector," an integer that is placed in the D0 register.

Routine parameters that are passed to and from an application and the File Manager are contained in a parameter block, which is a data structure in the heap or stack. Parameters are passed in a block and a pointer to the block is passed instead. See Apple's "Inside Macintosh" (published by Addison-Wesley) for more information about the parameter block.

The code below POKEs the name of the folder into the Parameter Block and then passes the pointer of the parameter block to HFSDispatch.

Code Example

   DIM iopb%(60)
   dirname$ = "Test folder"
   dirname$ = CHR$(LEN(dirname$)) + dirname$
   POKEL VARPTR(iopb%(0)) + 18, SADD(dirname$)
   HFSDispatch 6,iopb%(0)    '6 is the Routine Selector value for
                             'creating a folder.
   END
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB57375


FIX: Passing PEEKL to a SUBprogram Returns "Type Mismatch" (57376)

Symptoms

Using the PEEKL function as an argument for a SUBprogram that accepts a Long data type produces a "Type mismatch" error when run from within the QuickBasic Interpreter.

Compiling the program and running the application does not produce the error.

To work around this problem, assign the result of the PEEKL function to a temporary variable and then pass this through the argument list of your SUBprogram.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic version 1.00 for the Macintosh . This problem is corrected in QuickBasic 1.00b.

More information

Code Example

The following code produces the error in the interpreter:
   CALL ArgPass(PEEKL(10000))     ' "TYPE Mismatch" error here
   END
   SUB ArgPass(longArg&) STATIC
      PRINT longArg&
   END SUB
The following is a workaround:
   temp& = PEEKL(10000)
   CALL ArgPass(temp&)
   END
   SUB ArgPass(longArg&) STATIC
      PRINT longArg&
   END SUB
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB57376


BUG: Error Generated Using a Boolean Expression in Array Index (57378)

Symptoms

The following code returns "Closing parenthesis expected" when compiling the program. The code works within the interpreter.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic Version 1.00 for the Macintosh and in Microsoft Basic Compiler Version 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

If you add the closing parenthesis, as the error message suggests, the interpreter will then flag a "Syntax error" error message.

You can remove the Boolean expression, i>7, from the statement and test this prior to assigning b$(i) a value.

The following line causes the "Closing parenthesis expected" error:
     b$(i(i>7)) = ""
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB57378


FIX: Shift+Click to Select Text in 100K File May Fail (57380)

Symptoms

Selecting a block of text near the end of a large file (approximately 100K or larger) sometimes does not work properly when using the following steps:

  1. Place the insertion point at some location that you want to mark as the beginning of the selection block.
  2. While holding down the Shift key, click the mouse at some other location to mark the end of the selection block.
Microsoft has confirmed this to be a bug in the Interpreter environment in Microsoft QuickBasic 1.00 for the Apple Macintosh. This problem is corrected in QuickBasic 1.00b.

More information

When the selection works incorrectly, the inverse video selection block either falls short or runs past where you Shift+clicked to mark the end of the selection.

This behavior does not occur if you try to select text near the beginning of a file. Paging down towards the end of the file and selecting text in the manner described above demonstrates the problem.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB57380


How to Use CopyBits ToolBox Call in Macintosh QuickBasic (57381)

Summary

Below is an example of how to use the CopyBits ToolBox routine described on Page 508 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual for Version 1.00.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

The CopyBits routine description on Pages 508 and 509 is incorrect and does not work properly. In the argument list for the ToolBox trap, the following array arguments should be long integer types with the following descriptions:
   srcBits%() ---->  srcBits&, a pointer to the source bitmap
   dstBits%() ---->  dstBits&, a pointer to the destination bitmap
   srcRect%() ---->  srcRect&, a pointer to the source rectangle
   dstRect%() ---->  dstRect&, a pointer to the destination rectangle
You must first invoke the trap call to get the grafPort record for the source and destination windows. The pointers to the bitmaps and rectangles are obtained from these grafPort records. CopyBits can then use this information to copy a bit image between the source and destination windows.

The program shown below uses the ToolBox trap call to get the handle to the grafPort record for the source (src) and destination (dst) grafPorts (windows). GetPort (trap number &HA874) gives the handle for the current, active window. The CopyBits ROM trap is then invoked with the ToolBox statement.

Code Example

GetPort% = &HA874 ' Trap number to grafPort record
CopyBits% = &HA8EC  ' Trap number for the CopyBits routine in ROM
toolbox "i"       ' initialize the toolbox
WindOW 1,"1",(310,40)-(570,250)
W1GrafPort& = 0   ' initialize variable
toolbox "PQ", GetPort%,W1GrafPort&
WindOW 2,"2",(40,40)-(300,250)
W2GrafPort& = 0
toolbox "PQ",GetPort%,W2GrafPort&
FOR i = 1 to 150
   LINE (10,i)-(150,i)
NEXT i
WindOW 1
DestBitMap& = W1GrafPort& + 2  ' get bitmap from grafPort record
                               ' of window 1
SrcBitMap& = W2GrafPort& + 2   ' get bitmap from grafPort Record
                               ' of window 2. This is where we'll
                               ' draw our graphics.
SrcRect& = W1GrafPort& + 16    ' get rectangle from grafPort record
                               ' of window 1
DestRect& = SrcRect&           ' Get rectangle for destination bitmap
hMaskRgn& = PEEKL(W2GrafPort& + 28)
TxMode% = 0                    ' Only copy the source grafPort
' The following two lines must be placed on one physical line:
toolbox "PQ",CopyBits%,(SrcBitMap&),(DestBitMap&),(SrcRect&),
      (DestRect&),(TxMode%),(hMaskRgn&) 'Append this to previous line
WindOW CLOSE 1
WindOW CLOSE 2
END
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB57381


Macintosh QuickBasic ToolBox Call to Trap Any Key Press (57441)

Summary

The following program shows how key presses can be trapped by polling values returned from a ToolBox call in a loop. This technique can be used to check if any key on the keyboard is currently being pressed, such as the function keys on the extended keyboard and the TAB key. You can also check if the Command key, OPTION key, or a Shift key is currently down.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

A ToolBox call can be made to the GetKeys function, which returns a sequence of bits that shows the current status of all the keys on the keyboard. The bit position for a particular key is determined by the key code for that key on the keyboard. The key codes are defined in Apple's "Inside Macintosh" Volume I (Addison-Wesley, 1985), Page I-251, and Apple's "Inside Macintosh" Volume V (Addison-Wesley, 1986), Page V-192. Some sample key codes are as follows:
   F1 = 122   F2 = 120   F3 = 99   PgDn = 121
The following program prompts you to enter the key code of the key whose status you wish to poll. The program will then sit in a loop displaying the status of that key until the ESC (escape) key is pressed. A status of 0 indicates that the key is not currently pressed, while a status of -1 indicates a key press:
DEFINT a-z
DIM ShareD KeyArray(8)
Toolbox "i"
PRINT "Your Choices are: ";
PRINT " F1 = 122   F2 = 120   F3 = 99  or Page Down = 121 "
INPUT "Key-Code to test for: "; KeyCode
CLS
PRINT "Press ESC to exit"
PRINT "Keyboard State (-1 = Key is currently pressed)"
PRINT "----------------------------------------------"
WHILE INKEY$ <> CHR$(27)   ' Check for escape key
   CALL TestKey(KeyCode, status)
   LOCATE 4, 1
   PRINT "Key "; KeyCode; " "; status
WEND

SUB TestKey(KeyCode, status) STATIC
   ' Subroutine to determine if a give key is currently being
   ' pressed.  Called with:
   '   KeyCode = key code as defined in Inside Macintosh
   '   status = Boolean returned value (-1 = key pressed,
   '                                     0 = not pressed)
   Toolbox "PQ", &HA976, KeyArray(0)  ' Call GetKeys toolbox routine
   ArrayLoc = KeyCode \ 8             ' Memory offset in array
   Bit = KeyCode - (ArrayLoc * 8)     ' Bit to check
   ArrayElement = PEEK(VARPTR(KeyArray(0)) + ArrayLoc)
   status = (ArrayElement AND 2^Bit) = 2^Bit
END SUB
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB57441


"Invalid Function Call" Using Edit FIELD <= 15 Pixels Wide (57514)

Summary

The Edit FIELD statement in QuickBasic 1.00 for the Apple Macintosh gives an "Invalid function call" error message if the width of the Edit FIELD is less than or equal to 15 pixels.

The height of the Edit FIELD can be any value equal to or greater than 0 (zero).

Code Example

WindOW 1,"Test",(50,79)-(402,230)
Edit FIELD 1,"",(40,20)-(55,20)
This example reproduces the error "Invalid function call" on the Edit FIELD statement. To make the program work without error, increase the 55 to 56 or decrease the 40 to 39. This increases the width of the Edit FIELD to 16. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB57514


BUG: Math w/ Long-Integer Constants Gives Bad Answer Compiled (57710)

Symptoms

If an expression contains an addition, subtraction, or multiplication of two long-integer constants so that the computed result exceeds 32,767 (the maximum short integer), the compiled application gives wrong numeric results. (Division works correctly.)

Microsoft has confirmed this to be a bug with applications compiled with Microsoft QuickBasic 1.00 for Macintosh systems. We are researching this problem and will post new information as it becomes available. This problem does not occur in the interpreter in QuickBasic 1.00.

To work around this problem in compiled programs, store one or more of the literals in a variable and use the variable in the computational expression.

More information

Note that long-integer constants (or literals) are numeric digits with an & (ampersand) suffix, and can range from -2147483648& to +2147483648&.

Code Example

The following code example illustrates the problem described above:
a& = 256& * 256&    ' Multiplication results greater than 32,767 fail.
PRINT a&
PRINT 65536& + 1&   ' Addition results greater than 32,767 fail.
PRINT 65536& - 1&   ' Subtraction results greater than 32,767 fail.
PRINT 131072& / 2&  '**** Division works correctly.
The results of the above program are as follows:
   Interpreted:   |  Compiled:
   ---------------+------------
   65536          |      0
   65537          |      1
   65535          |     -1
   65536          |  65536
[Note: The resultant value from the compiled application is actually just the low word of the completed computation. The compiled program is failing to keep the high word of the long-integer calculation. For example, if the resultant is equal to a power of 2 larger than 2^15, which means all bits in the low word are zero, then the compiled program reports zero.]

The following program works around the problem:
tmp& = 256&
a& = tmp& * 256&
PRINT a&
tmp& = 65536&
PRINT tmp& + 1&
PRINT tmp& - 1&
PRINT 131072& / 2&          '**** no change for division
The results for this altered program will match the correct interpreter results listed above.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB57710


How to Make Command+Key Alternatives to Menus in Basic (57778)

Summary

To make Command+key options serve as an alternative to selecting user-defined Menus with the mouse, you can use the CmdKEY statement (an MBLC Toolbox library routine). The CmdKEY statement also automatically places the special Command-key-character symbol in the menu item (see the code example below). This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

The CmdKEY Toolbox library statement is described on Page 477 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual.

Code Example

This example is based on the MenuKeys sample program, located in the Programs Folder in the MS ToolLib Folder on Disk 2 (the Basic ToolBox Disk) of Microsoft Basic Compiler 1.00 for the Apple Macintosh, and in the same location on the Basic ToolBox Disk for Microsoft Basic Interpreter Version 3.00 for the Apple Macintosh. These products are the precursors to QuickBasic, and the features are similar. To make the program below match MenuKeys and work in these earlier Basic products, just add the statement Library "Basic Toolbox:ToolLib" at the top.

When you run this program, press Command+B to select the Bold menu item, or press Command+I to select the Italic menu item.
TextMode 10
FOR n=1 TO 5
   Menu n,0,0,""
NEXT n
Menu 1,0,1,"File"
Menu 1,1,1,"Quit"
CmdKey 1,1,"Q"
Menu 2,0,1,"Print"
Menu 2,1,1,"Bold"
Menu 2,2,1,"Italic"
CmdKey 2,1,"B"         ' Press Command+B for bold.
CmdKey 2,2,"I"         ' Press Command+I for italic.
SetItemStyle 2,1,1
SetItemStyle 2,2,2
ON Menu GOSUB event
Menu ON
delay:
   GOTO delay
END
event:
   Menu
   men=Menu(0)
   item=Menu(1)
   IF men=1 THEN STOP
   TextFace item
   PRINT"This is the style you chose"
RETURN
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB57778


Modifying File and Edit Menus in Compiled QuickBasic Programs (57779)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article describes how to use an updated version of ResEdit to modify the spelling of items in the File and Edit (default) menus (while retaining their functionality) in compiled applications in QuickBasic. This procedure could be used for changing the menus to a foreign language. However, you cannot change the length of the names with this technique. This applies to the File menu and its Quit command and to the Edit menu and its Undo, Cut, Copy, Paste, and Clear commands.

    This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

    More information

    The ResEdit program (Version 1.1b3) shipped with QuickBasic cannot make the modifications shown below. You can use a later version of Apple's ResEdit, Version 1.3d1, which may be obtained from Macintosh user groups or from Apple.

    Note that the "Menu" resource in the QuickBasic editor contains the menus for the editor and doesn't contain the default menus for compiled applications. The default menus (File and Edit) for compiled applications are contained in the "MBRL" resource.

    When you compile with the Use Default Menu option (under the Options command on the Run menu) and you don't define your own menus with Menu statements in the program, a compiled program uses the default menus stored in the "MBRL" resource.

    You may alter the "MBRL" resource with ResEdit Version 1.3d1. If you compile a program with the Include the Runtime Code option (from the Options command on the Run menu), you can modify the "MBRL" resource in that specific application. An alternative is to modify the "MBRL" resource stored in QuickBasic (b) or QuickBasic (d) to force the change on all compiled applications.

    To change the default menu in a Macintosh QuickBasic application, do the following:
    1. Execute ResEdit Version 1.3d1 (newer than the one in QuickBasic).
    2. Move to the volume and folder containing the application.
    3. Double-click on the application.
    4. Double-click on "MBRL" (Microsoft Basic Run-Time Library).
    5. Double-click on "MBRL ID = 0".
    6. Choose Find ASCII from the Find menu.
    7. Type Edit and press Find Next.
    8. Modify the desired strings in the rightmost column keeping the length of each string the same (for example, change "Edit" to "Eooo", not to "Eoo" or "Eoooo").
    9. Close three windows.
    10. Answer "Yes" to "Do you want to save <appl>?"
    11. Quit ResEdit (choose Quit from File menu).
    The above method can also be used on QuickBasic (b) or (d) itself. By changing the "MBRL" resource in QuickBasic, all newly compiled programs will have the altered menu.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB57779


BUG: QuickBasic's AddStrings.C Incorrect for MPW C Vers 3.00 (58036)

Symptoms

The program AddStrings.C, supplied with Microsoft QuickBasic 1.00 for the Macintosh for interfacing with Macintosh Programmer's Workshop (MPW) C, does not work correctly when compiled with MPW C Version 3.00.

When called, AddStrings is supposed to concatenate two strings together and return the result in a third string. As supplied, however, AddStrings does not modify the third string. In the sample program TestPCR.MPWC, the third string is blank after the call (it remains unchanged).

Microsoft has confirmed this to be a bug in QuickBasic 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

More information

To correct AddStrings.C, two lines at the bottom of the routine must be switched. At the very bottom of AddStrings.C are the following three lines:
   resdesc = GetStringArg();
   AllocTempDesc(&tempdesc);
   AssignString(tempdesc,resdesc);
These lines should be changed to the following:
   AllocTempDesc(&tempdesc);
   resdesc = GetStringArg();
   AssignString(tempdesc,resdesc);
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB58036


BUG: Correction for Rtrim and Ltrim QuickBasic Utilities (58038)

Symptoms

The Ltrim and Rtrim routines, found in the Utility Subprograms file, don't handle all strings. The Rtrim routine does not correctly trim leading spaces, and Ltrim gives an "Illegal Function Call" when passed a blank string of spaces. Below are corrections to handle these cases.

The Utility Subprograms program is in the QB Demos folder on the Examples Disk provided with Microsoft QuickBasic 1.00 for the Macintosh .

Microsoft has confirmed this to be a bug in QuickBasic 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

More information

Both Rtrim and Ltrim access one extra character beyond the boundaries of the string. In addition, these routines are not equivalent to the Ms-Dos QuickBasic 4.00, 4.0B, and 4.50 LTRIM$ and RTRIM$ routines, which trim ANY character with an ASCII code equal to or less than 32, instead of just spaces (ASCII 32).

The following code example illustrates the problems with the existing Rtrim and Ltrim routines and shows the code changes needed to correct them:
CLS

R$ = "test   "
PRINT "Rtrim"
PRINT "|"; R$; "|", "length"; LEN(R$); " -> "
CALL Rtrim(R$)
PRINT "|"; R$; "|", "length"; LEN(R$)
PRINT

L$ = "    "
PRINT "Ltrim"
PRINT "|"; L$; "|", "length"; LEN(L$); " -> "
PRINT "Causes Illegal Function Call if following lines activated."
'CALL Ltrim(L$)                      'Causes Illegal Function Call
'PRINT "|"; L$; "|", "length "; LEN(L$)

'To correct Ltrim, comment out first WHILE and
'uncomment second WHILE.
SUB Ltrim (s$) STATIC
   IF s$ <> "" THEN
     i% = 0: a& = SADD(s$)

     ' comment out this line:
     WHILE PEEK(a& + i%) <= 32: i% = i% + 1: WEND

     ' uncomment this line to correct:
     'WHILE (PEEK(a& + i%) = 32) AND (i% < LEN(s$)): i% = i% + 1: WEND
     s$ = RIGHT$(s$, LEN(s$) - i%)     'Illegal Function Call here
   END IF
END SUB

'To correct Rtrim, comment out first WHILE line and line above it, and
'uncomment the second WHILE line and the preceding line.
SUB Rtrim (s$) STATIC
   IF s$ <> "" THEN

      ' comment out the following two lines:
      i% = LEN(s$) + 1: t% = 0: a& = SADD(s$)
      WHILE t% <= 32: i% = i% - 1: t% = PEEK(a& + i%): WEND

      ' uncomment the following two lines to correct:
      'i% = LEN(s$) - 1: t% = 0: a& = SADD(s$)
      'WHILE PEEK(a& + i%) = 32: i% = i% - 1: : WEND

      s$ = LEFT$(s$, i% + 1)
   END IF
END SUB
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB58038


How to Open Macintosh QuickBasic Data File with Shared Access (58177)

Summary

Below is an example of how to open a data file with "shared" access from Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

This program will not work on machines with 64K ROMs (pre-MacPlus).

Warning: Because this routine temporarily changes the operating system, incorrect use can cause the system to crash or other adverse effects to occur. You should not make any major alterations to the code and should be very careful in its use.

Code Example

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
'>> The following code demonstrates a technique for opening a
'>> file with shared access. It accomplishes this by patching
'>> the _OPEN OS routine to force the ioPermssn to Shared.
'>> Warning - This is not a trivial technique. If a Basic error
'>> occurs while the _OPEN trap is patched, the machine Must
'>> be rebooted. Therefore, you should keep the code between the
'>> patch & unpatch to a minimum.
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    DIM reg&(16),hpatch&, pPatch&, pOpen&
    GetTrapAddress%=&HA246 : SetTrapAddress%=&HA247
    ToolBox "i"
'=== Find out where the current _OPEN code is
    ToolBox "RQ",GetTrapAddress%,reg&(0),0,0,0
    pOpen&=reg&(0)
'==== Set up the patch
    NewHandle 12,hpatch&
    hLock hpatch& : pPatch&=PEEKL(hpatch&)
    PRINT HEX$(PEEKL(hpatch&))
    POKEW pPatch&,&H117C        'Move.B #4,1B(a0)
    POKEW pPatch&+2,&H4         'immediate data
    POKEW pPatch&+4,&H1B        'reg offset
    POKEW pPatch&+6,&H4EF9      'jmp    OldOpenCode
    POKEL pPatch&+8,pOpen&      'Abs.L for jmp

'>>>>>>>>>>>>>>>>>>>> Start of Critical Section <<<<<<<<<<<<<<<<<
'==== Install the patch for _OPEN
    ToolBox "RQ",SetTrapAddress%,reg&(0),(pPatch&),0,0
'=== Opens a file with shared access. It must be opened with the
'=== patch.
'    OPEN "Am.tmp2" FOR INPUT AS 1

'==== Remove the patch
    ToolBox "RQ",SetTrapAddress%,reg&(0),(pOpen&),0,0
'>>>>>>>>>>>>>>>>>>>> End of Critical Section <<<<<<<<<<<<<<<<<<<

'==== clean up
    hunLock hpatch&
    DisposeHandle hpatch&
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB58177


Hiding Folders & Changing Other Folder Attributes with ResEdit (58212)

Summary

The procedure below describes how you can use ResEdit to change a Macintosh folder's attribute, for example, making a folder hidden.

ResEdit is supplied with Microsoft QuickBasic 1.00 for the Apple Macintosh. Updated versions of ResEdit may be obtained from Macintosh user groups or from Apple Computer, Inc.

More information

To hide a folder or change other folder attributes, follow the steps listed below:

  1. Double-click ResEdit to start it.
  2. Single-click on the folder you want to modify, thus highlighting that folder. (Do not double-click on the folder because this shows you the contents of the folder, not the folder attributes.)
  3. Choose Get Info from the File menu. A dialog box that allows you to change the folder's name and attributes appears. Changeable attributes include Locked, Invisible, Inited, System, On Desk, Bozo, Busy, and Changed.
  4. Put anX in the box next to "Invisible" to make the folder hidden.
  5. Choose Quit from the File menu.
  6. AnswerYes to the "Save <Info for folder _____> before closing?" prompt.
  7. The folder is now hidden (invisible) and can be "unhidden" (made visible) by following the same steps. (Note: Although the folder is not visible on the Desktop, it is visible in ResEdit.)
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB58212


Correction for ToolBox Statement Example Calling ScrollRect (58659)

Summary

On Page 519 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual, the example for the ScrollRect ToolBox call is incorrect.

The incorrect example on Page 519 is as follows:
   Trapno% = &HA8EF
   ToolBox "P", Trapno%, r%(0), (horiz%), (vert%), H&
The correct syntax for this ToolBox call is as follows:
   Trapno% = &HA8EF
   ToolBox "P", Trapno%, VARPTR(r%(0)), (horiz%), (vert%), (H&)
This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB58659


Correction for PaintArc, QuickBasic ToolBox Example, Page 516 (58674)

Summary

The description of the PaintArc ToolBox routine on Page 516 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual is incorrect. There are three errors in the description, as follows:

  1. The trap number (&HA8CO) is wrong in the example; however, it is correct in the description above (&HA8BF).
  2. Also in the example, the rectangle parameter r%() is incorrectly passed (without VARPTR) in the ToolBox statement.
  3. The rectangle argument is listed as "r%", which signifies a single integer, instead of as "r%()", which signifies an integer array.

More information

For a list of the Macintosh system traps, see Appendix C of "Inside Macintosh: Volume III," by Apple Computer, published by Addison-Wesley.

The incorrect example from Page 516 is as follows:
   TrapNo%=&HA8CO
   Toolbox "P", TrapNo%, r%(0), (startAngle%), 45
It should read as follows:
   TrapNo%=&HA8BF
   Toolbox "P", TrapNo%, VARPTR(r%(0)), (startAngle%), 45
The following is a complete example of invoking the PaintArc routine through QuickBasic's ToolBox statement:
   Toolbox "i"           'Initialize toolbox and variables
   DIM r%(3)
   SetRect r%(0), 10, 10, 100, 100
   startAngle% = 10
   TrapNo%=&HA8BF
   Toolbox "P", TrapNo%, VARPTR(r%(0)), (startAngle%), 45
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB58674


Correction for ColorBit ToolBox Argument on Page 508 (58675)

Summary

The ColorBit argument description on Page 508 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual is incorrect. The "theBit%" parameter is incorrectly shown as an array, "theBit%()", in the argument description table. It should be a single integer variable "(theBit%)", as shown in the "Example" on the same page. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB58675


How to Put an Icon in a Menu Item Using ToolBox Statement (58677)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    In Microsoft QuickBasic 1.00 for the Apple Macintosh, the Menu statement does not support all forms of menus possible in the current Macintosh systems. For example, it is not possible to place an icon in a menu using Basic's Menu statement, even though the Macintosh Menu Manager supports this feature. However, it is possible to access the Macintosh Menu Manager directly with Basic's ToolBox statement.

    The example below shows how to use the ToolBox statement to call the Menu Manager, create a menu, and then display the menu with an icon in that menu. The icon displayed should be an existing Icon resource in either the source file, the application file, or the System file.

    This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

    More information

    For more information on programming menus using the Toolbox routines, there is another Knowledge Base article that shows how to create pop-up menus. This article can be found by querying on the following words:

    ToolboxNEWTOOL pop-up

    Also, see Chapter 11 of "Inside Macintosh, Volume I" by Apple Computer, published by Addison-Wesley.

    The following code example creates a menu and displays an icon with ID 257 in that menu. When working inside the QuickBasic interpreter, this icon can be in the Icon resource of either the System file or the source file. When working with a compiled application, the Icon resource should be placed into the resource fork of the application file.

    Note: This program does not process any menu messages, and thus lacks full functionality. Detecting which menu option was selected must be done by polling the mouse position with a QuickBasic statement, such as GetMouse. Neither QuickBasic's ON Menu GOSUB event trapping nor the GetNextEvent system trap will trap menu events for the method used in this program.

    [This program's method can't use QuickBasic's ON Menu GOSUB to trap the menu events because the ToolBox statement in this program makes menus incompatible with ON Menu GOSUB. QuickBasic also does not allow programs to use the Macintosh ROM routine GetNextEvent because QuickBasic traps all events and empties out the event queue before it allows a ToolBox GetNextEvent call to act upon them. GetNextEvent always returns a value of FALSE (zero) because the event queue is cleared by QuickBasic.]

    Code Example (Incomplete: performs no action when menu is selected.)

    '*** Creating menu with icon in it using ToolBox calls
ToolBox "i"

'Clear old menu bar
ClearMenuBar% = &HA934
ToolBox "PQ", ClearMenuBar%

'Get handle for new menu
mh& = 0
id% = 1
NewMenu% = &HA931
ToolBox "LQ", NewMenu%, id%, "Test", mh&

'Insert menu into menu bar
after% = 0
InsertMenu% = &HA935
ToolBox "PQ", InsertMenu%, (mh&), (after%)

'***** Add item with icon to menu
'Note: Icon should have id of 256+n for "Mytest^n"
'      For icons with ids > 265, use ASC(n)-ASC(0)
'      The icon resource can be in System file, Source file, or
'        compiled application.
AppendMenu% = &HA933
ToolBox "PQ", AppendMenu%, (mh&), "Mytest^1"

'Draw new menu bar
DrawMenuBar% = &HA937
ToolBox "PQ", DrawMenuBar%

'Wait for a mouse click to end program
WHILE Mouse(0) <> 1 : WEND
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB58677


ToolBox "Type Mismatch"; Use VARPTR on Array Parameter (58820)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Many of the ToolBox statement calls documented in Section E.10.3 (Pages 497-524) of "Microsoft QuickBasic for Macintosh: Language Reference" incorrectly show passing arrays by simply passing the first element of the array.

    In most of these cases, this causes the error "Type Mismatch" on the ToolBox statement. To avoid this error, pass the VARPTR of the first element of the array.

    One exception to this rule is the return array for register-based calls. This array can be passed with the first element of the array without using VARPTR.

    The following routines on Pages 497-524 should pass the VARPTR of the first array element:

    BackPat CopyBits EraseArc FillArc FrameArc InvertArc PaintArc RectInRgn ScrollRect SetPortBits

    This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

    More information

    The following is a correct example of the BackPat ToolBox call:
       DIM pattern%(3)
   pattern%(0)=&HAAAA
   pattern%(1)=&H5555
   pattern%(2)=&HAAAA
   pattern%(3)=&H5555
   ToolBox "i"
   ToolBox "P", &HA87C, VARPTR(pattern%(0))
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB58820


Correction for FillArc ToolBox Example on Page 511 "Reference" (58821)

Summary

The FillArc ToolBox example on Page 511 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" is incorrect. The ToolBox statement does not use the rectangle parameter (r%()), and the example references the pattern parameter incorrectly (pat%()).

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

The incorrect example on Page 511 is as follows:
   TrapNo%=&HA8C2
   Toolbox "P", TrapNo%, (startAngle%), (arcAngle%), pat%
It should read as follows (note: the underscore is for display purposes only; VARPTR(pat%(0)) should be on the same line as the ToolBox statement):
   TrapNo%=&HA8C2
   Toolbox "P", TrapNo%, VARPTR(r%(0)), (startAngle%), (arcAngle%),_
                         VARPTR(pat%(0))
The following is a complete example using the FillArc ToolBox call:
   ToolBox "i"                  'Initialize toolbox and variables
   DIM r%(3), pat%(3)
   SetRect r%(0),10,10,100,100
   pat%(0) = &H5555             'Make checker pattern
   pat%(1) = &HAAAA
   pat%(2) = &H5555
   pat%(3) = &HAAAA
   startAngle% = 10
   arcAngle%   = 90
   TrapNo%=&HA8C2
   Toolbox "P", TrapNo%, VARPTR(r%(0)), (startAngle%), (arcAngle%),_
                         VARPTR(pat%(0))  'Should be on Toolbox line
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB58821


GetFontName ToolBox Example Correction on Page 514 "Reference" (58822)

Summary

The GetFontName Example on Page 514 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" is incorrect. The variables that are initialized do not match the variables in the ToolBox statement. This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

The incorrect example from Page 514 is as follows:
   TrapNo%=&HA8FF
   a$ = ""
   fNum% = 4
   Toolbox "P", TrapNo%, (FontNum%), FontName$
It should be changed to read as follows:
   TrapNo%=&HA8FF
   FontName$ = ""  ' This is changed.
   FontNum% = 4    ' This is changed.
   Toolbox "P", TrapNo%, (FontNum%), FontName$
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB58822


SetDateTime ToolBox Example Correction on Page 520 "Reference" (58823)

Summary

The SetDateTime Example on Page 520 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" is incorrect. The DIM statement is missing a space and uses the wrong type for the array.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

The incorrect example from Page 520 is as follows:
   DIMrr$(4)
   SetDateTime%=&HA03A
   DO&=NewDateTime&
   Toolbox "R", SetDateTime%,rr&(0),,,(DO&)
It should be changed to read as follows:
   DIM rr&(4)              '*** This line is corrected
   SetDateTime%=&HA03A
   DO&=NewDateTime&
   Toolbox "R", SetDateTime%,rr&(0),,,(DO&)
The following is a full example of using SetDateTime:
   Toolbox "I"                          'Initialize toolbox and vars
   DIM rr&(4),OldDT&,NewDT&
   SetDateTime%=&HA03A

   GetDateTime OldDT&                   'Get current info
   DO&=OldDT&+1000                      'Move forward 1000 seconds
   Toolbox "R", SetDateTime%,rr&(0),,,(DO&)

   GetDateTime NewDT&                   'Get new info
   DO&=NewDT&-1000                      'Reset date and time
   Toolbox "R", SetDateTime%,rr&(0),,,(DO&)

   PRINT OldDT&, NewDT&                 'Show difference
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB58823


How to Use Apple Symbol in Menus; Create Custom Apple Menu (58824)

Summary

This article demonstrates how to use the Apple symbol and other special characters in menus. By disabling the standard Apple menu, it is possible to create your own application Apple menu. This facility gives more control to QuickBasic programs.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

The following code example disables the Apple menu and creates a menu bar containing new Apple, File, and Edit menus. It then creates menus using each of the special low-order ASCII characters (17-20), and finally, it makes menu items using all the displayable extended-ASCII characters.
toolbox "i"

'Erase menu bar
toolbox "pq", &HA934

'Set up 3 new standard menus :
Menu 1, 0, 1, CHR$(20)       'Apple symbol=CHR$(20)
Menu 2, 0, 1, "File"
Menu 3, 0, 1, "Edit"

'Set four other menus using special characters
FOR i% = 17 TO 20
    Menu i%-13, 0, 1, CHR$(i%)+STR$(i%)
NEXT

'Set menu items to show usable extended characters
FOR i% = 1 TO 6
    FOR j% = 1 TO 15
        n% = 127+((i%-1)*15)+j%
        Menu i%+1, j%, 1, CHR$(n%)+STR$(n%)
    NEXT
NEXT

'Wait for a mouse click to end program
WHILE Mouse(0)<>1 : WEND
Note: This program does not process any menu events, and thus lacks full functionality. Detecting which menu option is chosen must be done using ON Menu GOSUB event trapping or polling of the Menu() function.

For users of the Macintosh II computer, the above program even uses the color Apple in the first menu. The limitation to using color with the apple is that the menu title must be one character wide and the color icon (cicn resource), id=20, must be defined in the System file. This can be checked with ResEdit by doing the following:

  1. Start ResEdit.
  2. Open the System file.
  3. Open the "cicn" resource.
  4. Verify that there is a resource with ID=20.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB58824


FIX: Compiled QuickBasic Sys Error on Macintosh IIci IIcx IIfx (59137)

Symptoms

Programs compiled with the Use Default Window option in Microsoft QuickBasic 1.00 can fail at run time with a System error (bomb) ID=1 on the Macintosh IIci, IIcx, and IIfx. The same compiled program runs correctly on other Macintoshes, including the Macintosh Plus, SE, or II. The same program runs correctly in QuickBasic's interpreter on all of the above Macintoshes.

Microsoft has confirmed this to be a bug in programs compiled in Microsoft QuickBasic 1.00 for the Macintosh . This problem was corrected in QuickBasic 1.00a, which was released specifically to correct this problem (and no other problems). Later, QuickBasic 1.00b was released, which also corrects this problem (in addition to correcting other problems). Microsoft recommends upgrading to the latest release for QuickBasic, version 1.00b (as of April 1991).

Version 1.00a was needed only by programmers developing compiled programs to run on the Macintosh IIci, IIcx, and IIfx, since no other problems were corrected by 1.00a.

You can work around this problem in QuickBasic 1.00 by NOT compiling with Use Default Window from the Options dialog box (under the Run menu), and using a WindOW statement to make your own output window.

More information

The Macintosh IIci, IIcx, and IIfx computers were released by Apple after Microsoft released QuickBasic 1.00. Microsoft released QuickBasic 1.00a to correct the introduced incompatibility.

To duplicate the problem, compile the following program in QuickBasic 1.00 with the Use Default Window option and run the compiled " apl" program on a Macintosh IIci, IIcx, or IIfx computer:
   PRINT "Hello world"
To work around the problem in 1.00, compile without the Use Default Window option and add a WindOW statement, such as the following:
   WindOW 1,"TEST",(2,40)-(400,300)
   PRINT "Hello world"
We have found that this compatibility problem may be related to the memory configuration and the number of empty memory slots on the Macintosh IIci. The Macintosh IIci computers that demonstrate this problem have had 4 megabytes of RAM (four 1-megabyte SIMS), leaving four empty memory slots. When these four empty memory slots are filled (for example, by expanding to 5 megabytes using four 256K SIMS), the problem disappears.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB59137


Example of SaveString, GetString, LoadString Library Routines (59286)

Summary

The following program example shows how to invoke SaveString, LoadString, and GetString, which are QuickBasic Toolbox library (MBLC) routines described on Pages 484, 487, and 492 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual.

More information

SaveString, LoadString, and GetString can only use strings up to 255 characters in length.

Note that SaveString, LoadString, and GetString require calls to other library (MBLC) routines (such as OpenResFile, CloseResFile) in order to be used.

SaveString does NOT overwrite (replace) an existing resource (if any) that has the same ID number. Instead, SaveString places another resource with the same ID in the file. This poses a problem with running the example below more than once, since a duplicate resource with ID=0 is added to the resource file each time. You can avoid writing two resources with the same ID number in a resource file by executing GetRes to get the handle of the existing resource, then executing RemoveRes to delete it before saving the new resource. Or, you can simply delete the resource file and make a new one. The OpenResFile statement automatically creates a new resource file if the specified file does not exist. If the file exists, OpenResFile opens its resource fork.

Code Example

ref% = 0       'Must initialize ref% and id%, otherwise you'll get a
id% = 0        ' "TYPE Mismatch" error
a$ = "This is a test of SaveString"
openresfile "stringres",ref% 'If the file "stringres" doesn't exist,
                             'it is created and assigned a ref% number

'The following SaveString statement saves a$ in the resource file as a
'named resource, "teststring". (Giving a name is optional.)
'(ResEdit can later view the string stored in the resource file):
savestring ref%,id%,a$,"teststring"

closeresfile ref%     'Close "stringres" resource file
WHILE Mouse(0)<>1:WEND
b$=""
ref% = 0
id% = 0
openresfile "stringres", ref%   'Opens "stringres" resource file

' 1. Here is one way to retrieve the string:
loadstring ref%,id%,b$
PRINT b$    ' Prints the string retrieved with LoadString

' 2. Here is another way to retrieve the string:
getstring ref%,id%,h&        'Gets string resource with id% = 0 and
                             'assigns it the handle h&
drawstring h&amp;    'Draws the string associated with handle h&

closeresfile ref%
END
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB59286


Example of Alert, a QuickBasic Toolbox Library (MBLC) Routine (59287)

Summary

Below is an example of using the Alert routine, which is a Toolbox library (MBLC) routine described on Pages 439-441 and 475 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

For a more complete demonstration program, see the Alert Demo program in the QB Demos folder on the QuickBasic Examples disk.

The syntax for the Alert routine is as follows

alert ref%,type%,id%,item%,a$(0),a$(1),a$(2),a$(3)

where:

ref% = the reference number of an open resource file

type% = the type of icon (if any) displayed in the alert box (see Pages 439 and 475)

id% = ID number of a specific alert box in the opened resource file referenced by ref%

item% = returns the number of the button that was pressed in the alert box

a$() = strings that you can put into the alert box

Code Example

ref%=0
IF SYSTEM(4) THEN    ' If program is compiled, use OpenResFile...
   n$="Examples:QB Demos:Demo Resources"  'Specify "disk:folder:file"
   OpenResFile n$,ref%
ELSE  ' else if interpreted, get file reference number of QuickBasic:
   ref% = SYSTEM(7)
END IF
' Note: The alert box with ID number 305 is stored in the resource
' fork of Microsoft QuickBasic (b) and (d), and also in the Demo
' Resources file in the QB Demos folder on the QuickBasic Examples disk

item% = 0           'Initialize this return argument for alert,
                    'otherwise you'll get a "TYPE Mismatch" error.
a1$ = "Example using Alert"
a2$ = "This is string 2"
a3$ = "This is string 3"
alert ref%,2,305,item%,a1$,a2$,a3$
                                 'ref% = reference # of resource file
                                 '2    = type of icon displayed.
                                 '       Icon 2 is a caution sign.
                                 '305  = ID number of alert resource
                                 '       in Macintosh QuickBasic (b)
                                 'item% = returns the number of which
                                 '        button was pressed, if any
                                 'a1$, a2$, a3$ = Strings you wish to
                                 '              put into the alert box
IF item% <> -1 THEN
   PRINT "You have clicked button number =",item%
ELSE
   PRINT "No button was selected."
END IF
WHILE Mouse(0)<>1 : WEND   '
END
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB59287


How to Read Binary Files Using Basics Without Binary Access (59290)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Files written with Binary OPEN access can be read from other Basic products using either Random access or sequential INPUT access, making use of the INPUT$ function to read in groups of bytes. Note that ASCII byte values and integers are stored the same way in most Microsoft Basics, but the floating-point (single and double precision) formats may differ among various Basic versions, which can complicate sharing of files created with Binary or Random access.

    Note that "binary file" is a general term for a file containing a stream of bytes with no delimiters. A binary file can be written (or read) with an OPEN access of Binary or Random in Basic. To make sense of a binary file, you must also know the record definition (or byte boundaries) of all types of variables stored in the file.

    To illustrate the above concepts, examples are provided below. Example 2a or 2b running in Microsoft QuickBasic (b) (IEEE binary math version) 1.00 for the Apple Macintosh can read IEEE floating-point numbers stored in a file that was created with Binary or Random access in QuickBasic for Ms-Dos (in Example 1a or 1b) and uploaded to the Macintosh. These products share the same IEEE format, even though they run on different computers. (Note: To transfer the file, you need special serial communications or uploading software/hardware capable of transferring binary data files between Ms-Dos and Macintosh computers.)

    More information

    Do not confuse the terms "binary file" and OPEN FOR Binary, which are different concepts. A binary file is a type of file, while FOR Binary is an access mode of the OPEN statement (for opening ANY type of file).

    The Binary access mode of the OPEN statement is supported in Microsoft QuickBasic 4.00, 4.0B, and 4.50 for Ms-Dos, Microsoft Basic Compiler 6.00 and 6.0B for Ms-Dos and MS OS/2, and Microsoft Basic PDS 7.00 for Ms-Dos and MS OS/2. (These product versions also support a new third variable argument on the PUT# and GET# statements to more conveniently write variables to Binary or Random access files, without the need for a FIELD statement).

    However, the Binary OPEN access mode (and the third variable argument on the PUT# and GET# statements) are NOT features in the following products: in Microsoft QuickBasic 1.00, 1.01, 1.02, 2.00, 2.01, and 3.00 for Ms-Dos; in Microsoft Basic Compiler 5.35 and 5.36 for Ms-Dos; in Microsoft GW-Basic Versions 3.20, 3.22, 3.23, and earlier; and in Microsoft QuickBasic 1.00 for the Apple Macintosh.

    For QuickBasic (b) for Macintosh, the numeric conversion from a Ms-Dos QuickBasic 4.00, 4.0B, or 4.50 Binary or Random file is simple with the CVI, CVL, CVS, and CVD functions. QuickBasic (d) (decimal math version) for Macintosh can use CVI and CVL, but not CVS or CVD, for this conversion.

    Since Ms-Dos Basics earlier than QuickBasic 4.00, 4.0B, or 4.50 do not support the Long type and their floating-point format is not IEEE (except for QB87.Exe in QuickBasic 3.00), the numbers stored as strings in their Binary or Random files are unreadable by CVS and CVD in QuickBasic for the Macintosh. Integers are readable with the CVI function. To convert other numeric values (Long integer, single precision, and double precision), you would have to do complicated bit manipulation based on the IEEE format to parse the string into a number recognizable in that Basic version.

    For more information concerning the IEEE format, please see Pages 131-134 in the "Microsoft Macro Assembler 5.1: Programmer's Guide," or the "IEEE and Rounding" application note, which can be obtained by calling Microsoft Technical Support at (206) 454-2030. More information can also be found in this database by querying on the following words:

    floating and point and format and IEEE

    Examples 1a and 1b below create an identical Binary.DAT binary file on disk for a given Basic.

    Example 1a

    The following code outputs a file with strings containing numeric values. Run this in QuickBasic 4.00, 4.0B, or 4.50 for Ms-Dos, Basic compiler 6.00 or 6.0B for Ms-Dos, or in Basic PDS 7.00 for Ms-Dos (which all support the OPEN FOR Binary mode and the third PUT# variable argument). Examples 1a and 1b create an identical Binary.DAT file on disk for a given Basic.
       OPEN "binary.dat" FOR Binary AS #1
   i% = 1
   l& = 2
   s! = 3.45!
   d# = 6.789#
   PUT #1, , i%
   PUT #1, , l&amp;
   PUT #1, , s!
   PUT #1, , d#
   CLOSE #1

    Example 1b

    The following code outputs a file with strings containing numeric values. Run this in QuickBasic 4.00, 4.0B, or 4.50 for Ms-Dos, Basic compiler 6.00 or 6.0B for Ms-Dos, in Basic PDS 7.00 for Ms-Dos, or even in QuickBasic (b) for Macintosh. (Examples 1a and 1b create an identical Binary.DAT file on disk for a given Basic.) Example 1b uses the FIELD statement technique (with Random access mode):
       OPEN "binary.dat" AS #1 LEN = 18
   FIELD #1, 2 AS i$, 4 AS lo$, 4 AS S$, 8 AS D$
   i% = 1
   lo& = 2
   s! = 3.45!
   d# = 6.789#
   LSET i$ = MKI$(i%)
   LSET lo$ = MKL$(lo&amp;)
   LSET s$ = MKS$(s!)
   LSET d$ = MKD$(d#)
   PUT #1,1
   CLOSE #1

    Example 2a

    The following program, when run in QuickBasic (b) for Macintosh (or run in any other Basic listed above that uses IEEE format and supports the Long integer data type), will read the Binary.DAT file created by Example 1a or 1b. This program opens the file FOR INPUT (sequential access) and invokes the INPUT$ function:
       OPEN "binary.dat" FOR INPUT AS #1
   i$ = INPUT$(2, 1)    ' Inputs 2 bytes
   lo$ = INPUT$(4, 1)   ' Inputs 4 bytes
   s$ = INPUT$(4, 1)    ' Inputs 4 bytes
   d$ = INPUT$(8, 1)    ' Inputs 8 bytes
   PRINT CVI(i$), CVL(lo$), CVS(s$), CVD(d$)
   CLOSE #1

    Example 2b

    The following program, when run in QuickBasic (b) for the Macintosh (or run in any other Basic listed above that uses IEEE format and supports the Long integer data type), will also read the file created by and uploaded from Example 1a or 1b. Example 2b uses the FIELD statement technique (with Random access mode):
       OPEN "binary.dat" AS #1 LEN = 18
   FIELD #1, 2 AS i$, 4 AS lo$, 4 AS S$, 8 AS D$
   GET#1,1
   PRINT CVI(i$), CVL(lo$), CVS(s$), CVD(d$)
   CLOSE #1
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB59290


FramePoly and FramePgon Don't Frame Same Polygon Twice (59317)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Given the exact same polygon coordinates, the CALLed ROM routine FramePoly will not frame the exact same polygon on multiple calls. This same behavior occurs with the equivalent ROM routine FramePgon invoked with QuickBasic's ToolBox statement. Therefore, this is a limitation of the Apple Macintosh ROM routines, not of Microsoft QuickBasic.

    More information

    This problem can be demonstrated by the following sample program. This program draws a polygon with FramePoly, changes the mode of the QuickDraw pen to XOR, and then executes the exact same FramePoly statement. By definition, you would expect this to erase the polygon. However, this does not happen and a few pixels are left visible, mostly at the corners. This same problem occurs when FramePgon is used in a similar manner.

    Code Example

    DIM polygon (12)

polygon%(0)  = 26                          'Number of bytes in array.

polygon%(1)  = 100  : polygon%(2)  = 10    'Coordinates of rectangle
polygon%(3)  = 300  : polygon%(4)  = 500   'enclosing the polygon.

polygon%(5)  = 100  : polygon%(6)  = 180   'Coordinates of the
polygon%(7)  = 260  : polygon%(8)  = 220   'endpoints of the polygon.
polygon%(9)  = 290  : polygon%(10) = 390
polygon%(11) = 100  : polygon%(12) = 180

FramePoly VARPTR(polygon%(0))   'Draw the polygon.
PenMode 10                      'Switch QuickDraw pen to XOR mode.

LOCATE 1,1
PRINT "Click to redraw the polygon"
WHILE Mouse(0) = 0
WEND

FramePoly VARPTR(polygon%(0))   'Redraw the same polygon.

LOCATE 1,2                      'Pause to view the results.
PRINT "Click to end"            'Some pixels around the corners of the
WHILE Mouse(0) = 0              'polygon are still visible.
WEND
END
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB59317


Polygon Routines Don't Affect Total Area of Framed Polygon (59318)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The CALLed Macintosh ROM routines ErasePoly, FillPoly, Paintpoly, and InvertPoly do not effect the entire area of a polygon drawn with FramePoly. For example, if a polygon is drawn with FramePoly and then the same polygon is erased with ErasePoly, not all of the polygon will be erased.

    This same behavior occurs with the equivalent ROM routines ErasePgon, FillPgon, PaintPgon, and InvertPgon invoked with QuickBasic's ToolBox statement. That is, they will not effect the entire area of a polygon drawn with FramePgon. Therefore, this is not a problem with QuickBasic, because QuickBasic behaves exactly the same as a direct call to the ROM routine itself.

    This information applies to Microsoft QuickBasic Compiler 1.00 for the Apple Macintosh. This is a limitation of the Apple Macintosh ROM routines.

    More information

    The following example program illustrates this behavior. It first uses FramePoly to draw a polygon and then prompts the user to perform other operations (FillPoly, InvertPoly, ErasePoly, and Paintpoly) on the same polygon. These other operations do not effect the entire polygon. In this example, the behavior is very evident with ErasePoly and FillPoly, slightly evident with InvertPoly, and not evident with Paintpoly (it would be more evident with Paintpoly if the current pen pattern was changed to something else).

    Code Example

    DIM polygon%(12)
DIM pattern%(3)

polygon%(0)  = 26                         'Number of bytes in array.

polygon%(1)  = 200 : polygon%(2)  = 10    'Coordinates of rectangle
polygon%(3)  = 300 : polygon%(4)  = 500   'enclosing the polygon.

polygon%(5)  = 200 : polygon%(6)  = 180   'Coordinates of the
polygon%(7)  = 260 : polygon%(8)  = 220   'endpoints of the polygon.
polygon%(9)  = 290 : polygon%(10) = 390
polygon%(11) = 200 : polygon%(12) = 180

FOR i = 0 to 3          'Create a pattern for use with FillPoly.
   pattern%(i) = 1234
NEXT i

FramePoly VARPTR(polygon%(0))

LOCATE 1,1
PRINT "Click to fill the polygon."
WHILE Mouse(0) <> -1
WEND
FillPoly VARPTR(polygon%(0)),VARPTR(pattern%(0))

LOCATE 2,1
PRINT "Click to invert the polygon."
WHILE Mouse(0) <> -1
WEND
InvertPoly VARPTR(polygon%(0))

LOCATE 3,1
PRINT "Click to erase the polygon."
WHILE Mouse(0) <> -1
WEND
ErasePoly VARPTR(polygon%(0))

LOCATE 4,1
PRINT "Click to paint the polygon."
WHILE Mouse(0) <> -1
WEND
Paintpoly VARPTR(polygon%(0))

LOCATE 5,1
PRINT "Click to end."
WHILE Mouse(0) <> -1
WEND
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB59318


BUG: Polygon ROM CALLs Top-Justify Within Their Rectangle (59319)

Symptoms

The vertical position of a polygon manipulated by the ErasePoly, InvertPoly, Paintpoly, and FillPoly Toolbox ROM routines is directly related to the y coordinate of the upper-left corner of the rectangle enclosing the polygon that is passed to those routines. This is not the case with FramePoly.

Microsoft has confirmed this to be a bug with Microsoft QuickBasic Version 1.00 for the Macintosh . We are currently researching this problem and will post further information here as it becomes available.

More information

In other words, if the y coordinate of the upper-left corner of the rectangle enclosing the polygon is less than the y coordinate of the uppermost point of the specified polygon, then the y coordinate of the uppermost point of the polygon will be drawn as having the same value as the y coordinate of the upper-left corner of the rectangle enclosing the polygon. The y coordinates of the remaining points in the polygon will be adjusted upwards accordingly.

For example, assume the y coordinate of the uppermost point in a polygon is 200 and the y coordinate of the upper-left corner of the rectangle enclosing the polygon is passed to the polygon-drawing routines as 100. When FramePoly is called, the y coordinate of the uppermost point in the polygon actually drawn will be 200. However, when FillPoly, InvertPoly, ErasePoly, or Paintpoly are called, the y coordinate of the uppermost point in the polygon drawn will be converted to 100 because that is the value of the y coordinate of the upper-left corner of the rectangle enclosing the polygon. Remember that the coordinates of this rectangle are passed to the routines as a parameter and it is possible (and workable in the case of FramePoly) to pass a rectangle whose sides the polygon won't come close to touching.

To avoid this behavior, make sure that the y coordinate of the upper-left corner of the rectangle passed to the FillPoly, InvertPoly, ErasePoly, and Paintpoly routines is the same as the y coordinate of the highest point in the polygon. Another workaround is to invoke the equivalent ROM routines FramePgon, FillPgon, InvertPgon, ErasePgon, and PaintPgon with QuickBasic's ToolBox statement to draw polygons. The problem does not occur with these routines.

The following example program illustrates the problem. It first uses FramePoly to draw a polygon and then prompts the user to perform other operations (FillPoly, InvertPoly, ErasePoly, and Paintpoly) on the same polygon. These other operations will affect another region above the original polygon even though the same polygon coordinates are given. This is because the y coordinate of the upper-left corner of the rectangle enclosing the polygon that is passed to the routines (100) is less than the y coordinate of the uppermost point in the polygon (200). The same problem does NOT occur if QuickBasic's ToolBox statement is used to directly invoke the ROM routines FramePgon, FillPgon, InvertPgon, ErasePgon, and PaintPgon in a similar manner.

Code Example

DIM polygon%(12)
DIM pattern%(3)

polygon%(0)  = 26                         'Number of bytes in array.

polygon%(1)  = 100 : polygon%(2)  = 10    'Coordinates of rectangle
polygon%(3)  = 300 : polygon%(4)  = 500   'enclosing the polygon.

polygon%(5)  = 200 : polygon%(6)  = 180   'Coordinates of the
polygon%(7)  = 260 : polygon%(8)  = 220   'endpoints of the polygon.
polygon%(9)  = 290 : polygon%(10) = 390
polygon%(11) = 200 : polygon%(12) = 180

FOR i = 0 to 3          'Create a pattern for use with FillPoly.
   pattern%(i) = 1234
NEXT i

FramePoly VARPTR(polygon%(0))

LOCATE 1,1
PRINT "Click to fill the polygon."
WHILE Mouse(0) <> -1
WEND
FillPoly VARPTR(polygon%(0)),VARPTR(pattern%(0))

LOCATE 2,1
PRINT "Click to invert the polygon."
WHILE Mouse(0) <> -1
WEND
InvertPoly VARPTR(polygon%(0))

LOCATE 3,1
PRINT "Click to erase the polygon."
WHILE Mouse(0) <> -1
WEND
ErasePoly VARPTR(polygon%(0))

LOCATE 4,1
PRINT "Click to paint the polygon."
WHILE Mouse(0) <> -1
WEND
Paintpoly VARPTR(polygon%(0))

LOCATE 5,1
PRINT "Click to end."
WHILE Mouse(0) <> -1
WEND
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB59319


How to Use "!C/P Script" MPW Script File, Macintosh QuickBasic (59322)

Summary

The steps below explain how to use the MPW (Macintosh Programmer's Workshop) script file included with Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

(Note: MPW is by Apple Computer, Inc.)

There is an MPW script file, "!C/P Script", included with Macintosh QuickBasic on the Examples disk in the following directory:

User Libraries:MBPC Rsrcs

The following steps explain how to use the commands in the script file:

Note: It is assumed that you have installed MPW Version 3.00 on your machine. Refer to the MPW documentation to see how to do this.

  1. Go to the directory "User Libraries:MBPC Rsrcs," and double-click the script file "!C/P Script." This starts the MPW shell and loads in the script file.
  2. In MPW, choose Set Directory from the Directory menu. This brings up the Select Current Directory dialog box. Highlight (single click) the directory name appropriate for the language that you want to work in as follows:

    1. MPWC PCR for the C language
    2. MPWP PCR for Pascal
  3. Once the appropriate folder is highlighted, click the Directory button. This causes MPW to use the correct folder for finding the correct source code.
  4. Highlight the compilation command line for the file that you want to compile. Note: Some command lines run past one line, in which case, highlight all of the lines for that particular command.
  5. Press the Enter key on the numeric keypad (the RETURN key does not work the same as the Enter key in this case).
  6. Repeat Steps 4 and 5 for each compile and link line to be executed.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB59322


Basic &num Constant Defaults to &Onum (Octal), Not &Hnum (Hex) (59403)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Compiler 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.01
  • Microsoft QuickBasic 1.02
  • Microsoft QuickBasic 2.0
  • Microsoft QuickBasic 2.01
  • Microsoft QuickBasic 3.00
  • Microsoft QuickBasic 4.00
  • Microsoft QuickBasic 4.0B
  • Microsoft QuickBasic 4.50
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft GW-Basic 3.2
  • Microsoft GW-Basic 3.22
  • Microsoft GW-Basic 3.23

    • Summary

    In all versions of Microsoft Basic products, the base for a literal constant that begins with an ampersand (&) alone (not &H, &h, &O, or &o) defaults to octal (equivalent to &O or &o). Thus, if you type a literal such as the following

    &700

    then all versions of Microsoft Basic will assume that this is an octal literal equivalent to &o700.

    In fact, many Microsoft Basic Interpreters (such as GW-Basic Versions 3.20 and later for Ms-Dos; QuickBasic 4.00 and later for Ms-Dos; Microsoft Basic Interpreter Versions 2.00, 2.10, and 3.00 for the Apple Macintosh; and QuickBasic 1.00 for the Apple Macintosh) actually alter the literal to &o700 to show they are making this assumption.

    The octal default for a literal constant that begins with a lone ampersand (&) occurs in the following products:

    1. Microsoft QuickBasic 1.00 for the Apple Macintosh
    2. Microsoft Basic Compiler 1.00 for the Apple Macintosh
    3. Microsoft Basic Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh
    4. Microsoft QuickBasic 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.0B, 4.50 for Ms-Dos
    5. Microsoft Basic Compiler 5.35 and 5.36 for Ms-Dos
    6. Microsoft Basic Compiler 6.00 and 6.0B for MS OS/2 and Ms-Dos
    7. Microsoft Basic PDS 7.00 for Ms-Dos and MS OS/2
    8. Microsoft GW-Basic Interpreter Versions 3.20, 3.22, and 3.23

    More information

    To demonstrate this feature of Basic, enter the following code into the environment one of the Basic interpreters, such as GW-Basic or Microsoft QuickBasic:

       40 CLS
   50 PRINT &amp;700    ' This will print out as 448 (decimal value)
   55 PRINT &amp;o700   ' This will print out as 448 (decimal value)
   60 PRINT &amp;H700   ' This will print out as 1792 (decimal value)
   70 END

    In many Microsoft Basic interpreters (such as GW-Basic 3.20 or later for Ms-Dos; QuickBasic 4.00 and later for Ms-Dos; Basic interpreter 2.00, 2.10, and 3.00 for the Apple Macintosh; or QuickBasic 1.00 for the Apple Macintosh), the editor automatically changes lines 50 and 55 to the following:

       50 PRINT &amp;O700
   55 PRINT &amp;O700

    If you want a hexadecimal number, the & (ampersand sign) must be followed with H, as in line 60 above.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB59403


Passing Long Integers Between Macintosh QuickBasic and MPW C (59486)

Summary

The two programs below demonstrate how a Microsoft QuickBasic program can pass long integer variables to and from Apple MPW (Macintosh Programmer's Workshop) C version 3.00 pure code resources.

This information about interlanguage calling applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

When doing interlanguage calling with Microsoft QuickBasic, the other language can make calls to the Basic run time to get the address of passed arguments. This is accomplished with the GetNextLibArg statement.

GetNextLibArg returns a pointer to a variant record containing another pointer to each possible type of QuickBasic variable (single precision, double precision, integer, etc.). Usually a double indirection of pointers is used to get the actual passed data.

Using double indirection of pointers with LSC or Apple MPW C, however, does not return the correct value. This is a QuickBasic header file problem. The routine below demonstrates how an inline assembly-language routine can be used in place of the double indirection to work around the problem.

More information on interlanguage calling with Microsoft QuickBasic can be found in the "Microsoft QuickBasic for Apple Macintosh: Language Reference," starting on page 444.

Compile and link PrintLng.c from Apple MPW C version 3.00 as follows:
   c -p PrintLng.c

   link -p -c MSBB -o PrintLng -rt MBPC=2 -t MBPC -sn Main=PrintLng
   BasicLib.a.o PrintLng.c.o
Note: The file BasicLib.a.o comes with Microsoft QuickBasic for the Apple Macintosh on the Examples disk in the "User Libraries:MBPC Rsrcs:MPWC PCR" folder.

Once compiled and linked, PrintLng is a pure code resource that can be used with the RetLng QuickBasic program.

Code Example

The following QuickBasic program is RetLng, which invokes an Apple MPW C routine to return a series of long integer numbers:
   Library "PrintLng"
   A& = 0 : B& = 0
   CALL PrintLng(A&, B&)
   PRINT A&; B&
   WHILE INKEY$ = "" : WEND
The following Apple MPW C routine is PrintLng.c, which accepts a series of passed long-integer numbers from a Microsoft QuickBasic program and returns a constant value in them:
/**************************************************************
 * PrintLng.c (c) 1990 Microsoft Corporation                  *
 **************************************************************
 * Description: Example to show how to pass long integer      *
 *              numbers from QuickBasic to MPW C and back.    *
 **************************************************************/

#include "BasicMPWC.h"

pascal void AssignLng(LibArgPtr ptr, Longint val) = {
   0x225F,  /* movea.l (a7)+,a1                             */
   0x2E19,  /* move.l  (a1)+,d7   ;get Long value           */
   0x205F,  /* movea.l (a7)+,a0   ;get ptr to variable      */
   0x20C7   /* move.l   d7, (a0)+ ;assign the value         */
};

/*------------------------------------------------------------*
 * A routine to pass back to Basic single precision constants *
 *    Called from Basic as:                                   *
 *    CALL PrintLng (< long integer argument list >)          *
 *------------------------------------------------------------*/

PUBLIC Void Main() {
   INT16         tempflag, argtype;
   LibArgPtr     valptr;
   Longint       templng;

   argtype = GetNextLibArg(&valptr, &tempflag);

   while (argtype != _ARGSEND) {
      if (argtype != _NullARG)
         if (argtype == _LongARG) {
            templng = 4321;
            AssignLng(valptr, tempdbl);
         }
      argtype = GetNextLibArg(&valptr, &tempflag);
   }

} /* Main */
Running RetLng produces the following output:
   4321  4321
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB59486


Passing Single-Precision Data Between QuickBasic and MPW C (59487)

Summary

The two programs below demonstrate how a Microsoft QuickBasic program can pass single precision variables to and from Apple MPW (Macintosh Programmer's Workshop) C version 3.00 pure code resources.

This information about interlanguage calling applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

When doing interlanguage calling with Microsoft QuickBasic, the other language can make calls to the Basic run time to get the address of passed arguments. This is accomplished with the GetNextLibArg statement.

GetNextLibArg returns a pointer to a variant record containing another pointer to each possible type of QuickBasic variable (single precision, double precision, integer, etc.). Usually a double indirection of pointers is used to get the actual passed data.

Using double indirection of pointers with LSC or Apple MPW C, however, does not return the correct value. This is a QuickBasic header file problem. The routine below demonstrates how an inline assembly-language routine can be used in place of the double indirection to work around the problem.

More information on interlanguage calling with Microsoft QuickBasic can be found in the "Microsoft QuickBasic for Apple Macintosh: Language Reference," starting on page 444.

Compile and link PrintSng.c from Apple MPW C version 3.00 as follows:
   c -p PrintSng.c

   link -p -c MSBB -o PrintSng -rt MBPC=2 -t MBPC -sn Main=PrintSng
   BasicLib.a.o PrintSng.c.o
Note: The file BasicLib.a.o comes with Microsoft QuickBasic for the Apple Macintosh on the Examples disk in the "User Libraries:MBPC Rsrcs:MPWP PCR" folder.

Once compiled and linked, PrintSng is a pure code resource that can be used with the RetSng QuickBasic program.

It should be noted that PrintSng uses the record structure BigRec to pass the single-precision number to the assembly-language subroutine. This is because MPW automatically converts single and double precision numbers to an extended 10-byte format when passing them. Using the record structure stops MPW from performing this conversion.

Code Example

The following QuickBasic program is RetSng, which invokes an Apple MPW Pascal routine to return a series of single-precision numbers:
   Library "PrintSng"
   A! = 0 : B! = 0 : C! = 0
   CALL PrintSng(A!, B!, C!)
   PRINT A!; B!; C!
   WHILE INKEY$ = "" : WEND
The following Apple MPW C routine is PrintSng.c, which accepts a series of passed single-precision numbers from a Microsoft QuickBasic program and returns a constant value in them:
/**************************************************************
 * PrintSng.c (c) 1989 Microsoft Corporation                  *
 **************************************************************
 * Description: Example to show how to pass single-precision  *
 *              numbers from QuickBasic to MPW C and back.    *
 **************************************************************/

#include "BasicMPWC.h"

struct BigRec {
   Single singlenum;
};

pascal void AssignSng(LibArgPtr ptr, struct BigRec val) = {
   0x225F,  /* movea.l (a7)+,a1                               */
   0x2E19,  /* move.l  (a1)+,d7   ;get single precision value */
   0x205F,  /* movea.l (a7)+,a0   ;get ptr to variable        */
   0x20C7   /* move.l   d7, (a0)+ ;assign the value           */
};

/*------------------------------------------------------------*
 * A routine to pass back to Basic single-precision constants *
 *    Called from Basic as:                                   *
 *    CALL PrintSng (< single precision argument list >)      *
 *------------------------------------------------------------*/

PUBLIC Void Main() {
   INT16         tempflag, argtype;
   LibArgPtr     valptr;
   struct BigRec tempdbl;

   argtype = GetNextLibArg(&valptr, &tempflag);

   while (argtype != _ARGSEND) {
      if (argtype != _NullARG)
         if (argtype == _SINGARG) {
            tempdbl.singlenum = 123.456;
            AssignSng(valptr, tempdbl);
         }
      argtype = GetNextLibArg(&valptr, &tempflag);
   }

} /* Main */
Running RetSng produces the following output:
   123.456  123.456  123.456
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB59487


Passing Integers Between QuickBasic and MPW C Version 3.00 (59533)

Summary

The two programs below demonstrate how a Microsoft QuickBasic program can pass integers to and from Apple MPW (Macintosh Programmer's Workshop) C version 3.00 pure code resources.

This information about interlanguage calling applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

When doing interlanguage calling with Microsoft QuickBasic, the other language can make calls to the Basic run time to get the address of passed arguments. This is accomplished with the GetNextLibArg statement.

GetNextLibArg returns a pointer to a variant record containing another pointer to each possible type of QuickBasic variable (single precision, double precision, integer, etc.). Usually a double indirection of pointers is used to get the actual passed data.

Using double indirection of pointers with LSC or Apple MPW C, however, does not return the correct value. This is a QuickBasic header file problem. The routine below demonstrates how an inline assembly-language routine can be used in place of the double indirection to work around the problem.

For more information on interlanguage calling with Microsoft QuickBasic, see the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual, starting on page 444.

Compile and link SumIntArgs.c from Apple MPW Pascal version 3.00 as follows:
   c -p SumIntArgs.c

   link -p -c MSBB -o SumIntArgs -rt MBPC=2 -t MBPC -sn Main=SumIntArgs
   BasicLib.a.o SumIntArgs.c.o
Note: The file BasicLib.a.o comes with Microsoft QuickBasic for the Apple Macintosh on the Examples disk in the "User Libraries:MBPC Rsrcs:MPWC PCR" folder.

After compiling and linking, SumIntArgs is a pure code resource that can be used with the SumInt QuickBasic program.

Code Example

The following QuickBasic program is SumInt, which invokes an Apple MPW C routine to sum a series of passed integers:
   DEFINT a-z
   Library "SumIntArgs"
   a = 0     ' Initialize passed values
   b = 2
   c = 4
   d = 8
   CALL SumIntArgs(a, b, c, d)        ' CALL Pascal routine
   PRINT "Sum of: "  b;" ";c;" and ";d  ' Display returned values
   PRINT "Is: "a
   WHILE INKEY$ = "" : WEND             ' Wait for key press
The following Apple MPW C routine is SumIntArgs.c, which accepts a series of passed integers from a Microsoft QuickBasic program and returns the sum of the integers:
/*************************************************************
 * IntSum.c (c) 1989 Microsoft Corporation                   *
 *************************************************************
 * Description:  Example to show how to pass integers from   *
 *               QuickBasic to MPW C and back.               *
 *************************************************************/

/*========================= INCLUDE FILES ===================*/
#include "BasicMPWC.h"
pascal void AssignInt(LibArgPtr ptr, INT16 val) = {
   0x3E1F,    /* move.w  (a7)+,d7  ; get int value           */
   0x205F,    /* movea.l (a7)+,a0  ; get ptr to Int variable */
   0x3087     /* move.w   d7, (a0) ; assign the Int value    */
};

PUBLIC Void Main() {
   INT16      tempflag, argtype, NextInt, Sum;
   LibArgPtr  valptr, pSum;

   Sum = 0;
   argtype = GetNextLibArg(&pSum, &tempflag);
   argtype = GetNextLibArg(&valptr, &tempflag);

   while (argtype != _ARGSEND) {
      if (argtype != _NullARG)
         if (argtype == _INTARG) {
            NextInt = IntegerArg();
            Sum = Sum + NextInt;
         }
      argtype = GetNextLibArg(&valptr, &tempflag);
   }

   AssignInt(pSum, Sum);
} /* Main */
Running SumInt produces the following output:
   Sum of:  2   4 and 8
   Is:  14
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB59533


BUG: IF THEN SUBname Causes "Undefined Label"; Requires CALL (59757)

Symptoms

The IF ... THEN SUBName statement causes an "Undefined label" error in QuickBasic for the Macintosh when attempting an implicit call to the specified SUBprogram.

To work around this error, use an explicit CALL statement for single-line IF statements, as follows:
   IF ... THEN CALL SUBName
Microsoft has confirmed this to be a bug in Microsoft QuickBasic Version 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

More information

The problem occurs because the IF ... THEN Label statement does not require a GOTO statement for alphanumeric labels in QuickBasic for the Macintosh . (Note that Microsoft QuickBasic for Ms-Dos requires a GOTO clause for alphanumeric labels in the IF ... THEN GOTO Label statement.)

Since the GOTO is not required, the simple alphanumeric could be interpreted as a label or an implicit CALL to a SUB. By using the explicit CALL statement, the ambiguity of the statement is resolved.

Code Example

The following code example produces an "Undefined label" error on the first IF statement. If the first IF is removed, the second IF works correctly:
     IF 1 = 1 THEN SubName       'Causes "Undefined label" error
   IF 1 = 1 THEN CALL SubName  'No error for this line
   END

   SUB SubName STATIC
      PRINT "In Sub"
   END SUB
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB59757


BUG: WIDTH Not Reset in Mac QuickBasic Interpreter; Use 255 (59764)

Symptoms

The WIDTH for the output window in the interpreter in QuickBasic Version 1.00 for the Macintosh is not reset at the end of program execution. This can cause problems with subsequent program executions. For example, with a subsequent program that LOCATEs to a specific column and PRINTs a string, the string is placed on the next line if it exceeds the WIDTH set in the previous program. This problem does not occur in compiled applications.

To work around the problem, place a WIDTH 255 statement at the beginning of the program (or execute WIDTH 255 in the Command window). This resets the WIDTH to the default and has the effect of an "infinite" width.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic Version 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

More information

This problem affects the sample program on Pages 408 and 409 of the "Microsoft QuickBasic for Macintosh : Language Reference" manual. On the first run of this program, everything displays correctly, but on the second execution, the first PRINT statement is written at the beginning of the next line.

Code Example

The following code example demonstrates the problem when run multiple times:
   LOCATE 1, 30
   PRINT "Hello"
   WIDTH 30
   END
On the first run of the above program, it displays "Hello" beginning at the 30th column of the 1st line of the output window. The second and ensuing runs of the program display "Hello" on the beginning of the 2nd line.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB59764


Passing Double Precision Data Between QuickBasic and MPW C (60419)

Summary

The two programs shown below demonstrate how a Microsoft QuickBasic program can pass double precision numbers to and from pure code resources created with Apple MPW (Macintosh Programmer's Workshop) C version 3.00.

This information about interlanguage calling applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

When doing interlanguage calling with Microsoft QuickBasic, the other language can make calls to the Basic runtime to get the address of passed arguments. This is accomplished with the GetNextLibArg statement.

GetNextLibArg returns a pointer to a variant record containing another pointer to each possible type of QuickBasic variable (single precision, double precision, integer, etc.). Usually a double indirection of pointers is used to get the actual passed data.

Using double indirection of pointers with LSC or Apple MPW C, however, does not return the correct value. This is a QuickBasic header file problem. The routine below demonstrates how an inline assembly-language routine can be used in place of the double indirection to work around the problem.

More information on interlanguage calling with Microsoft QuickBasic can be found in the "Microsoft QuickBasic for Apple Macintosh: Language Reference" starting on page 444.

Compile and link PrintDbl.c from Apple MPW C version 3.00 as follows:

c -p PrintDbl.c

link -p -c MSBB -o PrintDbl -rt MBPC=2 -t MBPC -sn Main=PrintDbl
BasicLib.a.o PrintDbl.c.o

Note: The file BasicLib.a.o comes with Microsoft QuickBasic for the Apple Macintosh on the Examples disk in the User Libraries:MBPC Rsrcs:MPWP PCR Folder.

Once compiled and linked, PrintDbl is a pure code resource that can be used with the RetDbl QuickBasic program.

Note: PrintDbl uses the record structure BigRec to pass the double precision number to the assembly language subroutine. This is because MPW automatically converts single and double precision numbers to an extended 10-byte format when passing them. Using the record structure stops MPW from performing this conversion.

Code Example

The following QuickBasic program is RetDbl, which invokes an Apple MPW C routine to return series of double precision numbers:
   Library "PrintDbl"

   A# = 0 : B# = 0 : C# = 0
   CALL PrintDbl(A#, B#, C#)
   PRINT A#, B#, C#

   WHILE INKEY$ = "" : WEND
The following Apple MPW C routine is PrintDbl.c, which accepts a series of passed double precision numbers from a Microsoft QuickBasic program and returns a constant value in them:
/**************************************************************
 * PrintDbl.c (c) 1989 Microsoft Corporation                  *
 **************************************************************
 * Description: Example to show how to pass double precision  *
 *              numbers from QuickBasic to MPW C and back.    *
 **************************************************************/

#include "BasicMPWC.h"

struct BigRec {
   Double dblnum;
};

pascal void AssignDbl(LibArgPtr ptr, struct BigRec val) = {
   0x225F,  /* movea.l (a7)+,a1                             */
   0x2E19,  /* move.l  (a1)+,d7   ;get Long value           */
   0x2C19,  /* move.l  (a1)+,d6   ; get second part         */
   0x205f,  /* movea.l (a7)+,a0   ;get ptr to Int variable  */
   0x20C7,  /* move.l   d7, (a0)+ ;assign the Int value     */
   0x20C6   /* move.l   d6, (a0)+ ;assign the Int value     */
};

/*------------------------------------------------------------*
 * A routine to pass back to Basic double precision constants *
 *    Called from Basic as:                                   *
 *    CALL PrintDbl (< double precision argument list >)      *
 *------------------------------------------------------------*/

PUBLIC Void Main() {
   INT16         tempflag, argtype;
   LibArgPtr     valptr;
   struct BigRec tempdbl;

   argtype = GetNextLibArg(&valptr, &tempflag);

   while (argtype != _ARGSEND) {
      if (argtype != _NullARG)
         if (argtype == _DBLARG) {
            tempdbl.dblnum = 123.456;
            AssignDbl(valptr, tempdbl);
         }
      argtype = GetNextLibArg(&valptr, &tempflag);
   }

} /* Main */
Running RetDbl produces the following output:

123.456 123.456 123.456

Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB60419


Correction for "BasicMPWC.h" File Producing Error 261 (60420)

Summary

The file "BasicMPWC.h" supplied with Macintosh QuickBasic must be altered for use with MPW (Macintosh Programmer's Workshop) C Version 3.00. The corrections shown below allow the MPW C routines supplied with QuickBasic to be compiled with MPW C Version 3.00.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

If any of the MPW C routines supplied with Macintosh QuickBasic (AddStrings.C, PrintVerRec.C or PrintArgs.C) are compiled with MPW C Version 3.00, the following error message is generated:
   #pascal void Debugger()
   #   extern 0xA9FF;
   #                ?
   ### Error 261 we already did this function
   #----------------------------------------------------------
   #   File "BasicMPWC.h"; Line 186 # Compiling
   #----------------------------------------------------------
This error is generated because this function declaration also occurs in the "Types.h" header file that comes with MPW C 3.00. To eliminate the error message, comment out the last two lines of the file "BasicMPWC.h", so it appears as follows:
   /* Pascal Void Debugger()
        extern 0xA9FF;   */
After saving this change to disk, the MPW C files can be compiled without receiving any error messages.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB60420


Correction to ForeColor ToolBox Example (60426)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The ForeColor Toolbox example on Page 512 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" for Microsoft QuickBasic Version 1.00 for the Apple Macintosh uses the wrong type for the color parameter. The example uses a normal (2-byte) integer instead of a long (4-byte) integer (denoted by the "&" suffix). The argument description correctly lists the parameter as a long integer ("COL&").

    The incorrect example on Page 512 is as follows:
       TrapNo% = &HA862
   col% = 341
   ToolBox "P", TrapNo%, (col%)
    This should be changed to use long integers as follows:
       TrapNo% = &HA862
   col&amp; = 341
   ToolBox "P", TrapNo%, (col&amp;)
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB60426


BUG: Probs Using Long Integers in Mac QuickBasic 1.00 (60862)

Symptoms

This article documents several cases where the product of a long integer and another number can be incorrect in Microsoft QuickBasic Version 1.00 for the Macintosh . This problem occurs only in the interpreter, not in a compiled program.

Microsoft has confirmed this to be a bug in QuickBasic 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

More information

To work around the problem, either compile the code or change one of the variables to a single- or a double-precision number. The table below summarizes the values that X and Y can take on in the code example and whether or not the expression fails.

Reproducing the problem only requires a three-line program with two variables. The data type of the two variables should be as described in the chart below. Consider the following three-line program:
      X = <some value -- see the chart>
      Y = <some value -- see the chart>
      PRINT X * Y
This program produces incorrect results if X is a long integer with a value of 65536& and Y is a long integer with a value of -1. In this case, X will not be negative.

In the following chart

  1. "MAX" means the largest possible value that type of number can have.
              MAX Long:   2,147,483,647
          MAX Sing:   3.37+38
          MAX Double: 1.67D+308
  2. "MIN" means the smallest possible value that type of number can have.
              MIN Long:   -2,147,483,648
          MIN Sing:   -3.37E+38
          MIN Double: -1.67D+308
  3. "Long" means long-integer variable.
  4. "Sing" means single-precision variable. Double means double-precision variable.
                  X                   Y              Problem ?
    -------------------   ----------------       ---------

     65536& to MAX Long   Negative Long          Yes

    -65536& to MIN Long   Negative Long          Yes

     65536& to MAX Long   Negative Integer       Yes

    -65536& to MIN Long   Negative Integer       Yes

     65536& to MAX Sing   Negative Long          No
         or Double

    -65536& to MIN Sing   Negative Long          No
         or Double

     65536& to MAX Long   Negative Sing          No
                            or Double

    -65536& to MIN Long   Negative Sing          No
                            or Double
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB60862


Extra Comma Listed in Description of Alert Toolbox Routine (61333)

Summary

The description of the Alert Toolbox Library routine on Page 475 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual incorrectly lists an additional required comma after the item% parameter.

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

The incorrect Alert description from Page 475 is as follows:
   Alert ref%,type%,id%,item%,[[,A0$]][[,A1$]][[,A2$]][[,A3$]]
The corrected Alert description is as follows:
   Alert ref%,type%,id%,item%[[,A0$]][[,A1$]][[,A2$]][[,A3$]]
Please note that the optional comma before A0$ is still required when the A0$ parameter is used. Only the comma immediately following the item% is incorrect. The original syntax description incorrectly requires two commas between item% and A0$ when only one comma is actually necessary. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB61333


BUG: Undefined Subprogram CALLing Machine Language Using Long (61334)

Symptoms

CALLing a machine-language routine using a long integer (&) for the routine's address causes the QuickBasic Interpreter to produce the "Undefined subprogram" error. Using a long for the address works correctly in a compiled application.

To work around this problem, use a single-precision (!) or double-precision (#) variable for the address of the machine-language routine.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic version 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

Code Example

The following code example produces an "Undefined subprogram" error in the QuickBasic Interpreter but works correctly when compiled:
   Code% = &H4E75         'equiv to RTS in assembly language
   Ptr& = VARPTR(Code%)   'Ptr! or Ptr# works correctly
   CALL Ptr&              'This line causes Undefined subprogram
   PRINT "Call succeeds in application."
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB61334


BUG: Cannot ERASE Passed Arrays That Are DIMmed in SUBprograms (61404)

Symptoms

If a dynamic array is dimensioned in a SUBprogram and passed as a parameter to another SUB, any attempt to ERASE that array later in the first SUB generates an "Invalid function call" error. This problem occurs only in the interpreter.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic Compiler 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

More information

When run in the interpreter, the following code generates an "Invalid function call" error on the ERASE statement. Note that in the interpreter, all arrays are dynamic and all SUBs must be STATIC.
CALL FirstSub

SUB FirstSub STATIC             'In interpreter SUBs must be STATIC
   DIM array%(100)              'Data type of array does not matter
   array%(100) = 255            'Set highest element to 255
   PRINT array%(100)            'Print highest element, yields 255
   CALL SecondSub(array%())     'This is necessary for the error
   ERASE array%                 'Invalid function call generated
                                'here
   DIM array%(100)              'Re-dim array, set all elements to 0
   PRINT array%(100)            'Print highest element, yields 0
END SUB

SUB SecondSub(array%()) STATIC  'Array must be passed as parameter
   'Empty SUB                   'No code is required
END SUB
The correct output is as follows:

255 0

In the interpreter, only the first PRINT statement is executed because the ERASE statement generates the "Invalid function call" error. If the CALL to SecondSub is not executed, the rest of the code executes correctly.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB61404


WIDTH Statement Incorrectly Lists All Parameters as Optional (61658)

Summary

In the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual, the syntax description of the WIDTH statement does not follow the notational conventions used with the documentation.

The WIDTH statement syntax description on Page 353 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference") incorrectly shows that both "size" and ", printzone" are optional:

WIDTH [[size]] [[,printzone]]

When all parameters are optional, the statement should be legal with no parameters. In this case, "WIDTH" alone should be a legal statement according to the above syntax description, but that statement causes the following error:
Missing operand
The correct syntax description for the WIDTH statement is as follows:

WIDTH {size | ,printzone | size,printzone}

This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh.

More information

The following section of the "Typographical Conventions" description from Page 7 of "Microsoft QuickBasic for Apple Macintosh: User's Guide" defines the notations used in the documentation:
   [[optional item]]    Items inside double square brackets are
                        optional.
   {choice1 | choice2}  Braces and a vertical bar indicate a choice
                        between two or more items. You must choose one
                        of these items unless all of the items are
                        also enclosed in double square brackets.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB61658


Scroll Bar Toolbox Routines for Use Only with ScrollText (61677)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    The scroll bar Toolbox Library statements included with Macintosh QuickBasic are designed to be used with the ScrollText routine and are not designed as general purpose scroll bar routines.

    This information applies to Microsoft QuickBasic 1.0, 1.0a, and 1.0b for the Apple Macintosh.

    More information

    The scroll bar routines ActiveScroll, DisposeScroll, GetScrollValue, HideScroll, MoveScroll, NewScroll, SetScrollValue, and ShowScroll are all designed to be used with ScrollText.

    When you drag the scroll button in a scroll bar, the Macintosh can automatically return a value for the scroll bar based on the minimum and maximum values for the scroll bar.

    When a mouse click is detected on either the scroll button, or in the scroll bar, the distance to scroll needs to be defined by the program. This is accomplished in other languages by defining special scroll bar handling routines that are called when a mouse click is detected in either of these areas. However, as stated on page 492 of the "Microsoft QuickBasic for the Apple Macintosh: Language Reference":

    A click anywhere in the scroll bar (the bar, the arrows, or the scroll box) is not detected by QuickBasic as a mouse or dialog event.

    This means that in QuickBasic, no processing can be done for a click in any of these areas. QuickBasic is able to update the scroll value only by moving the scroll bar button. To work around this limitation, ScrollText has special handling routines to trap and process mouse clicks on the scroll arrows and in the scroll box.

    In place of these routines, a scroll box can be created by dynamically drawing each piece of the scroll bar. Mouse clicks can then be trapped and processed in these areas. In effect, a routine is created that simulates creating a scroll bar and doing what the toolbox routines would do.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB61677


BUG: Mac QB Forgets Clip Region When Changing Between Windows (62271)

Symptoms

The QuickBasic MBLC routine SetClip can be used to set the clipping region for the current output WindOW and GraphPort. However, if a clipping region is set in one WindOW, and the active window is then changed to a different WindOW, the clipping region set for the previous WindOW will be "forgotten." The example below demonstrates this behavior.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

More information

To work around the problem, reset the clipping region whenever you set a WindOW to be the active WindOW again. For example, in the code example below, SetClip is used in WindOW 1. WindOW 2 is then set to the current WindOW. Then WindOW 1 is made the current WindOW again. When WindOW 1 becomes the current WindOW again, SetClip should be used to reset the clipping region.

This following code example demonstrates the problem. To show the workaround, uncomment the line marked as the workaround.

Code Example

ScreenWidth% = SYSTEM(5)
ScreenHeight% = SYSTEM(6)
CenterX% = ScreenWidth% / 2
CenterY% = ScreenHeight% / 2
x1% = CenterX% /4 : x2% = CenterX% - 40
y1% = CenterY% /2 : y2% = CenterY% + 20

WindOW 2, "window 1",(CenterX%, 20) - (ScreenWidth%,_
           ScreenHeight%), 7
WindOW 1, "window 1",(20, 20)-(CenterX%,_
           ScreenHeight%), 5

' Set a small, square clipping region
CALL SetClipRegion(x1%, y1%, x2%, y2%)

'Draw lines to show the boundaries of the clip region
'Lines are drawn only within the clip region
FOR n = 1 TO 100
  LINE (1, n * 4)-(ScreenWidth%, n * 4)
NEXT n
' Toggle between the windows.
WindOW 2
INPUT "HIT RETURN TO Continue", a$
WindOW 1

'***** Uncomment the following line to show the workaround ****
'  CALL SetClipRegion(x1%, y1%, x2%, y2%)
'**************************************************************
' Draw Circles to show the current clip region
x1% = CenterX% / 2
FOR I = 1 TO 30
  Circle (x1% , CenterY%), I * 5
NEXT I
INPUT "HIT RETURN TO EXIT THE ProgRAM", a$

WindOW CLOSE 1
WindOW CLOSE 2

END

SUB SetClipRegion(x1%, y1%, x2%, y2%) STATIC
     R& = 0 : SetRect c%(0), x1%, y1%, x2%, y2%
     NewRgn R& : OpenRgn
     FrameRect VARPTR(c%(0))
     CloseRgn R&
     SetClip R&
     DisposeRgn R&
END SUB
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB62271


BUG: Can't Drag Window Across Two Monitors in Compiled Program (62951)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Symptoms

    If you are using a Macintosh system with two or more monitors, you cannot drag the window between them. This problem occurs only with a compiled application.

    Microsoft has confirmed this to be a bug in Microsoft QuickBasic version 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

    More information

    When you try to drag a window across the border of any two monitors, the window stops moving at the screen border. You can push the window across this border, but you cannot completely move it to the second monitor.

    Even though the portion of the window that is now on the second monitor is active, you cannot grab the window and pull it all the way over. Clicking in the window or displaying text or graphics will function properly.

    Under the QuickBasic interpreter, grabbing the window and dragging it completely across to a second monitor works correctly.

    The following sample code will demonstrate this problem if you are using a multimonitor system:
       WindOW 1,"Drag Test",(200,200)-(400,400)
   'You can display text or graphics here if you want
   WHILE Mouse(0) <> 0 : WEND
   WindOW CLOSE 1
   END
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB62951


EOF(n) Returns True on Random File Until GET Is Executed (63002)

The information in this article applies to:
  • Microsoft Basic Compiler 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    This article provides detailed information on the behavior of the EOF function on a random-access file in QuickBasic and Basic programs for the Apple Macintosh.

    When the Random file is first opened, the EOF function always returns -1 (true). EOF returns -1 until a GET statement is executed. Once the first GET statement is executed, EOF returns 0 (false) if the GET statement finds a record. EOF returns -1 (true) if there are no more records left in the file or if the last GET statement was unable to read an entire record.

    This information applies to Microsoft Basic Interpreter versions 2.00, 2.10, and 3.00, to Microsoft Basic Compiler 1.00, and to Microsoft QuickBasic 1.00 for the Apple Macintosh.

    More information

    Since the EOF function always returns a true value until a GET statement is executed, you will only want to test for the EOF condition after an attempt has been made to read a random-access record. If you open the file and test for the EOF condition without first reading in a record, the EOF function returns a true value even if there are more records to be read.

    The following program duplicates this behavior. The program opens a random file and puts an integer value into the file. It then closes this file, reopens it, and checks for an EOF condition. If the GET statement is commented out, EOF returns a true value even though the end of the file has not yet been reached and there are still valid records and valid data in the file.
       CLS
   OPEN "BOB.DAT" FOR OUTPUT AS #1 'Create a file to be opened later
   CLOSE #1                        'in the program for random-access.

   OPEN "BOB.DAT" AS #1 LEN = 2    'Put an integer into the file.
   FIELD #1, 2 AS var1$
   LSET var1$ = MKI$(5)
   PUT #1, 1
   CLOSE #1

   OPEN "BOB.DAT" AS #1 LEN = 2    'Open the file again to check for EOF.
   FIELD #1, 2 AS var1$

   'GET #1, 1                      'If this line is commented out, EOF
                                   'returns true even though there
                                   'are still records to be read.

   IF EOF(1) THEN PRINT "End of File"
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB63002


CALL PenMode & Pensize Work with CALL LINE, Not Circle or LINE (63160)

The information in this article applies to:
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft Basic Compiler 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    The LINE, Circle, and PSET statements in QuickBasic always have a 1-pixel width and a Copy masking mode, and are not affected by the CALL Pensize, CALL PenMode, or CALL Penpattern ROM routines.

    If you want routines that are affected by CALL Pensize, CALL PenMode, or CALL Penpattern, you can use CALL LINE (or CALL Lineto), CALL FrameOval, or other ROM routine CALLs.

    This information applies to Microsoft QuickBasic 1.00 for the Apple Macintosh, to Microsoft Basic Interpreter versions 2.00, 2.10, and 3.00 for the Apple Macintosh, and to Microsoft Basic Compiler version 1.00 for the Apple Macintosh.

    More information

    Note that CALL LINE (Page 389) is a ROM routine, whereas the LINE statement (Page 177) is part of the QuickBasic language (in the "Microsoft QuickBasic for Apple Macintosh: Language Reference").

    The following code segment is a modification of the sample program on Page 395 of the "Microsoft QuickBasic for Apple Macintosh: User's Guide." The program prints the eight PenModes (Copy, OR, XOR, BIC, NOT Copy, NOT OR, NOT XOR, NOT BIC, respectively numbered 8 through 15) on the screen, giving an example of each with the Lineto ROM call and the LINE statement.

    Code Example

       DEFINT a-z
   DIM pattern(3)
   LINE (200,10)-(300,250),,bf  '
   FOR y = 10 to 250 step 2     'create a background for drawing
     LINE (300,y)-(400,y)       '
   NEXT

   FOR i = 0 to 3 : READ pattern(i) : NEXT  'create the pen pattern
   DATA -32446,9240,6180,17025

   CALL Penpat(VARPTR(pattern(0)))  'set up the pen pattern
   CALL Pensize (12,12)             'set up the pen size
   mode = 8

   FOR y = 20 to 230 step 30
    CALL PenMode(mode)              'set up the pen mask
    CALL MoveTo(1,y+8)
    READ mode$ : PRINT mode mode$   'print the mask #,type
    CALL MoveTo (100,y)
    CALL Lineto (400,y)             'draw a line with the pen
    LINE (100,y+2)-(400,y+2)        'show that LINE statement won't draw it
    mode = mode + 1
   NEXT
   WHILE Mouse(0) <> -1 : WEND
   DATA " Copy"," OR",XOR,BIC,NOT Copy,Not OR,NOT XOR,NOT BIC
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB63160


LINE INPUT #1 Reads Up to 32,767 Characters into String (63621)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    Page 182 of "Microsoft QuickBasic for Apple Macintosh: Language Reference" incorrectly states that 1023 is the maximum number of characters that can be read by the LINE INPUT # statement. LINE INPUT # can actually read up to 32,767 characters (the maximum string length).

    More information

    The maximum number of characters for LINE INPUT # in Microsoft Basic Compiler 1.0 for Macintosh was 1023. This limit was increased to 32,767 with Microsoft QuickBasic 1.0 for the Macintosh.

    If more than 32,767 characters are on a line read with LINE INPUT #, the characters from 32,768 to the end of the line are lost.

    Note: The LINE INPUT # statement treats a carriage return character (ASCII byte value 13) as the end of an input line.

    "The Waite Group's Microsoft QuickBasic Bible" (published by Microsoft Press, 1990) also incorrectly states on page 599 that QuickBasic for the Macintosh has a limit of 1023 characters in a LINE INPUT # statement. The limit is 32767 characters.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB63621


Macintosh QuickBasic 1.00a Disk Contents; Released Through PSS (64013)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a

    • Summary

    This article gives the disk contents for Microsoft QuickBasic 1.00a for the Apple Macintosh.

    The 1.00a Program disk just replaces the programs listed below on the version 1.00 Program disk. The "ReadMe 1.00a" file briefly mentions the corrected System error problem that occurs when running compiled programs on a Macintosh IIci, IIcx, or IIfx.

    More information

    Disk Contents for QuickBasic 1.00a (One Program Disk)

       Contents                   Description
   --------                   -----------

   File Browser               Utility to read and print Text files
                              (such as "ReadMe 1.00a")

   Microsoft QuickBasic (b)   Binary math QuickBasic 1.00a

   Microsoft QuickBasic (d)   Decimal math QuickBasic 1.00a

   ReadMe 1.00a               This text file says a problem was
                              corrected on Macintosh IIci, IIcx, and
                              IIfx. (This supplements, but does NOT
                              replace, the "ReadMe" file for 1.00.)

   Run-Time Folder
   ---------------

   QB10.bl                    1.00a Binary math external run time

   QB10.cl                    1.00a 68881 coprocesser-math external
                              run time

   QB10.dl                    1.00a Decimal math external run time

    Why Version 1.00a Was Released

    Microsoft QuickBasic 1.00a corrects a problem where programs compiled with the Use Default Window option in 1.00 can fail at run time with a System error (bomb) ID=1 on the Macintosh IIci, IIcx, and IIfx. For an article describing this problem and its workarounds, query in this Knowledge Base on the following words:

    IIci and IIcx and IIfx and QuickBasic

    QuickBasic 1.00a was released specifically to correct only this problem. Version 1.00a may be obtained by calling Microsoft Technical Support (Version 1.00a is not available through the Microsoft Customer Service Department.)
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB64013


GetDirName Works Only for Boot Drive in Macintosh QuickBasic (64104)

Summary

The GetDirName Toolbox Library (MBLC) routine correctly returns the folder name (commonly called the pathname) when given a volume reference number of either -1 or 0. Different numbers representing other drives either give the error message "String Too Long" if a device is present and being used, or a null or meaningless string if the boot drive is the only device active.

Microsoft has confirmed this to be a problem in Microsoft QuickBasic version 1.00 for Apple Macintosh. We are researching this problem and will post new information here as it becomes available.

More information

When a hard or floppy disk is used in a Macintosh computer, the Finder displays an icon in the upper-right corner to indicate its presence. A hidden integer value is also assigned to the device in a field of a record structure that defines, among other things, available storage areas to the machine. These integer values can be used in a program to refer to that device. The standard set of assigned values starts at -1 and decrements by 1 for each additional device in the order the devices are provided to the machine.

The QuickBasic MBLC routine GetDirName will return the boot folder name only. Any other device known to the Finder (via an assigned device number) will not be correctly identified by the GetDirName function call. To find other volume names, Toolbox calls found in the "Inside Macintosh" series by Apple Computer (published by Addison-Wesley) must be used.

The following code sample demonstrates the GetDirName problem:

Sample Code

x$ = ""            REM  Initialize the string for the toolbox call
GetDirName -1, x$  REM  Returns the boot volume name to x$
PRINT x$
GetDirName -2, x$
REM  This function call should return the second volume name listed in
REM  the Finder window to x$. However, if there is no disk icon
REM  present, a null or useless string will be returned, and, if a
REM  device is present, the error message "String Too Long" is
REM  displayed.
PRINT x$
INPUT "Done, hit return";  x$
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB64104


BUG: QuickBasic Interpreter Allows Duplicate Line Numbers (64431)

Symptoms

The interpreter in Microsoft QuickBasic for Macintosh incorrectly allows duplicate numeric line labels within a program.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic versions 1.00 and 1.00a for Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

At compile time, the compiler in QuickBasic correctly gives the "Duplicate label" error for duplicate line numbers. Note that the interpreter in QuickBasic correctly gives the error "Duplicate label" if the label begins with an alphabetic letter (A through Z). In other words, the problem occurs in the interpreter for duplicate line numbers, but not for duplicate alphanumeric labels.

More information

Because the QuickBasic interpreter's line number parser fails to check for duplicates, an unlimited number of lines with the same line number are incorrectly allowed. A GOTO or GOSUB to the repeated line number results in control being passed to the first occurrence of the repeated line number. (Compiling the program correctly gives a "Duplicate label" error.)

The following program, when run in interpretive mode, demonstrates the problem:
   Code Example
   ------------

   10 GOSUB 37
   20 END
   37 PRINT "Hello"
   37 PRINT "World"
   100 ' An intermixed line number to better illustrate the problem.
   37 PRINT "How are you doing?"
   50 RETURN
Note that QuickBasic does not order lines that have line numbers; for example, line 50 can follow line 100 without any numeric order enforced. No line-numbering order is enforced because line numbers are merely another form of line label in the QuickBasic language.
   Output from Example
   -------------------

   Hello
   World
   How are you doing?
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB64431


How to Define a String Array in FIELDs in a FOR...Next Loop (64498)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft QuickBasic for Ms-Dos 4.00
  • Microsoft QuickBasic for Ms-Dos 4.0B
  • Microsoft QuickBasic for Ms-Dos 4.50
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.10
  • Microsoft GW-Basic 3.2
  • Microsoft GW-Basic 3.22
  • Microsoft GW-Basic 3.23

    • Summary

    Below is an example of defining a string array in multiple FIELD statements invoked in a FOR ... NEXT loop.

    Code Example

    (Note: To run this program in GW-Basic, you must add a line number to each line.)
    OPEN "test.dat" AS #1 LEN = 300
DIM F$(30)
i = 1
FOR j = 1 TO 10
FIELD #1, (j - 1) * 30 AS temp$, 10 AS F$(i), 10 AS F$(i + 1), 10 AS F$(i +
2)
i = i + 3
NEXT
LSET F$(30) = "1234567890"
LSET F$(15) = "ABCDEFGHIJ"
PUT #1, 1
CLOSE

OPEN "test.dat" AS #1 LEN = 300
i = 1
FOR j = 1 TO 10
FIELD #1, (j - 1) * 30 AS temp$, 10 AS F$(i), 10 AS F$(i + 1), 10 AS F$(i +
2)
i = i + 3
NEXT
GET #1, 1
PRINT F$(30), F$(15)

    References

    For more information about alternatives to multiple FIELD statements in the latest Microsoft Basic products, query for a separate article in this Knowledge Base using the following words:

    Long and FIELD and 255

    Microsoft Basic PDS 7.00 and 7.10 for Ms-Dos and MS OS/2 introduce the ability to have arrays in user-defined TYPEs, which allows you to write an array to disk all at once. For more information, query for a separate article in this Knowledge Base using the following words:

    Random and Binary and PUT and Array and TYPE

    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB64498


BUG: Macintosh QuickBasic Listing Window Corrupted During Edit (65936)

Symptoms

Modifying the sample code below can corrupt the code displayed in the Listing window. This problem occurs after you first run the program and then try to make changes. This problem occurs only in this specific program; thus, it is very rare.

If the Listing window becomes corrupted, exit QuickBasic without saving and then re-enter QuickBasic. You can now safely reload the program. The program will be safe on disk as long as you don't Save after the Listing window becomes corrupted.

Microsoft has confirmed this problem in Microsoft QuickBasic 1.00 and 1.00a for the Macintosh . We are currently researching this problem and will post new information here as it becomes available.

More information

To demonstrate this problem, do the following:

  1. Run the program.
  2. Press Enter and the program will dimension the array.
  3. Stop the program by pressing Command+PERIOD (or select Stop from the File menu).
  4. Modify the following line:

    m=17543:n=2

  5. This line will now become garbage.
You can also attempt to modify other parts of the code and the same type of problem will occur.

The exact line spacing shown below is significant in this problem. Changing the line spacing or modifying the code in other ways may cause the problem to go away. For example, adding REM to the blank lines and then following the steps described above will not demonstrate the problem.

Note: The first three lines at the top of the program must all be blank and subsequent blank lines, such as the seven blank lines in the middle, must be entered as shown in order to duplicate the problem.

Sample Code

DEFDBL a-z

GOSUB menusub
WHILE INKEY$="":WEND
PRINT "dimming"
m=17543:m=2
DIM a(m)
PRINT "hi"
GOSUB menusub
WHILE -1:WEND

menusub:
a$=a$+"4.1"
Menu 1,0,1,"menu1"
Menu 1,1,1,"1.1"
Menu 1,2,1,"1.2"
Menu 2,0,1,"menu2"
Menu 2,1,1,"2.1"
Menu 2,2,1,"2.2"
Menu 3,0,1,"menu3"
Menu 3,1,1,"3.1"
Menu 3,2,1,"3.2"
Menu 4,0,1,"menu4"
Menu 4,1,1,"4.1"
Menu 4,2,1,"4.2"
Menu 5,0,1,"menu5"
Menu 5,1,1,"5.1"
Menu 5,2,1,"5.2"
RETURN
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB65936


Macintosh QuickBasic PrintVerRec Code Resource Prints Garbage (65937)

Summary

When using the PrintVerRec pure code resource example to print out the contents of Basic's version record, the information returned is garbage.

You can correct this problem by copying the STR# resource from TestPcr.Lsc to QuickBasic or to the PrintVerRec resource using ResEdit, as described below.

This information applies to Microsoft QuickBasic 1.00 and 1.00a for the Apple Macintosh.

More information

The version record, Verrec, provides your library routines with information about the QuickBasic program calling them. Page 456 of "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual describes the information that the version record contains.

The pure code resource, PrintVerRec, uses the STR#9999 resource, which is in the TestPcr.Lsc example. PrintVerRec.c can be found in "User Libraries:MBPC Rsrcs:LSC PCR". TestPcr.Lsc can be found in "User Libraries:MBPC Rsrcs:TestPCR". PrintVerRec uses the STR#9999 resource to display the information from the print record. Without this resource, PrintVerRec will start displaying whatever information is located at the memory location where it looks for the STR#9999 resource.

You can correct this problem by copying the STR# resource from TestPcr.Lsc to QuickBasic or to the PrintVerRec resource using ResEdit.

  1. OPEN TestPcr.Lsc using ResEdit.
  2. Select the STR# resource with a single click.
  3. Choose Copy from the Edit menu.
  4. Open Microsoft QuickBasic (b) or (d), or your code resource.
  5. Choose Paste from the Edit menu.
  6. Exit ResEdit, choosing OK to save the file.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB65937


ToolBox Statement with Wrong Array Can Corrupt Listing or Hang (65938)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a

    • Summary

    You must be careful to pass the correct number of array elements to QuickBasic's ToolBox statement when passing or receiving data.

    You can easily cause a system error, hang, or garbage in the QuickBasic Listing window if you pass incorrect parameters or arrays to the ToolBox statement in QuickBasic for Macintosh. (You must usually restart the Macintosh after a System bomb.)

    The garbage in the Listing window will not be written to your program as long as you do not Save after the program was corrupted. If you see garbage in the Listing window, you should exit without saving, restart QuickBasic, and reload your source file (which will be restored to its condition at the last Save).

    ToolBox, which is an MBLC routine built into QuickBasic, is a powerful statement that lets you make many Macintosh ROM traps; however, you must be careful to pass only the correct parameters to ToolBox.

    This information applies to Microsoft QuickBasic 1.00 and 1.00a for the Apple Macintosh system.

    More information

    Problems can occur especially when using an array to represent a record structure or hold rectangle coordinates. If the array is not dimensioned to the proper size, it is possible for initialized arrays or arrays returned from the ToolBox call to overwrite the symbol table or other parts of memory.

    For example, many ROM trap routines require an array as an argument. When you use an array to hold the coordinates of a rectangle, you must dimension the array to have exactly four elements. If you are using the default OPTION BASE 0, then you must DIM rect%(3), which gives you four elements; rect%(0) through rect%(3). If you are using OPTION BASE 1, you must DIM rect%(4), which gives you four elements; rect%(1) through rect%(4).

    If you dimension the array with DIM rect%(4) and fail to use OPTION BASE 1, the actual number of elements that you have will be five elements; rect%(0) through rect%(4). This extra element can overwrite the symbol table, the Listing window, or other parts of memory.

    This problem can also occur for any ToolBox call that requires information to be returned into a record structure, such as a grafport. If you don't dimension an array large enough to store all the data returned, this extra data can overwrite memory, giving the same problems.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB65938


BUG: Macintosh 1000x1000 WindOW Snaps Back to Smaller Size (65939)

Symptoms

When you increase the size of a 1000x1000 window in QuickBasic using the grow box, the window will snap back to a size smaller than 1000x1000. This problem applies only to a two-monitor system where QuickBasic's WindOW statement can cause a window to be 1000x1000 pixels.

Microsoft has confirmed this to be a bug with Macintosh QuickBasic versions 1.00 and 1.00a for the Macintosh system. We are researching this problem and will post new information here as it becomes available.

More information

Trying to increase the window to greater than 1000x1000 will not work as a solution; the window will snap back to approximately 984x999. This was tested on a two-monitor system, so a 1000x1000 window could be displayed.

Sample Code

   WindOW 1, "Large Window", (1,1)-(1000,1000),1
   WHILE Mouse(0)<> 1:WEND
   END
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB65939


No BasicLib.obj in Macintosh QuickBasic, Use BasicLib.Lib (65940)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.0a

    • Summary

    Page 451 of the "Microsoft QuickBasic for Macintosh: Basic Language Reference" manual contains a documentation error that states that you must link with BasicLib.obj to create a pure-code resource in MPW Pascal. There is no file called BasicLib.obj on the QuickBasic 1.00 distribution disks, nor do you need such a file.

    The correct file to use is BasicLib.Lib, which is on the Examples Disk in the following folder:

    Examples:User Libraries:MBPC Rsrcs:PCR Lib Src

    This information applies to Microsoft QuickBasic 1.00 and 1.00a for Apple Macintosh Systems. Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB65940


BUG: Divide by Zero Hangs on SE/30 If Compiled w/ 68881 Option (65941)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a

    • Symptoms

    Dividing by zero in a Macintosh QuickBasic (b) (binary math version) program compiled with the "Generate 68881 Code" option can cause a Macintosh SE/30 (with a 68881 installed) to hang. The problem does not occur on a Macintosh II computer with a 68881 installed.

    Microsoft has confirmed this problem in Microsoft QuickBasic 1.00 and 1.00a for the Macintosh Systems. We are researching this problem and will post new information here as it becomes available.

    More information

    This information does not apply to QuickBasic interpreted programs, which cannot take advantage of the 68881 math coprocessor. This information also does not apply to programs compiled in the decimal math version, Microsoft QuickBasic (d).

    The following program, when compiled with the "Generate 68881 Code" option (from the Options command in the Run menu) causes the computer to hang after a key is pressed. This was tested on a Macintosh SE/30. A Macintosh II did not hang; instead, error 11 was correctly generated.

    Sample Code

       PRINT "before"
   WHILE INKEY$ = "" : WEND
   X = 0
   PRINT 1/X
   PRINT "after"
   WHILE INKEY$ = "" : WEND
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB65941


BUG: Zero to Zero Power Returns Bad Result If Compiled w/68881 (65942)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a

    • Symptoms

    If a program is compiled with the "Generate 68881 Code" option under QuickBasic (b) (binary math version) and it attempts to raise 0 (zero) to the power of 0 (zero), the program will return 0 (zero) instead of the correct answer, which is 1.

    Microsoft has confirmed this to be a bug with Microsoft QuickBasic versions 1.00 and 1.00a for Macintosh systems. We are researching this problem and will post new information here as it becomes available.

    More information

    If the sample program below is compiled with the "Generate 68881 Code" option (from the Options command in the Run menu of QuickBasic binary math version), the program will return an erroneous result (0). If the program is run inside the QuickBasic interpreter environment, the program runs properly and the correct result is 1.

    The program fails only under the two conditions shown below, where X=0 and Y=0:
       Y ^ X    or    0 ^ X
    Note that the expression 0^0 works correctly.

    Sample Code

    X= 0
Y= 0
PRINT "Y^X ",Y ^ X   'Zero raised to the power of zero gives problem.
PRINT "0^X ",0 ^ X   'This form also produces the problem.
PRINT "0^0 ",0 ^ 0   'This works.
WHILE INKEY$ = "" : WEND
END
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB65942


Correction to QuickBasic AllocString Function Prototype (66228)

Summary

The AllocString library support routine is incorrectly documented on Page 458 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference." The documentation incorrectly shows the function prototypes as follows:

Pascal:
   Procedure AllocString(VAR thestring: SdRecPtr; length: INT16);
C:
   pascal void AllocString(thestring, length);
   SdRecPtr thestring;
   INT16 length;
These incorrectly show "thestring" as type SdRecPtr, when it should be of the type StringPtr. The correct prototypes are shown below:

Pascal:
   Procedure AllocString(VAR thestring: StringPtr; length: INT16);
C:
   pascal void AllocString(thestring, length);
   StringPtr *thestring;
   INT16 length;
This information applies to Microsoft QuickBasic 1.00 for Apple Macintosh Systems. Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB66228


BUG: Circle(x,y),rad,,-0.1,0 Draws Only the Radius in Basic (67374)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0e
  • Microsoft QuickBasic for Ms-Dos 4.00
  • Microsoft QuickBasic for Ms-Dos 4.0B
  • Microsoft QuickBasic for Ms-Dos 4.50
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.10

    • Symptoms

    The Circle command takes the following parameters:
       Circle[STEP](x,y),radius!,,start!,stop!
    If you specify a start! value that is slightly larger than stop!, the Circle command should draw an almost complete circle. However, if the difference between start! and stop! is very small, Circle may draw only a point or radius. This problem happens in the interpreter environment and in compiled programs.

    Status

    Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

    More information

    Changing the size of radius changes the requirement for the distance between start! and stop! necessary to reproduce the problem. When start! is near zero, leaving off the stop! produces different results from those obtained when stop! is specified. Use the following code examples to reproduce the problems described above.

    Code Examples

    ' When start! or stop! is negative, Circle draws a radius and
' treats the angle as positive. Without the negative sign, no
' radius is drawn.
'
Screen 12  'Problem occurs in any graphics screen mode.
10 Circle (50, 50), 50, , -.01         'Works correctly.
20 Circle (50, 150), 50, , -.01, 0     'Should be same as line
                                       '10 but draws only the radius.
30 Circle (50, 250), 50, , -.011, 0    'Slightly larger difference
                                       'from start & stop works.
40 Circle (420, 240), 200, , -.01, 0   'This works with same end/start
                                       'as line 20 but has larger
                                       'radius
    On the Apple Macintosh, use the following code:
    Circle (50, 50) 10, ,-0.001, 0
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB67374


Macintosh QuickBasic Converts "Clip: " Clipboard Tabs to Commas (67377)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    When reading from the "Clip:" clipboard device in QuickBasic for the Apple Macintosh, any tab characters in the clipboard will be converted to commas. This is not a problem in QuickBasic but a feature that allows the easy transfer of data from word processors, spreadsheets, and other applications that use the tab character to separate data elements. To read the text exactly as it was cut or copied into the clipboard, open the "Clip:Text" device instead.

    This information applies to QuickBasic for the Apple Macintosh versions 1.00, 1.00a, and 1.00b.

    More information

    Note that tab characters have an ASCII value of 9.

    When the following statement is used to open the clipboard for input, strings input using INPUT$ or LINE INPUT #1 will be read with tab characters converted to commas:
       OPEN "clip:" FOR INPUT AS #1
    Because the INPUT # statement reads strings separated by commas one at a time, the INPUT # statement can easily parse blocks of text clipped from tabular forms, such as spreadsheets or word processor tables.

    If the following statement is used to open the clipboard for input, strings will be input with tabs left intact:
       OPEN "clip:text" FOR INPUT AS #1
    For additional information on the "Clip:" device and other generalized I/O devices, see page 123 in the "Advanced Topics" section of the "Microsoft QuickBasic For Apple Macintosh: User's Guide."
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB67377


"Illegal Function Call," Negative Number to Fractional Power (67887)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft Basic Compiler 1.0, when used with:
  • the operating system: Mac OS (all versions)
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft QuickBasic for Ms-Dos 4.00
  • Microsoft QuickBasic for Ms-Dos 4.0B
  • Microsoft QuickBasic for Ms-Dos 4.50
  • Microsoft QuickBasic for Ms-Dos 5.0
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.10
  • Microsoft GW-Basic Interpreter 3.20
  • Microsoft GW-Basic Interpreter 3.22
  • Microsoft GW-Basic Interpreter 3.23

    • Summary

    Raising a negative number to a fractional power gives an "Illegal function call" in Basic because the result will be a complex number, which is not supported in Basic. (A complex number is of the form x+y*i where x is the real component and y is the imaginary component; i is the square root of -1.)

    Note: -5^(-Y) is not the same as X^(-Y) when X = -5 because -5^(-Y) is actually parsed as -(5^(-Y)). In other words, the exponentiation operator (^) has greater precedence than the subtraction (-) operator.

    This information applies to most versions of Microsoft Basic, including the following:

    1. Microsoft QuickBasic 1.00 for the Apple Macintosh.
    2. Microsoft Basic Compiler 1.00 for the Apple Macintosh.
    3. Microsoft Basic Interpreter versions 1.00, 1.01, 2.00, 2.10, and 3.00 for the Apple Macintosh.
    4. Microsoft QuickBasic 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.0B, 4.50 for Ms-Dos.
    5. Microsoft Basic Compiler 5.35 and 5.36 for Ms-Dos.
    6. Microsoft Basic Compiler 6.00 and 6.0B for MS OS/2 and Ms-Dos.
    7. Microsoft Basic PDS 7.00 and 7.10 for Ms-Dos and MS OS/2.
    8. Microsoft GW-Basic Interpreter versions 3.20, 3.22, 3.23 for Ms-Dos.

    More information

    The first PRINT statement below gives "Illegal function call." Many programmers will try debugging this code by substituting an actual constant for X, and the PRINT will seem to give the correct result. However, upon close examination of the precedence of operators, it will be apparent that the exponential symbol takes precedence over the minus sign. The expression 5^(-1/6) is parsed first and then the negation of this expression is performed. The third PRINT demonstrates what is actually happening in the first PRINT statement:
    X = -5
PRINT X ^ (-1 / 6)       ' generates "Illegal function call"
PRINT -5 ^ (-1 / 6)      ' same as PRINT -(5 ^ (-1 / 6)); no error
PRINT (-5) ^ (-1 / 6)    ' generates "Illegal function call"
    To avoid the "Illegal function call" message, raise the absolute value (ABS) of X to the fractional power. If you do this when X is a negative number, please remember that you must multiply by i (the square root of -1) to get the true mathematical result. Because the square root of -1 cannot be represented in Basic, you must keep track of imaginary number results yourself using a flag variable or warning message, for example:
       X=-5
   PRINT ABS(X) ^ (-1 / 6)
   IF SGN(X) < 0 THEN
      PRINT "Warning: the resulting root is an imaginary number. This"
      PRINT "root should be multiplied by i, the square root of -1."
   END IF
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB67887


Basic Can Write Files for MS Excel Spreadsheet (68122)

The information in this article applies to:
  • Microsoft QuickBasic 1.00
  • Microsoft QuickBasic 1.01
  • Microsoft QuickBasic 1.02
  • Microsoft QuickBasic 1.0a
  • Microsoft QuickBasic 1.0b
  • Microsoft QuickBasic 2.0
  • Microsoft QuickBasic 2.01
  • Microsoft QuickBasic 3.00
  • Microsoft QuickBasic 4.00
  • Microsoft QuickBasic 4.0B
  • Microsoft QuickBasic 4.50
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.10
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b
  • Microsoft Basic Compiler 1.00
  • Microsoft GW-Basic Interpreter 3.20
  • Microsoft GW-Basic Interpreter 3.20 and later
  • Microsoft GW-Basic Interpreter 3.22
  • Microsoft GW-Basic Interpreter 3.23

    • Summary

    Microsoft QuickBasic can manipulate ASCII text files used by Microsoft Excel in either comma separated values (CSV) or tab separated values (Text) file formats.

    QuickBasic can generate these file formats with the standard Basic statements OPEN, CLOSE, PRINT, and WRITE.

    This information applies to Microsoft QuickBasic 1.00, 2.00, 3.00, 4.00, 4.0B, and 4.50 for Ms-Dos; Microsoft Basic Compiler versions 6.00 and 6.0B for Ms-Dos and MS OS/2; Microsoft Basic PDS 7.00 and 7.10 for Ms-Dos and MS OS/2; Microsoft Basic Interpreter versions 2.00, 2.01, and 3.00 for Apple Macintosh; Microsoft QuickBasic 1.00 and 1.00b for Apple Macintosh; Microsoft Basic Compiler 1.00 for Apple Macintosh; and GW-Basic Interpreter versions 3.20, 3.22, and 3.23 for Ms-Dos.

    More information

    Microsoft Excel supports two Text file formats: tab (Text) files, and comma (CVS) delimited files. Both of these files contain the textual information in each cell, no formulas, and a delimiter between each column and a carriage return plus linefeed (CR/LF) at the end of each row on Ms-Dos computers (but just CR ending each row on Macintosh computers).

    Tab delimited files have a tab character separating each column. To generate a tab character in Basic, use the CHR$() function with a parameter of 9. For example,
       Tab$ = CHR$(9)
    Comma delimited files have a comma character separating each column. There are several ways to generate a comma in the output file. One way is to use Basic's CHR$() function with a parameter of 44. For example,
       Comma$ = CHR$(44)
    If a cell contains a comma, the value from the cell will be enclosed in double quotation marks. In Basic, you can use the WRITE command to place an item in double quotation marks.

    Basic Code Example

            REM ** Create a Comma Delimited File **
        Comma$ = CHR$(44)
        OPEN "Excel.Cvs" FOR OUTPUT AS #1
        PRINT #1, "Employee Information"
        PRINT #1, " "
        PRINT #1, "First"; Comma$; "Last Name"; Comma$; "Age"
        PRINT #1, " "
        PRINT #1, "Loren"; Comma$; "Moe"; Comma$; 35
        PRINT #1, "Arthur"; Comma$; "Nelson"; Comma$; 21
        PRINT #1, "George"; Comma$; "Merriman";Comma$; 30
        PRINT #1, " "
        CLOSE #1

        REM ** Creates a TAB Delimited File **
        Tab$ = CHR$(9)
        OPEN "Excel.Txt" FOR OUTPUT AS #2
        PRINT #2, "Employee Information"
        PRINT #2, " "
        PRINT #2, "First"; Tab$; "Last Name"; Tab$; "Age"
        PRINT #2 " "
        PRINT #2, "Loren"; Tab$; "Moe"; Tab$; 35
        PRINT #2, "Arthur"; Tab$; "Nelson"; Tab$; 21
        PRINT #2, "George"; Tab$; "Merriman"; Tab$; 30
        PRINT #2, " "
        CLOSE #2
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB68122


BUG: Multiple TIMER ON Resets ON TIMER GOSUB in QuickBasic (69043)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Symptoms

    Whenever a TIMER ON statement executes in QuickBasic for Macintosh, the ON TIMER GOSUB timer is reset. When TIMER ON executes multiple times, this may cause the event trap to never execute, or execute slower than expected. The following program demonstrates this behavior.

    Microsoft has confirmed this to be a bug with Microsoft QuickBasic 1.00, 1.00a, and 1.00b for the Macintosh . We are researching this problem and will post new information here as it becomes available.

    (This problem does not occur with QuickBasic for Ms-Dos.)

    More information

    To work around the problem, execute the TIMER ON statement once during the time when you want to have the ON TIMER GOSUB active.

    The following program should jump to "trap:" once every second; however, because the TIMER ON statement is executed faster than once per second, the event trap never takes place. To make the program perform as expected, remove the TIMER ON statement in the WHILE... WEND loop.

    Code Sample

    ON TIMER(1) GOSUB trap
TIMER ON

WHILE INKEY$=""
   TIMER ON             ' remove this line
WEND
END

trap:
   i=i+1
   LOCATE 1,1
   PRINT i
   RETURN
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB69043


BUG: QuickBasic Can't Find: File Dialog Fails on System 6.0.7 (69113)

Symptoms

If a QuickBasic (for Macintosh ) program attempts to OPEN, RUN, or CHAIN a filename that does not exist in the current or specified folder, a dialog box prompts you with "Can't find: <filename>. Would you like to look for it?". When you click OK, you can normally look for the file in other folders; however, under Macintosh System 6.0.7, if you select the target file's folder from the dialog box, the file's name will not properly display.

Microsoft has confirmed this to be a bug with Microsoft QuickBasic versions 1.00, 1.00a, and 1.00b for Macintosh only when running under Macintosh System version 6.0.7 and Finder (or MultiFinder) version 6.1.7. The problem does not occur on other System or Finder versions.

Microsoft is researching this problem and will post new information here as it becomes available.

More information

You may use any of the following methods to work around this problem:

  1. Use a different version of the Macintosh System software, such as System 6.0.5. -or-

  2. Ensure that the complete and correct path is given to the file. -or-

  3. Ensure that the file is in the same folder as the QuickBasic environment (if running in the interpreter), or in the same folder as the compiled application (if running as a compiled application).
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB69113


BUG: Incomplete Edit Menu in QuickBasic 1.0b/1.0e Compiled Pgm (69161)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0e

    • Symptoms

    If you compile in Microsoft QuickBasic 1.0b or 1.0e for Apple Macintosh using the run-time options "Use Default Window" and "Use Default Menu," then the Edit menu in the compiled application will contain the usual Undo and Cut options but may be missing the Copy, Paste, and Clear options on certain Macintosh computer models.

    This happens only when running an application compiled under QuickBasic 1.0b or 1.0e on certain Macintosh computers (listed below). The problem does not occur for applications compiled under QuickBasic 1.0 and 1.0a. The problem does not occur in any version of the interpreter.

    Microsoft has confirmed this to be a bug in Microsoft QuickBasic for the Macintosh versions 1.0b and 1.0e. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

    More information

    This problem occurs only on certain Macintosh machines. Below is a list of machines, their configurations, and whether or not the problem occurs.
       Machine        System   Finder   No Problem     Problem
   -------        ------   ------   ----------     -------

   Mac Plus       6.0.4    6.1.4         X
   Mac SE         6.0.4    6.1.4         X
   Mac IIsi       6.0.7    6.1.7         X
   Mac SE/30      6.0.4    6.1.4                     X
   Mac II         6.0.4    6.1.4                     X
   Mac IIcx       6.0.7    6.1.7                     X
   Mac IIci       6.0.7    6.1.7                     X
   Mac Portable   6.0.5    6.0.5                     X
   Mac Quadra     7.0.0                              X
    To reproduce the problem, compile the file TextEdit, the program example included with QuickBasic. Compile TextEdit with the "Use Default Window" and "Use Default Menu" options, and run the application on one of the machines that demonstrates the problem.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB69161


Basic Uses Radians, Not Degrees, for Trigonometric Functions (69164)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b
  • Microsoft Basic Compiler 1.0, when used with:
  • the operating system: Mac OS (all versions)
  • Microsoft Basic Interpreter for Apple Macintosh 1.00
  • Microsoft Basic Interpreter for Apple Macintosh 1.01
  • Microsoft Basic Interpreter for Apple Macintosh 2.0
  • Microsoft Basic Interpreter for Apple Macintosh 2.1
  • Microsoft Basic Interpreter for Apple Macintosh 3.00
  • Microsoft QuickBasic for Ms-Dos 4.00
  • Microsoft QuickBasic for Ms-Dos 4.0B
  • Microsoft QuickBasic for Ms-Dos 4.50
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.00
  • Microsoft Basic Compiler for Ms-Dos and OS/2 6.0B
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.10
  • Microsoft GW-Basic 3.2
  • Microsoft GW-Basic 3.22
  • Microsoft GW-Basic 3.23

    • Summary

    You must pass angle measurements in radians (not degrees) to Basic's trigonometric functions (SIN, COS, and TAN).

    All versions of Microsoft Basic require radians for the built-in trigonometric functions (SIN, COS, TAN). Therefore, the value returned from Basic's SINe, COSine, and TANgent will be different than your calculator's value, unless your calculator is using radians.

    To convert degrees to radians, multiply the degrees by pi/180, where pi equals 3.14159265359.

    This information applies to the following Basic versions:

    1. Microsoft QuickBasic 1.00, 1.00a, and 1.00b for Apple Macintosh.
    2. Microsoft Basic Compiler 1.00 for Apple Macintosh.
    3. Microsoft Basic Interpreter versions 1.00, 1.01, 2.00, 2.10, and 3.00 for Apple Macintosh.
    4. Microsoft QuickBasic 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.0B, and 4.50 for Ms-Dos.
    5. Microsoft Basic Compiler 5.35 and 5.36 for Ms-Dos.
    6. Microsoft Basic Compiler 6.00 and 6.0B for Ms-Dos and MS OS/2.
    7. Microsoft Basic PDS 7.00 and 7.10 for Ms-Dos and MS OS/2.
    8. Microsoft GW-Basic Interpreter versions 3.20, 3.22, and 3.23 for Ms-Dos.

    Code Example

    'Radians = degrees * PI / 180
PI = 3.141593
X = 45
' The following prints .8509035, which is the SIN of 45 radians,
' which may not be what you wanted:
PRINT SIN(X)

' Now, convert X to radians before passing to the SIN function:
PRINT SIN(X * PI / 180)  'This gives .7071068 as the SIN of 45 degrees
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB69164


FIX: INT() Rounds Large Negatives Badly If Compiled in 1.00 (69165)

Symptoms

The INT() function in QuickBasic 1.00 for the Macintosh rounds large negative numbers incorrectly in compiled programs. This problem does not occur when programs are run inside the QuickBasic 1.00 interpreter environment.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic version 1.00 for the Macintosh . This problem is corrected by Microsoft QuickBasic 1.00a (and 1.00b).

More information

The following sample code demonstrates the incorrect results in a compiled program:

Sample Code

FOR i% = 1 TO 6
  A# = (((10^i%) * -1234#) + .5)
  PRINT A#, INT(A#)
NEXT i%

Incorrect Output Results

-12349.5         -12340
-123499.5        -123400
-1234999.5       -1234000
-12349999.5      -12339999
-123499999.5     -123399999
-1234999999.5    -1233999999

Expected Output Results

-12349.5         -12340
-123499.5        -123400
-1234999.5       -1234000
-12349999.5      -12340000
-123499999.5     -123400000
-1234999999.5    -1234000000
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB69165


How to Get a Macintosh File's Size Without Opening the File (69176)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    There are two methods to get the file size of an Apple Macintosh file through library calls in Microsoft QuickBasic 1.00, 1.00a, and 1.00b for the Apple Macintosh. These library calls are GetFileInfo and HFSDispatch, neither of which requires the file to be open. This article has an example of using each of these calls.

    The following information applies to Microsoft QuickBasic 1.00, 1.00a, and 1.00b for Apple Macintosh.

    More information

    Both methods, GetFileInfo and HFSDispatch, require using an array as the parameter block record. For more information about the parameter block, query on the following keywords:

    ParamBlockRec and HFSDispatch and IOPB

    The information returned by both methods is the logical length of both the resource fork and the data fork. These values must be converted into long integers and added together to get the total file length.

    GetFileInfo and HFSDispatch are MBLC library resources supplied with QuickBasic.

    Example 1 (below) uses the GetFileInfo Library call. For more detailed information on this call, see page 115 of "Inside Macintosh," Volume 2, by Apple Computer Inc. (published by Addison-Wesley).

    Example 1

    DIM FileInfo% (40)
filename$ = FILES$(1)
GetFileInfo filename$, FileInfo%(0)
DataForkLength& = FileInfo%(27) * 2 ^ 16 + FileInfo%(28)
RsrcForkLength& = FileInfo%(32) * 2 ^ 16 + FileInfo%(33)
TotalLength& = DataForkLength& + RsrcForkLength&
PRINT "The Length of file "; filename$; " is "; TotalLength&
END
    Example 2 (below) demonstrates the use of the HFSDispatch method. This method actually calls the routine GetCatInfo, which does not have its own trap address. A pointer to the filename must be inserted into the parameter block record for this method to work correctly. For more information about the GetCatInfo, see page 155 of "Inside Macintosh," Volume 4.

    Example 2

    DIM IOPB%(60)
filename$ = FILES$(1)
'convert the string to Pascal format:
filename$ = CHR$(LEN(filename$)) + filename$
'Poke the address of the string into the IOPB:
POKEL VARPTR(IOPB%(9)), SADD(filename$)
HFSDispatch 9, IOPB%(0)
DataForkLength& = IOPB%(27) * 2 ^ 16 + IOPB%(28)
RsrcForkLength& = IOPB%(32) * 2 ^ 16 + IOPB%(33)
TotalLength& = DataForkLength&amp; + RsrcForkLength&
PRINT "The Length of file "; filename$; " is "; TotalLength&
END
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB69176


Macintosh Parameter-Block Record Format (Used by HFSDispatch) (69177)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    The HFSDispatch library routine (an MBLC resource) for QuickBasic for the Macintosh allows access to HFS (hierarchical file system) routines that do not have individual trap addresses. You must pass these HFS routines an input/output parameter block, which contains information used by the File Manager to perform the details of the routine. However, the data structure of the parameter block is not fully compatible with the data structures available with QuickBasic. This article shows how to set up an array of integers that can be used as the parameter block.

    The following information applies to Microsoft QuickBasic 1.0, 1.0a, and 1.0b for Apple Macintosh.

    More information

    A Macintosh parameter-block record is a variable record that can take six basic forms:

    1. ParamBlockRec -- Used by all routines in the 64K ROM version of the Macintosh File Manager.
    2. HParamBlockRec -- Used by the RAM-based version of the File Manager, which can use the hierarchical file system.
    3. CInfoPBRec
    4. CMovePBRec
    5. WDPBRec -- Used by routines that exclusively use the hierarchical file directory (128K ROM only).
    6. FCBPBRec -- Used to gain access to the contents of a file's file control block (128K ROM only).
    HFSDispatch uses all six parameter-block record formats, depending on the routine that it calls.

    The format for QuickBasic's HFSDispatch library call is
       HFSDispatch selector%, IOPB%(0)
    where selector% is the routine number to call, as follows:
      Selector% Routine Name  Parameter-Block Record Type
  --------- ------------  ---------------------------

     1      OpenWD        WDPBRec
     2      CloseWD       WDPBRec
     5      CatMove       CMovePBRec
     6      DirCreate     HParamBlockRec
     7      GetWDInfo     WDPBRec
     8      GetFCBInfo    FCBPBRec
     9      GetCatInfo    CInfoPBRec
    10      SetCatInfo    CInfoPBRec
    11      SetVolInfo    HParamBlockRec
    16      LockRng       ParamBlockRec
    17      UnlockRng     ParamBlockRec
    The IOPB% array is used to set up a memory region to be used as the parameter block. For most uses of HFSDispatch, this array should be dimensioned to around 60 integer elements.

    The first 11 array elements and corresponding parameter-block record entries are as follows:
       Array
   Element Element Name  Pascal Type  Description
   ------- ------------  -----------  -----------

   0-1     qLink         QElemPtr     Used by File Manager
    2      qType         Integer      Used by File Manager
    3      ioTrap        Integer      Used by File Manager
   4-5     ioCmdAddr     Ptr          Used by File Manager
   6-7     ioCompletion  ProcPtr      Pointer to completion routine
    8      ioResult      OsErr        Returns the result code
   9-10    ioNamePtr     StringPtr    Points to string containing
                                      path/filename
    11     ioVRefNum     Integer      Volume, drive, or working directory
                                      reference number
    Note that the above eight fields are identical for all six parameter-block record types.

    The remaining elements of the record vary according to the parameter-block record type, as well as the type of file access being done, whether for a file, a volume, a catalog information query, or other low-level access.

    An example of the data structure for the CInfoPBRec, used in the GetCatInfo and SetCatInfo routines, follows. A similar technique can be used for breaking down the other parameter-block records.

    For Files

       Array
   Element Element Name  Pascal  Type   Description
   ------- ------------  -----------   -----------

    12     ioFRefNum     Integer       Path reference number
   13(h)   ioFVersNum    Signed Byte   Version number
   13(l)   filler1       Signed Byte   Not used
    14     ioFDirIndex   Integer       Index (see "Inside Macintosh,"
                                       volume 4, pages 155-156 for usage)
   15(h)   ioFlAttrib    Signed Byte   File attributes (see below)
   15(l)   filler2       Signed Byte   Not used
   16-23   ioFlFndrInfo  FInfo
                         (16 Bytes)    Information used by the Finder
                                       (see below)
   24-25   ioDirID       Long Integer  Directory ID or file number
    26     ioFlStBlk     Integer       First allocation block of data fork
   27-28   ioFlLgLen     Long Integer  Logical end-of-file of data fork
   29-30   ioFlPyLen     Long Integer  Physical end-of-file of data fork
    31     ioFlRStBlk    Integer       First allocation block resource fork
   32-33   ioFlRLgLen    Long Integer  Logical end-of-file of resource fork
   34-35   ioFlRPyLen    Long Integer  Physical end-of-file resource fork
   36-37   ioFlCrDat     Long Integer  Date and time of creation
   38-39   ioFlMdDat     Long Integer  Date and time of last modification
   40-41   ioFlBkDat     Long Integer  Date and time of last backup
   42-49   ioFlXFndrInfo FXInfo
                         (16 bytes)    Additional information used by the
                                       Finder (see below)
   50-51   ioFlParID     Long Integer  File's parent directory ID
   52-53   ioFlClpSiz    Long Integer  File's clump size

    For Directories

       Array
   Element Element Name  Pascal Type   Description
   ------- ------------  -----------   -----------

    12     ioFRefNum     Integer       Path reference number
   13(h)   ioFVersNum    Signed Byte   Version number
   13(l)   filler1       Signed Byte   Not used
    14     ioFDirIndex   Integer       Index (see "Inside Macintosh,"
                                       volume 4, pages 155-156 for usage)
   15(h)   ioFlAttrib    Signed Byte   File attributes (see below)
   15(l)   filler2       Signed Byte   Not used
   16-23   ioDrUsrWds    DInfo
                         (16 Bytes)    Information used by the Finder
                                       (see below)
   24-25   ioDrDirID     Long Integer  Directory ID
    26     ioDrNmFls     Integer       Number of files in directory
   27-35   filler3       Array [1..9]
                         of Integer    Not used
   36-37   ioDrCrDat     Long Integer  Date and time of creation
   38-39   ioDrMdDat     Long Integer  Date and time of last
                                       modification
   40-41   ioDrBkDat     Long Integer  Date and time of last backup
   42-49   ioDrFndrInfo  DXInfo
                         (16 bytes)    Additional information used by the
                                       Finder (see below)
   50-51   ioFlParID     Long Integer  Directory's parent directory ID
    Note that some of the element names are common to some or all of the other data structures.

    The ioFlAttrib byte contains the following file attributes:
       Bit   Meaning
   ---   -------

   0     Set if file is locked
   2     Set if resource fork is open
   3     Set if data fork is open
   4     Set if a directory
   7     Set if file (either fork) is open
    Following are some of the additional data types used by the Finder, broken down by element:

    Type FInfo

        Array   Element Name  Pascal Type      Description
   -----   ------------  -----------      -----------

   16-17   fdType        OSType (4 Char)  File type
   18-19   fdCreator     OSType (4 Char)  File's creator code
    20     fdFlags       Integer          File flags as follows:

                                             Bit 0  - Set if file
                                                      is on desktop
                                             Bit 13 - Set if file
                                                      has a bundle
                                             Bit 15 - Set if file's
                                                      icon is invisible

   21-22   fdLocation    Point (4 bytes)  File's icon location
    23     fdFldr        Integer          File's window as follows:

                                             -3  - File in Trash window
                                             -2  - File is on desktop
                                              0  - File is in disk window

    Type FXInfo

       Array   Element Name  Pascal Type    Description
   -----   ------------  -----------    -----------

    42     fdIconID      Integer        Icon ID
   43-46   fdUnused      Array [1..4]
                         of Integer     Reserved
    47     fdComment     Integer        Comment ID
   48-49   fdPutAway     Long Integer   Home directory ID

    Type DInfo

       Array   Element Name  Pascal Type    Description
   -----   ------------  -----------    -----------

   16-19   frRect        Rect
                         (8 bytes)      Folder's rectangle coordinates
    20     frFlags       Integer        Directory flags (see fdFlags above)
   21-22   frLocation    Point
                         (4 bytes)      Folder's location
    23     frView        Integer        Folder's view

    Type DXInfo

       Array   Element Name  Pascal Type    Description
   -----   ------------  -----------    -----------

   42-43   frScroll      Point
                         (4 bytes)      Scroll position
   44-45   frOpenChain   Long Integer   Directory ID chain of open folders
    46     frUnused      Integer        Reserved
    47     frComment     Integer        Comment ID
   48-49   frPutAway     Long Integer   Directory ID
    One problem with using an integer array for the IOPB structure is that the element sizes of the parameter block are not all 2 bytes long. For example, to convert the ioFlPyLen (a long integer value containing the physical length of the data fork) from two integer values (IOPB%(29) and IOPB%(30)) to a single, long-integer value, the following formula must be used:
       PhysicalLength& = PEEKL(VARPTR(IOPB%(29)))
    To convert a long integer to two integers:
       IOPB%(29) = PEEKW(VARPTR(PhysicalLength&))     ' High 2 bytes
   IOPB%(30) = PEEKW(2+VARPTR(PhysicalLength&))   ' Low 2 bytes
    To extract a single byte from an integer, as is required to get the ioFVersNum, the following will work:
    high% = PEEK(VARPTR(IOPB%(13)))    ' Extracts high byte from integer
low% = PEEK(1+VARPTR(IOPB%(13)))   ' Extracts low byte from integer
VersNumber% = high%
ioPermission% = low%   '(ioPermission is a signed byte in HParamBlockRec)
    To combine two bytes into an integer:
    POKE VARPTR(IOPB%(13)), high%
POKE VARPTR(IOPB%(13))+1, low%
    The preceding information can be applied to all formats of the parameter block. For more information on the structure and data elements of the other formats, consult

    References

    "Inside Macintosh," volume 4, Apple Computer Inc., Addison-Wesley
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB69177


How to Get the Names of All Mounted Macintosh Disk Volumes (69211)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    The following is a short demonstration program that shows how to get all the mounted disk volume names in Microsoft QuickBasic 1.00, 1.00a, and 1.00b for Apple Macintosh.

    More information

    The Macintosh File Manager keeps information about mounted disk volumes in a volume-control-block queue; each entry consists of a volume control block. A volume control block is a 178-byte nonrelocatable block that contains volume-specific information. For a description of the structure of a volume control block, see page 176 of "Inside Macintosh," Volume 4, by Apple Computer Inc. (published by Addison-Wesley).

    The location of the default volume control block is &H352. The first entry in each block is a pointer to the next entry. If this value is a zero, the end of the queue has been reached. The volume name is located at bytes 44 to 70 (27 bytes long) from the head of the block.

    The following is a code example:
    'Program to demonstrate the use of the Volume Control Block
'       to get the names of all mounted volumes

DIM VolName$(10)        'Array to hold the names
VolCount% = 0           'Counter to hold total number of volumes
ptr& = &H352            'Pointer to default Volume Control Block
vol& = PEEKL(ptr&)      'Get pointer to next entry in queue
WHILE vol& <> 0 'Loop until null pointer
        vol& = PEEKL(ptr&)
        ptr& = vol&
        IF vol& <> 0 THEN
                VolCount% = VolCount% + 1
                x$ = ""
                st = PEEK(vol& + 44)
                FOR i = 1 TO st 'Skip i = 0 (Length of String)
                        x$=x$ + CHR$(PEEK(vol& + 44 + i))
                NEXT i
                VolName$(VolCount%) = x$
                PRINT "[";VolName$(VolCount%);"]"
                INPUT a  ' pause program using input statement
        END IF
WEND
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB69211


Graphics Get/Put and SaveArray/LoadArray Example in QuickBasic (69584)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    A sample program below demonstrates how to use the SaveArray and LoadArray MBLC routines found in Microsoft QuickBasic 1.00, 1.00a, and 1.00b for Apple Macintosh. The sample program also demonstrates the graphics GET and PUT statements using a multidimensional array.

    More information

    The graphics GET statement gets a bit image from the screen and places that bit image into an array in memory. The graphics PUT statement draws the bit image in this array back onto any area on the output window.

    SaveArray saves any array to the resource fork of any disk file. LoadArray loads the previously-saved array from disk into a QuickBasic array in memory.

    The LoadArray and SaveArray MBLC routines are documented on pages 486 and 491 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual. GET and PUT are documented on pages 143-145 and 273-275.

    The following sample program can (optionally) be run multiple times, either compiled or interpreted. The program writes the array to the resource file just once, thus avoiding the writing of duplicate arrays into the resource file. (Overwriting resources to the same id% number creates duplicate resources, which would need to be removed with RemoveRes.)

    If you want the program to store the array into the program's own resource fork, you must modify the program to use SYSTEM(7) to obtain the resource file reference number (ref%) of the currently running program (instead of using OpenResFile/CloseResFile). OpenResFile/CloseResFile are used only to access resource files that are external to the currently running program.

    Example of Graphics Get/Put and SaveArray/LoadArray

    ON Break GOSUB breakhandle : Break ON  ' Required in interpreter.
ON ERROR GOTO handle     ' This error handler required in interpreter.
resfile$ = "Array Storage File"   'File name in which to store array.
flag% = 0  ' Must initialize parameters of MBLC toolbox routines.
' Test if file named in resfile$ exists:
Exists resfile$, flag%    ' flag% is -1 (true) if file exists
ref% = 0 ' Must initialize parameters of MBLC toolbox routines.
id% = 1  ' Must initialize parameters of MBLC toolbox routines.

' If resource file doesn't exist yet, then create it just once:
IF NOT flag% THEN
   DIM X%(44,2) 'Array X%() is 45x3, or 135 elements, or 270 bytes
   FOR J = 1 to 6
      PRINT "1234567890"   ' Draw anything here.
   NEXT
   GET (10,20)-(30,40),X%(0,1)  ' Get any image into array, then get
   GET (30,20)-(50,40),X%(0,2)  'another image into another dimension.
   CLS   ' Note: This example doesn't use the first part of X%(0,0).
   PUT (1,50),X%(0,2)    ' Confirms that the GET worked.
   PUT (1,100),X%(0,1)   ' Confirms that the GET worked.
   LOCATE 15,1 : PRINT "Press any key to continue."
   WHILE INKEY$ = "" : WEND
   OpenResFile resfile$, ref%   ' Open the resource fork of a file.
   bytes% = 270
   SaveArray ref%, x%(0,0), bytes%, id%  'Store array in resource fork
   CloseResFile ref%  ' Always close explicitly-opened resource files.
   ERASE x%     ' Erase the old array.
END IF

DIM y%(44,2)    ' Dimension a new array to load into.
OpenResFile resfile$, ref%     ' Open the resource file.
LoadArray ref%, id%, y%(0,0)   ' Load the array from disk into y%()
PUT (100,50),y%(0,2)    ' Confirms that the array has graphics in it.
PUT (100,100),y%(0,1)   ' Confirms that the array has graphics in it.
CloseResFile ref%     ' Always close explicitly-opened resource files.
LOCATE 15,1 : PRINT "Press any key to continue."
WHILE INKEY$ = "" : WEND
END
handle:    ' Error handler, just in case an error occurs.
   CloseResFile ref%  ' In the interpreter, you must close opened
                      ' resource files before ending the program, or else
                      ' resources may be misplaced in wrong files.
                      ' [An exception is that you should never close the
                      ' ref% number returned by the SYSTEM(7) function.]
   ERROR ERR  ' Aborts program and displays which error occurred, if any.
   STOP
breakhandle:  'Break (Command+PERIOD) handler, required in interpreter:
   CloseResfile ref%
   PRINT "Program aborted by the user."
   STOP
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB69584


How to Use a Modeless Dialog Box in Macintosh QuickBasic (69602)

Summary

Apple's Macintosh Dialog Manager supports dialog boxes and alert messages. The MBLC library routines provided in Microsoft QuickBasic let you call certain routines from the Dialog Manager. However, QuickBasic's MBLC routines only support modal dialog boxes; that is, dialog boxes that require the user to respond. The following article illustrates how a program can display a modeless dialog box that does not require a user response.

The following information applies to Microsoft QuickBasic 1.00, 1.00a, and 1.00b for the Apple Macintosh.

More information

A dialog box is a temporary window that displays information. There are three basic types of dialog boxes: modal, alert, and modeless. Modal and alert dialog boxes suspend program execution until the user responds. A modeless dialog box does not require user response, and usually displays temporary information while another process is performed. For more information about dialog boxes, see "Inside Macintosh" Volume 1, by Apple Computer Inc. (published by Addison-Wesley).

Using Modal and Alert Dialog Boxes

You can create a dialog box using ResEdit, and add the dialog box to your program. To access a normal modal dialog box, you execute GetNewDialog (an MBLC routine in QuickBasic) to read the dialog box out of a file's resource fork into memory. To display the dialog box on the screen, invoke ModalDialog (an MBLC routine in QuickBasic). ModalDialog waits for a user response before continuing. For more information on creating and using modal dialog boxes, see pages 439-442 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual.

Using Modeless Dialog Boxes

Modeless dialog boxes are loaded the same way as modal dialog boxes -- with the GetNewDialog routine. If the "Visible" property of the dialog is set via ResEdit, then GetNewDialog will also display the dialog box. The "Visible" property must be set for modeless dialog boxes. Note, however, that any Pict or Icon resource will not be displayed because only the resource id# is loaded by GetNewDialog, not the resource itself. To display all the resources contained in a dialog box, you must draw the dialog box, which is normally done by calling ModalDialog. However, to display the dialog box as modeless, you must invoke the DrawDialog toolbox ROM routine instead. DrawDialog is not a part of QuickBasic's library routines. Therefore, you must invoke DrawDialog through QuickBasic's ToolBox statement, as follows

ToolBox "PQ", &A981, (pointer&)

where:

"PQ" is the type of ROM call.
&A981 is the trap address of the ROM routine "DrawDialog".
(pointer&) is a pointer to the dialog information, set by the
GetNewDialog routine and passed by value ().

The following program demonstrates how QuickBasic's ToolBox statement can invoke DrawDialog to display a modeless dialog box:

Program Example

'  This program will display the "About..." box, a default
'  dialog box in all programs, as a modeless dialog box.
'  Note that the dialog box must be made "Visible" through
'  ResEdit for this to work correctly.

Trap% = &HA981     'Address of the ROM call (trap) for DrawDialog.
DialogNum% = 128   'ID# of the "About.." dialog box.
pointer& = 0       'Initialize variables used in the ToolBox calls.
ref% = 0
CLS
ref% = SYSTEM(7)   'Get the reference number for the resource fork
                   'of the currently running program (compiled or
                   'interpreted.)
GetNewDialog ref%, DialogNum%, pointer&   'QuickBasic library call.
ToolBox "I"        'Initialize the toolbox.
ToolBox "PQ", Trap%, (pointer&)    'Call the DrawDialog routine.
PRINT "Wait..."
FOR i = 1 to 2000: NEXT i
DisposeDialog pointer&    'QuickBasic library call to dispose the box.
END
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB69602


FIX: Macintosh QuickBasic 1.00b Tested with IIcx, IIci, IIfx (71237)

The information in this article applies to:
  • Microsoft QuickBasic 1.0b

    • Summary

    Microsoft QuickBasic 1.00b is a maintenance update that corrects some previous problems in version 1.00a and addresses compatibility issues with Apple's Macintosh IIcx, IIci, and IIfx computers and their respective system software.

    For a list of problems that are corrected by 1.00b, query on the following:

    fixlist1.00b and Macintosh and QuickBasic

    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB71237


FIX: Trace ON in Run Menu Indicated When You OPEN a New File (71238)

Symptoms

If you select Trace ALL from the Run menu for a program in memory, and then load up a new program, the Trace ALL will still be marked with a check mark, but will not be done. If you select Trace ALL again, the check mark remains, but is now activated.

This problem occurs in Microsoft QuickBasic 1.00 and 1.00a for Macintosh System. This problem was corrected in version 1.00b.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB71238


BUG: Incorrect Result, No "Overflow" Error, in Compiled App (71239)

Symptoms

The following code fails to give an "Overflow" error when compiled and run as an application, and prints an incorrect value of -32768:
   x% = 32767 + 1
   print x%
   while mouse(0)<> 1:wend
An "Overflow" error correctly occurs when the code is run in the interpreter.

This problem occurs in Microsoft QuickBasic 1.00, 1.00a, and 1.00b for the Macintosh System. Microsoft is researching this problem and will post new information here when it becomes available.

More information

The happens because of "constant folding" (also known as "constant arithmetic"). Constant expressions are evaluated at compile time and replaced with the result. Thus, an expression such as x% = 5 + 5 is folded by the compiler into a single assignment statement of the form x% = 10.

Thus x% = 32767 + 1 is compiled as x% = -32768. In this case, the maximum value for an integer is reached and the value gets rolled over (the sign bit gets set and a negative number is received). The expression x% = 32767 + 2 is translated to x% = -32767; the expression x% = 32767 + 3 is translated to x% = -32766; and so on.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB71239


BUG: Compiled Error 57 68020/68881 Option String$(32767,32) (71240)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Symptoms

    Below is an example of a problem using the String$(32767,32) function when compiled with the Generate 68020 Code or Generate 68881 Code option.

    The following code usually (incorrectly) gives error 57 ("Device I/O Error") at run time on Apple System version 6.05. Sometimes Error 5 ("Invalid Function Call") incorrectly occurs when the program tries to print the FRE function after the string assignment a$ = String$(32767,32). In other, different combinations of QuickBasic versions, compiler options, and System versions, wrong screen output, System Errors, or hanging may occur.

    The program is compiled with all compiler options including "Use default menus" and "Process events." The symptoms of this problem depend upon the version of the Apple System software.

    This problem occurs in Microsoft QuickBasic 1.00, 1.00a, and 1.00b for Macintosh Systems. Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

    When you compile without the Generate 68020 Code or Generate 68881 Code options, or if you changed the string assignment to a$ = String$(32766,32), no problem occurs.

    More information

    If compiled using QuickBasic 1.00b running on Apple System version 6.05, you will get either error 57 or error 5.

    When compiled with QuickBasic 1.00b using System version 6.04 (other System versions not tested), the display of output is corrupt:

    Instead of
       data: 74096   stack: 12212  string: 78820
   data: 74096   stack: 12212  string: xxxxx
    you get the following:
       data: 74096   stack: 12212  string: 78820
   data: data:

    74096    74096

   stack: stack:

    12212    12212

   string: string:  78820

    78820
    When tested with System version 6.04 using QuickBasic 1.00, a system bomb ID=3 occurs when the program is compiled with either the 68020 or 68881 options.

    Code Example

           WindOW 1,"",(10,25)-(500,500)
       PRINT "data: ";FRE(-1);"stack: ";FRE(-2);"string: ";FRE("")
       a$ = String$(32767,32)
       PRINT "data: ";FRE(-1);"stack: ";FRE(-2);"string: ";FRE("")
       INPUT x   'for a pause
       WindOW CLOSE 1
       END
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB71240


FIX: "BLOCK ELSE/END IF Must Begin Line" Error Message (71241)

Symptoms

Two or more adjacent accented e's in a REMark or quoted string incorrectly give a "BLOCK ELSE/END IF must begin line" error message at run time in QuickBasic's interpreter. (You can create an accented e by pressing OPTION+e followed by e.) The problem does not occur in QuickBasic's compiler.

This problem occurs in the interpreter in Microsoft QuickBasic versions 1.00 and 1.00a for Macintosh Systems. This problem is corrected in version 1.00b.

Code Example

  REM ee  'Where ee means to press OPTION+e followed by e, then again.
One accented e is okay. The problem occurs with two or more accented e's in a row, or when separated by spaces.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB71241


BUG: Mouse(0) Returns -1 After MouseUp on Modal Dialog (71242)

Symptoms

After a modal dialog box handles a MouseUp event, the Mouse(0) function may incorrectly return -1 as the status of the mouse button (incorrectly indicating the mouse button is still down). Expected behavior is for Mouse(0) to return 1, indicating that the mouse button is not currently down and a single button-click occurred since the last call to Mouse(0).

This problem occurs in Microsoft QuickBasic 1.00, 1.00a, and 1.00b for Macintosh Systems. Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available. The following code illustrates the problem; run the program and then click the mouse to pop up the first FILES$(1) dialog box:
   WHILE INKEY$ = ""
      m% = Mouse(0)
      PRINT m%
      IF m% = -1 THEN
         x$ = FILES$(1) 'The dialog keeps reappearing after you click
                        'OK or Cancel.
      END IF
   WEND
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB71242


BUG: Literal Parameters Not Passed to Nested Subprogram Calls (71243)

Symptoms

Literals are not properly passed through nested SUBprogram calls in Microsoft QuickBasic 1.00, 1.00a, and 1.00b for Apple Macintosh Systems.

Microsoft is researching this problem and will post new information here as it becomes available.

More information

The code example below demonstrates this problem:
    MySub1 1!

   SUB MySub1(x!) STATIC
      PRINT x!
      MySub2 x!
   END SUB

   SUB MySub2(y!)
      PRINT y!
   END SUB
This produces the following output; 1 is correctly passed at the first level call, but 0 is incorrectly passed at the second level call:

1
0

Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB71243


BUG: Bad Floating-Point Result When Using STATIC Array (71568)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Symptoms

    Creating a STATIC array in a program compiled under the binary version of Microsoft QuickBasic for the Macintosh may cause incorrect results from double-precision floating-point calculations.

    Microsoft has confirmed this problem in the Binary (b) version of Microsoft QuickBasic 1.00, 1.00a, 1.00b for Macintosh . Microsoft is researching this problem and will post new information here as it becomes available.

    More information

    Arrays can be made STATIC using the DIM STATIC statement or by compiling with the "Make all arrays STATIC" compile option.

    The following code demonstrates the problem:
            DIM STATIC s$(10000)  ' Problem also with:  DIM STATIC x(10000)
        a#=123456789.12
        b#=b#+a#
        PRINT a#
        PRINT b#
    This should result in two identical values being printed to the screen, but instead, the value of b# is incorrect.

    You can do any of the following to work around the problem:

    1. Do not dimension the array as STATIC.
    2. Make the array smaller than 10000 elements.
    3. Change the order of the variables in the calculation. For example, the following gives the correct results:

      b# = a# + b#

      Using a temporary variable also gives the correct results, as follows:

      c# = b# + a#
      b# = c#

    4. Use single precision variables instead of double precision.
    This problem occurs only in an application compiled under the binary version of Microsoft QuickBasic for the Macintosh. The problem does not occur in the interpreter under the binary version, and does not occur at all in the decimal version of Microsoft QuickBasic for Macintosh.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: kbbug KB71568


Macintosh QuickBasic Error Using HP "LaserJet IIP" Chooser (72678)

Summary

The Hewlett-Packard Chooser document "LaserJet IIP," which is supplied with the Hewlett-Packard LaserJet IIP, is not compatible with Microsoft QuickBasic 1.0, 1.0a, and 1.0b for Apple Macintosh.

When printing from Microsoft QuickBasic (for Apple Macintosh) to a Hewlett-Packard LaserJet IIP, a "System error ID = 03" will occur if the Chooser document supplied by Hewlett-Packard is used. This error will occur in either a program using LPRINT or PRINT# commands, or when printing a program listing using Print from QuickBasic's File menu.

To work around this problem, use the standard Apple LaserWriter Chooser document instead of the LaserJet IIP Chooser document when printing from QuickBasic.

Microsoft has confirmed this to be a problem in QuickBasic 1.0, 1.0a, and 1.0b for Apple Macintosh computers running on System 6.0.4, 6.0.5, and 6.0.7, and associated Finder versions 6.1.4, 6.1.5, and 6.1.7. We are researching this problem and will post new information here as it becomes available. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB72678


BUG: No Sound Using SOUND Statement in Compiled Pgm on Mac LC (72680)

Symptoms

Using QuickBasic's SOUND statement in a compiled program on a Macintosh LC computer fails to generate any sound. However, when the program is run in QuickBasic's interpreter, the correct sound is produced.

To work around the problem, use the Wave statement (such as Wave 0,SIN) before any SOUND statements in the program.

Microsoft has confirmed this to be a bug in Microsoft QuickBasic versions 1.0, 1.0a, and 1.0b for the Macintosh . We are researching the problem and will post new information here as it becomes available.

More information

When the following code sample is compiled and run on a Mac LC, no sound is produced:
SOUND 1046, 18.2, 130, 0         'Play a C note for 1 second
PRINT "Press any key to continue"
WHILE INKEY$="": WEND
END
The workaround to the problem is to add a Wave 0, SIN statement before the SOUND statement. The following code example works correctly when run from the interpreter or as a compiled program on the Macintosh LC:
Wave 0, SIN
SOUND 1046, 18.2, 130, 0
PRINT "Press any key to continue"
WHILE INKEY$="":WEND
END
Using Wave 0, SIN diminishes volume considerably and since this command puts the system in multi-voice mode, the volume cannot be controlled with the SOUND statement.

An alternative to Wave 0, SIN that produces louder sound is to define a square wave. Do this by defining an array of 256 integers with the first 128 elements set to 127 and the last 128 elements set to -128. Specify the array name as the second argument to the Wave command.

The following code example produces a louder sound:
   DIM w%(255)
   FOR i = 0 to 127
      w%(i) = 127
   NEXT
   FOR i = 128 to 255
      w%(i) = -128
   NEXT
   Wave 0, w%
   SOUND 1046,18.2
   PRINT "Press any key to continue"
   WHILE INKEY$ = "": WEND
   END
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB72680


"forst" "Path Not Found" Correction on Page 552, QuickBasic (72845)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    In the "Path not found" error-message explanation on page 552 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference," the second occurrence of the word "forst" should be changed to say "first".

    This information applies to Microsoft QuickBasic 1.0, 1.0a, and 1.0b for Apple Macintosh.

    More information

    The following statement on page 552 is incorrect:

    For example, if you specify path such as
    My Work Disk:forst folder:Word Document, when you meant
    My Work Disk:forst folder:Word Document, you will encounter this
    error ["Path not found"].

    This should be changed to say:

    For example, if you specify path such as
    My Work Disk:forst folder:Word Document, when you meant
    My Work Disk:first folder:Word Document, you will encounter this
    error ["Path not found"].

    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB72845


BUG: Subpgm Run-time "Error 35": Compiled w/ Line Length=255 (75413)

Symptoms

Attempting to run a compiled program that contains a line exactly 255 characters in length may result in run-time "Error 35" ("Undefined subprogram"). This problem will occur if a line exactly 255 characters in length is placed between a call to a subprogram and the SUB statement itself. This problem occurs for a program compiled under Microsoft QuickBasic for Macintosh . This problem does not occur in the QuickBasic development environment.

Microsoft has confirmed this to be a bug with programs compiled with Microsoft QuickBasic 1.0, 1.0a and 1.0b for the Apple Macintosh. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

More information

The QuickBasic environment (interpreter) supports a line length of 255 characters. Attempting to exceed this line length correctly gives a "Line too long" error while editing in the QuickBasic environment. The compiler will compile a line of exactly 255 characters without error, but the resulting compiled program may fail with an "Error 35" ("Undefined subprogram") at run-time if the line appears anywhere between a call to a SUB program and the SUB program itself.

The only workaround for this problem is to shorten the 255-character line to 254 characters or less.

Below is a code example that demonstrates the problem:
CALL Temp
'The line below must contain exactly 255 characters for the problem to
'occur:
'Put 254 X's here after the remark (the ' counts as one character).
END

SUB Temp STATIC
END SUB
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB75413


BUG: CopyFile Fails w/ System Err 3 w/ Binary Mac QB 1.0b (76667)

Symptoms

The following sample program, when compiled under the binary version of QuickBasic 1.0b, will fail with a system bomb 3 ("illegal instruction") when launched:
   INPUT "Name of source file: ", f1$
   INPUT "Name of destination file ", f2$
   CopyFile f1$, f2$      'Program fails on this statement.
This problem only occurs for programs compiled using the binary version of QuickBasic 1.0b. The problem does not occur when the program is run in the development environment of QuickBasic 1.0, 1.0a or 1.0b for either the binary or decimal version. The problem does not occur when the program is compiled with the decimal version of QuickBasic 1.0, 1.0a or 1.0b.

Microsoft has confirmed this to be a bug with Microsoft QuickBasic version 1.0b for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

More information

A workaround for the problem is to use ResEdit to copy the CopyFile MBLC routine from the decimal version of QuickBasic to the binary version. The program can be recompiled with the binary version and when run, the problem will no longer occur. Below are the steps to copy the CopyFile MBLC routine from the decimal version to the binary version:

  1. Launch ResEdit
  2. From the file list box, select the folder containing the decimal version of QuickBasic.
  3. Double-click on QuickBasic within the list to bring up the resource list box.
  4. From the resource list box, double-click on MBLC.
  5. Search for CopyFile ID=1200 within the list.
  6. Highlight the line including "CopyFile ID=1200".
  7. From the Edit menu, choose Copy.
  8. Close the list box containing the list of MBLC routines and associated ID numbers.
  9. Close the resource list box.
  10. Double-click on the binary version of QuickBasic within the list box to bring up the resource list box.
  11. From the resource list box, double-click on MBLC to bring up the list box containing a list of the MBLC routines and associated ID numbers.
  12. From the Edit menu, choose Paste. The CopyFile routine should appear at the top of the list (out of alphabetical order), indicating that it was successfully copied.
  13. Close the list box.
  14. Close the resource list box.
  15. From the "Save 'Microsoft QuickBasic (b)' before closing?" dialog box, select Yes to save the changes.
  16. From the File menu, choose Quit to exit ResEdit.
Recompile the program using the binary version of QuickBasic. When the program is launched, the CopyFile routine should work as expected.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB76667


BUG: Compiled Static Array in SUB, Err 10 Duplicate Definition (77736)

Symptoms

A compiled program using static arrays implicitly declared in a static SUB will incorrectly give a run-time error 10, "Duplicate Definition," on the second call to that SUB.

Microsoft has confirmed this to be a bug with the compiler in Microsoft QuickBasic 1.0b for the Macintosh . Microsoft is researching this problem and will post new information here as it becomes available.

This problem does not occur in programs interpreted in QuickBasic 1.0b.

More information

The error 10 ("Duplicate Definition") shows that on the second call to the subprogram, the compiled code mistakenly thinks the array element is being redefined as a different type.

The following steps demonstrate this problem in compiled programs:

  1. Type the following code in QuickBasic for Macintosh:
    Call MySub              'First call to SUB.
Call MySub              'Second call will cause error.

Sub MySub Static        'This Sub Initializes contents of an array.
   For i = 0 to 9
        MyArray(i) = i
   Next i
End Sub
  2. From the Run menu, select "Options..." and then make sure the "Make All Arrays Static" box is checked.
  3. Compile the program, and run the resulting compiled program.
Here is how you would need to change the above code to have it work properly:
Dim MyArray (10)                'Dimension the array at the module level.
Call MySub
Call MySub

Sub MySub Static
   Shared MyArray()     'Declare the array shared so it uses the same
   For i = 0 to 9               'array that was DIM'ed at the module level
        MyArray(i) = i
   Next i
End Sub
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB77736


BUG: When Compiled, PRINT CHR$(0) Incorrectly Concatenates (77877)

Symptoms

Below is an example where the null character, CHR$(0), in a PRINT statement causes incorrectly concatenated output in a compiled program. The problem does not occur in interpreted programs.

Microsoft has confirmed this problem in the compiler in Microsoft QuickBasic 1.0, 1.0a, and 1.0b for Macintosh .

More information

In the code example below, the output correctly appears on two separate lines in the interpreter in QuickBasic. However, from the compiled version of the program, the output incorrectly prints on the same line.
   A$ = CHR$(0)
   PRINT "Hi"; A$
   PRINT "Bye"; A$
   INPUT J
When run in the QuickBasic environment, the correct output appears as:
   Hi
   Bye
   ?
When compiled, however, the following incorrect output results:
   HiBye?
The CHR$(0) is ignored by the compiler, causing output to continue on the same line, as if the PRINT statement ended in a semicolon (;). If A$ is changed to any other ASCII character (such as CHR$(64), the @ character) the compiled code runs correctly, with the output appearing on two separate lines.
Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: kbbug KB77877


Sales Specification for QuickBasic 4.5 for Ms-Dos Available (77907)

Summary

You can obtain the following detailed sales literature by calling Microsoft End User Sales at (800) 426-9400.

QuickBasic for Ms-Dos, Sales Specification (part number 098-10594)

This information applies to Microsoft QuickBasic 4.5 for Ms-Dos. Modification Type Minor
Last Reviewed: 1/8/2003
Keywords: KB77907


QuickBasic Can Get Date/Time of Mac File's Last Modification (78072)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    You can use the GetFileInfo and Secs2Date Toolbox Library routines (stored as MBLC resources in QuickBasic for Macintosh) to obtain the date and time of a file's last modification.

    This information applies to Microsoft QuickBasic 1.0, 1.0a, and 1.0b for Apple Macintosh.

    More information

    The following is a program example that demonstrates using GetFileInfo and Secs2Date to obtain the date and time of the last modification of a file on a Macintosh disk:
    DIM fileInfo%(39), dtRec%(6)
GetFileInfo "filename", fileInfo%(0)
sec& = PEEKL(VARPTR(fileInfo%(38))      'Read two integers as one long
secs2Date sec&, dtRec%(0)
PRINT "Year  = "; dtRec%(0)
PRINT "Month = "; dtRec%(1)
PRINT "Day   = "; dtRec%(2)
PRINT "Day of the week = "; dtRec%(6)
PRINT
PRINT "Hour   = "; dtRec%(3)
PRINT "Minute = "; dtRec%(4)
PRINT "Second = "; dtRec%(5)
    For more information on the fileInfo data structure, query on the following words:

    HFSDispatch AND record AND structure

    References

    "Microsoft QuickBasic for Apple Macintosh: Language Reference," version 1.0, pages 482, 493

    "Inside Macintosh" volume II, Apple Computer Inc., Addison-Wesley, 1985
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB78072


BUG: Cannot ERASE Arrays in SUBs DIMmed in Main Program (78133)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Symptoms

    Any attempt to ERASE an array from within a SUB program will generate an "Invalid function call" error when run from the interpreter, or an "Invalid statement ordering" error when compiled. The problem occurs under the following conditions:

  • The array is a dynamic array.
  • The array is dimensioned in the main program.
  • The array is passed as an argument to a SUB program or is in a ShareD statement within the SUB program.
  • The array is erased within the SUB program.
    • The problem does not occur in the interpreter if ShareD follows the DIM statement for the array and the ShareD statement is removed from the SUB.

    When compiled with the "Make all arrays static" compile option, the error "Cannot erase static array variables" is correctly generated at compile time.

    Microsoft has confirmed this to be a bug with the binary and decimal versions of Microsoft QuickBasic 1.0, 1.0a and 1.0b for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

    More information

    When run in the interpreter, the following code generates an "Invalid function call" error on the ERASE statement. Note that in the interpreter, all arrays are dynamic and all SUBs must be declared as STATIC. When compiling, the following code generates an "Invalid Statement Ordering" error on the ERASE statement.

    Example 1

    In this example, the array a%(), which is dimensioned in the main program, is made accessible to the subprogram by the ShareD statement:
    DIM a%(30)                       'type of array does not matter
CALL asub
END

SUB asub STATIC
   ShareD a%()
   ERASE a%
END SUB

    Example 2

    In this example, the array a%() is passed as an argument to the subprogram:
    DIM a%(30)                       'type of array does not matter
CALL asub(a%())
END

SUB asub (a%()) STATIC
   ERASE a%
END SUB
    A possible workaround to the problem is to ERASE and DIM the array before making the call to the SUB. If the ERASE is needed in the middle of a SUB, divide the SUB into two SUBs, the first of which returns to the main program where the array can be ERASEd.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB78133


BUG: GetPicture "Invalid Function Call" after CHAIN (78387)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Symptoms

    Attempting to CHAIN to a program that uses the GetPicture toolbox routine (an MBLC stored in QuickBasic for Macintosh) will result in an "Invalid function call" (error 5) under the following conditions:

  • The program is run in the QuickBasic interpreter.
  • The program being chained from does not contain the Pict resource needed by GetPicture.
    • This problem occurs because the program being chained to attempts to use the resource fork of the original program (the program chained from) that was run. If the resource fork of the original program does not contain a Pict resource, then a call to the GetPicture toolbox routine will fail with an "Invalid function call" error.

    This problem does not occur in a compiled program. In a compiled program, the resource fork of the program being chained from is closed and the resource fork of the program being chained to is used.

    More information

    Steps to Reproduce Problem

    1. Launch QuickBasic
    2. From the code window of the QuickBasic development environment, enter the following code.
            CHAIN "ToolBoxSampler"
    3. From the File menu, choose Save.
    4. In the "Save program as:" dialog box, type chainer and press Enter.
    5. From the Run menu, choose Run Program.
    6. If the "Can't fine" ToolBoxSampler" dialog box appears, choose OK. Otherwise, go to step 9 below.
    7. Find ToolBoxSampler in the appropriate folder. ToolBoxSampler is a demonstration program supplied with Microsoft QuickBasic 1.0. It is located in the QB Demos folder of the Examples disk.
    8. Highlight ToolBoxSampler and choose Open.
    9. From the dialog box introducing the ToolBoxSampler, choose OK. The error message "Invalid function call" will occur on the statement GetPicture ref%, 20, d!.

    Workaround

    You can work around the problem by copying the Pict resource (needed by GetPicture) to the chained-from program, as follows:

    1. Launch ResEdit.
    2. From the files/folders list box, click on the folder containing ToolBoxSampler. Repeat this step as many times as necessary until the ToolBoxSampler is found.
    3. From the files/folders list box, select ToolBoxSampler. A list box containing the resources associated with ToolBoxSampler will appear.
    4. From the resource list box, click on Pict.
    5. From the Edit menu, choose Copy.
    6. Close the resource list box.
    7. From the file/folders list boxes remaining on the screen, close as many of the list boxes as necessary such that the program "chainer" created in step 4 above can be found.
    8. Click on chainer. A list box containing the resources associated with the program chainer will appear.
    9. From the Edit menu, choose Paste. Pict will be added to the list of resources.
    10. From the File menu, choose Quit.
    11. From the "Save 'chainer' before closing?" dialog box, select Yes.
    12. Follow steps 1 through 9 further above.
    After being chained to, the ToolBoxSampler should run without error.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: kbbug KB78387


BUG: Mouse(0) with WindOW OUTPUT Gives Incorrect Coordinates (79118)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Symptoms

    In a compiled program, the Mouse function incorrectly returns the position of the mouse pointer relative to the output window rather than the active window. This problem only occurs in compiled programs that use the WindOW OUTPUT statement to direct output to a window other than the active window.

    Microsoft has confirmed this to be a bug in Microsoft QuickBasic versions 1.0, 1.0a, and 1.0b for Macintosh . We are researching this problem and will post new information here as it becomes available.

    More information

    Workaround

    To work around this problem, set the output window to the active window using the WindOW OUTPUT statement before calling Mouse(0).

    The function Mouse(0) is designed to return the status of the mouse button and record the position of the mouse pointer within the active window. The x and y coordinates recorded by Mouse(0) are returned by Mouse(1) and Mouse(2), respectively.

    The active window is the highlighted, front-most window. It is the same as the output window unless the WindOW OUTPUT statement is used to direct output to another window.

    Steps to Reproduce Problem

    The program example below demonstrates the problem. The program creates two windows titled "One" and "Two". When you press the mouse button while the mouse pointer is in window "One," the mouse pointer x and y coordinates are printed in window "Two."

    When run in the interpreter environment, the x and y coordinates are correctly relative to the upper-left corner of window "One." When compiled, the coordinates are incorrectly relative to the upper-left corner of window "Two" (the values printed are negative).
    WindOW 1, "One", (10, 40)-(250, 160), 1
WindOW 2, "Two", (250, 190)-(500, 320), 1

WindOW 1                  ' the active window
WindOW OUTPUT 2           ' the output window

WHILE INKEY$ = ""
   IF Mouse(0) <> 0 THEN  ' mouse button down
      PRINT "x="; Mouse(1); "y="; Mouse(2)
   END IF
WEND
END
    To work around the problem so that this compiled program behaves correctly, insert the statement "WindOW OUTPUT 1" before the statement "IF Mouse(0) ..." and insert "WindOW OUTPUT 2" before the statement "PRINT "x=" ..."
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB79118


Documentation Error Causes "Unprintable Error" in QB for Mac (81954)

Summary

In the "Microsoft QuickBasic for Apple Macintosh: Language Reference" version 1.0 manual, there are errors in the code example on page 84. When the code example is entered as shown, it results in an "Unprintable Error" message. The example demonstrates how to use the COMMON statement in QuickBasic for the Macintosh.

There are three errors in the code on page 84, in the following statements:

Lines 7 and 21:
   "REM $INCLUDE "chesscom.inc"
Line 15:
   "REM $INCLUDE "game.inc"
The syntax shown on page 378 is also incorrect.

More information

To run the program on page 84 correctly, you must substitute the following statements for the metacommands shown:
   REM $INCLUDE: 'chesscom.inc'            '(for lines 7 and 21)

   REM $INCLUDE: 'gamecom.inc'             '(for line 15)
The syntax on page 378 should read:
   REM $INCLUDE: 'filename'
The syntax for include files is to use single quotation marks around the filename. The double quotation marks are syntax errors.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: KB81954


"Input Past End of File" with INPUT #; Use LINE INPUT # (82001)

The information in this article applies to:
  • Microsoft QuickBasic for Ms-Dos 4.00
  • Microsoft QuickBasic for Ms-Dos 4.0B
  • Microsoft QuickBasic for Ms-Dos 4.50
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.00
  • Microsoft Basic PDS for Ms-Dos and MS OS/2 7.10
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b
  • Microsoft Visual Basic Standard Edition for Windows 1.00

    • Summary

    When reading a sequential file, the INPUT # statement may produce the error
    Input past end of file
    even if the function EOF returns False (0) immediately before the INPUT #. This run-time error occurs when the INPUT # statement attempts to read more than one value, and not enough values remain in the file. The EOF function works properly with sequential text files in all versions of Microsoft Basic products.

    To avoid this run-time error, use the LINE INPUT statement to read one line at a time and parse values out of the input string.

    More information

    The error "Input past end of file" (error code 62) can occur when you use the INPUT # statement in a loop to iteratively read a fixed number of values from each line of a sequential (text) file, and one of the lines in the file has the wrong number of values. This happens because INPUT # reads across line boundaries. For example, when there are too few values on a line, INPUT # continues reading values from the next line. This leaves too few values on the next line for the following INPUT # iterations. When reading the last line in the file, the error occurs.

    Example Program

    The program below demonstrates how INPUT # can produce "Input past end of file" due to a missing data value, and demonstrates how to use LINE INPUT # to read each line from the file and then retrieve the values from the input line.
    DIM seenError%  ' tells if error "Input past end of file" occurred
CLS
q$ = CHR$(34)   ' the double-quote character (")

' Create a sequential data file with a missing value.
' The data also contains other minor problems that parseNumber
' and parseString handle better than INPUT #.
OPEN "data.txt" FOR OUTPUT AS 1
WRITE #1, 1, "two", 3    ' good data
WRITE #1, 2, "eleven"    ' missing value causes Input past end of file
PRINT #1, 3; ",,"; 10.25    ' unquoted null string
PRINT #1, 4; "eight,"; 9.5  ' good data
PRINT #1, 5; q$ + "one,"; 9 ' unmatched quote
CLOSE 1

' Read the data back from the file using INPUT #. This results in
' the error "Input past end of data" due to the missing value.
OPEN "data.txt" FOR INPUT AS 1
ON ERROR GOTO errorHandler
DO UNTIL EOF(1)
    INPUT #1, a%, b$, c#
    IF seenError% THEN
        PRINT "error"
    ELSE
        PRINT a%; "'"; b$; "'"; c#
    END IF
LOOP
ON ERROR GOTO 0
CLOSE 1

PRINT "=========="

' Read the data again using LINE INPUT #.
' The parseNumber and parseString functions print several error
' messages due to the missing value (parseNumber: null string) and
' other minor problems (unmatched ", unquoted null string).
OPEN "data.txt" FOR INPUT AS 1
DO UNTIL EOF(1)
    LINE INPUT #1, buf$
    a% = parseNumber(buf$)
    b$ = parseString(buf$)
    c# = parseNumber(buf$)
    PRINT a%; "'"; b$; "'"; c#
LOOP
CLOSE 1

END

errorHandler:
    IF ERR = 62 THEN
        ' input past end of file
        seenError% = -1
    ELSE
        ERROR ERR
    END IF
    RESUME NEXT

' parseNumber
'   Purpose
'     Retrieve and delete a numeric value from the beginning of an
'     input string. The number is terminated by a comma, space, a
'     double quote (string value), or the end of the input string. A
'     terminating comma is deleted. If no numeric value occurs before
'     the terminator, an error message is printed.
'   Parameters
'     buf$  -- the input string, modified by this function
'   Return
'     n!    -- the number retrieved
FUNCTION parseNumber! (buf AS String)
    DIM n AS Double      ' return value
    DIM s AS String      ' the value as a string
    DIM quote AS String  ' double quote character

    quote = CHR$(34)

    ' skip leading spaces
    DO WHILE LEFT$(buf, 1) = " "
        buf = MID$(buf, 2)
    LOOP

    ' get value into temporary string
    ' terminated by space, comma, or quote
    DO UNTIL buf = "" OR INSTR(" ," + quote, LEFT$(buf, 1))
        s = s + LEFT$(buf, 1)
        buf = MID$(buf, 2)
    LOOP
    IF s = "" THEN
        PRINT "parseNumber: null string"
        n = 0
    ELSE
        n = VAL(s)
    END IF

    ' skip trailing spaces and comma
    DO WHILE LEFT$(buf, 1) = " "
        buf = MID$(buf, 2)
    LOOP
    IF LEFT$(buf, 1) = "," THEN
        buf = MID$(buf, 2)
    END IF

    parseNumber = n
END FUNCTION

' parseString
'   Purpose
'     Retrieve and delete a string value from the beginning of an
'     input string. If the value begins with a double quote (") then
'     it is terminated by a subsequent double quote, otherwise the
'     string is terminated by a comma or the end of the input string.
'     A terminating comma is deleted. Error messages are printed if
'     the value begins with a double quote but does not end with a
'     double quote, or if an unquoted null string value occurs.
'   Parameters
'     buf$  -- the input string, modified by this function
'   Return
'     s$    -- the string retrieved
FUNCTION parseString$ (buf AS String)
    DIM s AS String         ' return value
    DIM quote AS String     ' double quote character
    DIM terminal AS String  ' close quote or comma

    quote = CHR$(34)
    s = ""

    ' skip leading spaces
    DO WHILE LEFT$(buf, 1) = " "
        buf = MID$(buf, 2)
    LOOP

    ' determine if quoted or unquoted
    IF LEFT$(buf, 1) = quote THEN
        terminal = quote
        buf = MID$(buf, 2)
    ELSE
        terminal = ","
    END IF

    ' get value
    DO UNTIL buf = "" OR LEFT$(buf, 1) = terminal
        s = s + LEFT$(buf, 1)
        buf = MID$(buf, 2)
    LOOP

    ' check closing quote
    IF terminal = quote THEN
        IF buf = "" THEN
            PRINT "parseString: unmatched " + quote + " on " + s
        ELSE
            ' skip closing quote
            buf = MID$(buf, 2)
        END IF
    ' unquoted null string not allowed
    ELSEIF s = "" THEN
        PRINT "parseString: unquoted null string"
    END IF

    ' skip trailing spaces and comma
    DO WHILE LEFT$(buf, 1) = " "
        buf = MID$(buf, 2)
    LOOP
    IF LEFT$(buf, 1) = "," THEN
        buf = MID$(buf, 2)
    END IF

    parseString = s
END FUNCTION
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB82001


"Duplicate Definition," CHAIN, Dynamic Array in COMMON (82912)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    CHAINing with a dynamic array in a COMMON statement will give a "Duplicate Definition" (run-time error 10) at run time if the CHAINed program attempts to dimension the array again without first erasing the array.

    Dynamic arrays are dimensioned at run time, while static arrays are dimensioned at compile time. A dynamic array needs to be dimensioned only once in the executable code; it must be erased before executing another DIM statement for that array.

    The compiler in QuickBasic allows you to make some arrays static (with DIM STATIC) and some arrays dynamic in a program. You can also choose the "Make All Arrays Static" option from the Options item in the Run menu.

    Arrays are always dynamic in the interpreter in QuickBasic. The interpreter does not support static arrays. Dynamic arrays cannot be redimensioned unless you first perform an ERASE. The ERASE statement removes a dynamic array from memory.

    This information applies to Microsoft QuickBasic 1.0, 1.0a, and 1.0b for Apple Macintosh.

    More information

    In a CHAIN operation, a dynamic array is passed in the COMMON statement, but needs only to be dimensioned in the CHAINing program. If the CHAINed program CHAINs back to the CHAINing program, the CHAINing program must incorporate logic so the DIM statement is not executed a second time.

    You can do this by passing a flag variable between programs in a COMMON statement. This flag variable is used in an IF statement to execute the DIM statement only once. This technique works with any Microsoft Basic interpreter or compiler that supports dynamic arrays.

    The following is an example of how to CHAIN between programs that pass a dynamic array in a COMMON statement:

    Program1

         COMMON array1(1), flag
   IF flag <> 100
       DIM array1(20)
   END IF
   array1(1) = 0
   IF array1(1) > 5 THEN STOP
   CHAIN "Program2 apl"
   END

    Program2

  COMMON array1(1), flag
   flag = 100
   array1(1)=array1(1)+1
   PRINT array1(1)
   CHAIN "Program1 apl"
   END
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB82912


BUG: IF Statement with POS Function Problem in Decimal QB (84384)

Symptoms

The following code evaluates differently within the interpreters of the binary and decimal versions of QuickBasic for the Macintosh:
   FOR I = 1 TO 5
     PRINT "1";
     ' POS returns the current horizontal column position of
     ' text printed to the output window
     IF I + 1 <> POS(n) THEN BEEP
   NEXT I
   ' wait for mouse click to continue
   WHILE Mouse(0) = 0 : WEND
The binary version of QuickBasic for the Macintosh works correctly (with no beeps) and the decimal version of QuickBasic for the Macintosh behaves incorrectly (as shown with a beep). Running in the decimal version will cause five beeps at run time. The above code executes correctly as an application compiled from either version of QuickBasic for the Macintosh.

Microsoft has confirmed this to be a bug with Microsoft QuickBasic versions 1.0, 1.0a, and 1.0b for the Macintosh . We are researching this problem and will post new information here as it becomes available.

More information

Adding the following debugging lines will show that the problem is not caused by the POS function, but rather by the way the IF THEN condition is parsed:
   DIM x(5), y(5)
   FOR I = 1 TO 5
     PRINT "1";
     ' POS returns the current horizontal column position of
     ' text printed to the output window
     IF I + 1 <> POS(n) THEN BEEP
     ' assign values returned by POS and I + 1 to variables
     x(I) = I + 1
     y(I) = POS(n)
   NEXT I
   PRINT
   ' print out values of debug arrays
   FOR I = 1 to 5
     PRINT x(I), y(I)
   NEXT
   ' wait for mouse click to continue
   WHILE Mouse(0) = 0 : WEND
The output of the program will be as follows in either the decimal or binary version of QuickBasic:
   11111
   2   2
   3   3
   4   4
   5   5
   6   6
This output is as expected. The decimal version of QuickBasic is not evaluating the left side of the IF THEN clause (I + 1) correctly.

Workarounds

If you put parentheses around the "I + 1" part of the IF clause, the decimal version also works properly. For example, insert the following IF statement into the code in place of the current IF statement:
   IF (I+1) <> POS(n) THEN BEEP
When you run the program, a beep will not sound. This means that with the parentheses, the IF statement is being evaluated correctly.

When the programs are compiled they also work correctly (meaning no beeps) in either the binary or decimal QuickBasic interpreter.
Modification Type Minor
Last Reviewed: 1/9/2003
Keywords: kbbug KB84384


QuickBasic "Launch After Compile" Option Fails on Mac System 7 (84552)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    The compile option "Launch after compile" in QuickBasic will not function correctly under Macintosh System 7. The particular error depends upon the hardware.

    More information

    On the Apple Quadra computer, the binary version of QuickBasic will abort with an error of type 3 on System 7. The decimal version of QuickBasic will not abort, but the application will not launch after compilation.

    For all other hardware, the "Launch after compile" option will not result in an error, but the application will not launch after compilation, and you will be returned to the QuickBasic editor environment.

    Note that to run QuickBasic on the Quadra or any other hardware with 32-bit addressing, you must first turn off the 32-bit addressing and restart the computer.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB84552


QuickBasic for Macintosh Will Not Run with 32-bit Addressing (84557)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    Under Apple System 7.0.n with 32-bit addressing set ON, QuickBasic for the Macintosh will fail. The particular error depends on the hardware.

    This information applies to Microsoft QuickBasic 1.0, 1.0a, and 1.0b for the Apple Macintosh. The following hardware causes problems when used with System 7 and 32-bit addressing turned on:

  • With an Apple Macintosh LC, the binary version of QuickBasic will work, but the decimal version will return a "BUS ERROR" and crash when you try to compile.
  • With an Apple Quadra Model 700 or 900, the QuickBasic binary and decimal versions will not run at all.
  • With an Apple Powerbook Model 170, QuickBasic runs correctly.

    • Workaround

    To run QuickBasic on these systems, turn off the 32-bit addressing from the System Control Panel and restart the system. Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB84557


BUG: SYSTEM(1) Function Gives Incorrect Value in 1.0e Env (85154)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0e

    • Symptoms

    In the QuickBasic environment version 1.0e for Macintosh , the function SYSTEM(1) incorrectly returns a value 2 greater than in earlier versions of QuickBasic. This does not happen in a compiled program.

    Microsoft has confirmed this to be a bug with Microsoft QuickBasic 1.0e for the Macintosh. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

    More information

    The SYSTEM(1) function returns an integer number that represents the machine type. SYSTEM(1) returns the following values from within the environment and from compiled programs for versions of QuickBasic earlier than version 1.0e:
       Return  Machine
   Value   Type
   ------  -------

   0       Unknown
   1       Mac 512K
   2       Mac Plus
   3       Mac SE
   4       Mac II
   5       Mac IIx
   6       Mac IIcx
   7       Mac SE/30
   8       Portable
   9       Mac IIci
  11       Mac IIfx
  15       Mac Classic
  16       Mac easy
  17       Mac LC
    In QuickBasic 1.0e, from within the environment, the return values for the SYSTEM(1) function are as follows:
       0       Unknown
   3       Mac 512K
   4       Mac Plus
   5       Mac SE
   6       Mac II
   7       Mac IIx
   8       Mac IIcx
   9       Mac SE/30
  10       Portable
  11       Mac IIci
  13       Mac IIfx
  17       Mac Classic
  18       Mac easy
  19       Mac LC
    If you compile the program, the SYSTEM(1) works as it did before. This can cause problems to programs that are expecting certain hardware configurations.
    Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: kbbug KB85154


Mac QB 1.00E: Cannot Change Options Because File Is Locked (90893)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0e

    • Summary

    The following error message may be displayed if the user tries to change the compile options when no source file is loaded, or with a file that has not yet been saved:
    You cannot change the options for this file because the file is locked.

    More information

    This error message is misleading because the file does not necessarily have to be locked in order to get this error message. If you receive this message, and the file is not locked you can work around this problem by using one of the following methods:

    1. Load in the file you want to compile, and then change the options if you are getting this error because no file is currently loaded, -or-

    2. Save the file that was created with QuickBasic or another editor in the environment. Then change the compile time options.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB90893


Troubleshooting QB Problems on Macintosh Quadra and Powerbook (92830)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0e

    • Summary

    If you use Microsoft QuickBasic Compiler for the Apple Macintosh, versions 1.0 or 1.0e on the new Apple Macintosh Quadra 700 or Quadra 900, you must set the Cache Switch Control Panel to the More Compatible (Caches Disabled) option to ensure that no compatibility problems exist. You must also set the Memory Control Panel to 32-bit addressing off.

    The following steps will set the necessary options described above:

    1. From the Apple menu, choose Control Panel.
    2. Select the Cache Switch panel.
    3. Choose the More Compatible (Caches Disabled) option.
    4. Close the Cache Switch panel.
    5. Select the Memory Panel.
    6. Choose 32-bit addressing off.
    7. Close the Memory Panel.
    8. Close the Control Panel.
    9. From the Special Menu, choose Restart.
    Note: To have this Control Panel installed, the Macintosh must be running Apple System 7.0.1.

    If the Cache Switch is not available in the Control Panel's folder, use the following procedure to copy the Cache Switch Control Panel to the System Folder from the Tidbits System Disk:

    1. Insert the Tidbits System Disk.
    2. Drag the Cache Switch into the System Folder of the Quadra.
    3. You will see a message of "Control panels need to be stored in the Control Panel's folder or they may not work properly. Put 'Cache Switch' into the Control Panel's folder."
    4. Choose the OK button.
    5. From the Apple menu, choose Control Panels. Double-click on Cache Switch. Select More Compatible.
    6. From the Special menu, choose Restart.
    The Cache Switch is only installed by the installer when doing a custom installation for a Quadra; many dealers do a default install instead. Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB92830


How to Enable Program Compiled in Mac QB to Run In Background (94118)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0e

    • Summary

    When running under Multifinder or System 7.0, if you run a compiled QuickBasic program and then click elsewhere to run another application, the QuickBasic program that is running in the background will halt until it gets the focus back.

    To allow compiled QuickBasic applications to run in the background you must use ResEdit, and edit the Size resource.

    More information

    The following steps can be used to edit the Size resource of your compiled application:

    1. Run ResEdit.
    2. Open your compiled QuickBasic application.
    3. Double click the resource of type Size.
    4. Double click the resource with ID -1.
    5. Change the item marked "Can Background" from 0 to 1.
    6. Save changes.
    7. Exit ResEdit.
    Your program can now run in the background under Multifinder or System 7 and above.
    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB94118


Viewing File in QuickBasic Environment Can Change Spacing (94315)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    If you load a file, other than Basic source code, into the Microsoft QuickBasic environment, the spacing in the file will be changed and additional characters may be added. Since the QuickBasic environment assumes you are loading a Basic source code file, it attempts to parse the contents of any file loaded into the environment. The parsing the environment does will almost certainly alter the spacing of any data files loaded into the environment.

    To view the data file, use a text editor, or write a loop that reads in the data file and prints it to the default output window.

    More information

    Steps to Reproduce Behavior

    1. Start QuickBasic.
    2. Type in the following code:
            OPEN "outfile" FOR OUTPUT AS #1
      FOR i = 1 TO 5
        FOR j = 1 TO 5
             PRINT #1, USING "###    ###   ";i;j;
        NEXT
        PRINT #1,     ' print space to next line
      NEXT
      CLOSE
    3. Run the program.
    If you now try to open the "outfile" file in the editor, it will look as follows:

    1112131& 415
    2122232& 425
    3132333& 435
    4142434& 445
    5152535& 455

    However, the actual output to the file would be as follows:
       1   1   1   2   1   3   1   4   1   5
   2   1   2   2   2   3   2   4   2   5
   3   1   3   2   3   3   3   4   3   5
   4   1   4   2   4   3   4   4   4   5
   5   1   5   2   5   3   5   4   5   5
    To view the data correctly, display it as follows:
       OPEN "outfile" FOR INPUT AS #1

WHILE NOT EOF(1)
LINE INPUT #1, x$
PRINT  x$
WEND
    This will print the data to the screen as it appears in the file.

    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB94315


FILES$(1) Function Doesn't Work Properly with System 6.0.8 (95332)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.0b

    • Summary

    The FILES$(1) function in QuickBasic 1.0b does not work correctly with the Macintosh operating system version 6.0.8. The FILES$(1) function is supposed to display a window that contains a list of all files the user can select. Under System 6.0.8, a dialog box appears on the screen, but instead of listing all the files in the current folder, it is empty.

    To work around this problem, do any one of the following:
  • Call the FILES$ function with a second parameter, such as the following
          FILES$(1,<promptstring$>)
    where <promptstring$> is a list of file types to display in the window. For more information about the FILES$ function, see page 131 of the "Microsoft QuickBasic for Apple Macintosh: Language Reference" manual. -or-

  • Use a different version of the Macintosh operating system. If you are going to use QuickBasic 1.0b, you will have to use a different version of the System software. -or-

  • If you do not have a different version of the System software, use QuickBasic 1.0e.

    To obtain pre-sales information about new or updated Microsoft products, call Microsoft Consumer Sales at (800) 426-9400. If you are outside the United States, contact the Microsoft subsidiary for your area. To locate your subsidiary, go to the Microsoft Web site http://www.microsoft.com/worldwide/default.htm
    • Modification Type: Minor
    Last Reviewed: 1/9/2003
    Keywords: KB95332 kbAudDeveloper


QuickBasic for Macintosh: Drawing a Pict File Larger Than 32K (95482)

The information in this article applies to:
  • Microsoft QuickBasic Compiler for the Apple Macintosh 1.00

    • Summary

    When the Picture statement is used to draw Pict files, the Pict file is put in a string variable to be displayed. However, strings have a maximum size of 32,767 characters; therefore, a picture file larger than this cannot be displayed with Picture.

    More information

    To work around this limitation, the picture must be put into a resource file and drawn with calls to the Toolbox Library. To do this, follow the steps below using ResEdit 2.1. Different versions of ResEdit may require modifications to the steps below.

    1. Start the drawing application that created the picture file, and load the picture.
    2. Select the picture and copy it to the Clipboard.
    3. Quit the drawing application and start ResEdit.
    4. From the File menu, choose New and give the new file a name. This will be the resource file that holds the picture.
    5. From the Resource menu, choose Create New Resource.
    6. For the type of resource, enter Pict. Make sure the letters are capitalized, then choose the OK button.
    7. From the Edit menu, choose Paste. This will paste the entire picture into the Pict resource.
    8. Make a note of the Pict ID number for this picture. It is at the bottom of the Picture window, and you will need it to pull the picture into QuickBasic. This number can be changed by choosing Get Resource Info from the Resource menu, if desired.
    9. From the File menu, choose Save menu to save the resource file.
    10. Use the following code to pull the resource Pict file into QuickBasic:

'  This code will read picture ID 128 from a resource file
'  created with ResEdit.

SUB drawpict (pictid%,pictfile$)
' pictid% is the picture ID in the resource file from step 8
' above. pictfile$ is the name of the picture file from step 4
' above.

ref% = 0   ' This must be initialized to zero or
                 ' you will get an error message.
handle&amp; = 0  ' This also must be initialized to zero.

'This opens the resource file that you created with ResEdit.
OpenResFile pict$,ref%
'This returns a handle to the picture resource so we can use it.
GetPicture ref%,pictid%,handle&
'This will draw it. See manual for changing draw location.
DrawPicture handle&
END SUB
    For more information, see these publications:

  • "Inside Macintosh Volume V," "Picture Compatibility," page V-92, by Apple Computer, Inc.
  • "Microsoft QuickBasic: Language Reference," Appendix E, GetPicture, DrawPicture, and other Toolbox routines
    • Also query on the following words in the Microsoft Knowledge Base:

    making and bitmap and resource and openpicture and addpicture
    making and pict and resource and picture$ and savepicture

    Modification Type: Minor
    Last Reviewed: 1/8/2003
    Keywords: KB95482


About this program.
Free Utility. Translations for the spanish words. 484 objects.

Buscar = Search
Buscar en anteriores = Search in previous
Buscar sólo títulos = Search only titles
Encontrados = Found
Imprimir = To print
Mostrar tema = Show topic
No resaltar texto buscado = Not to highlight searched text
Palabras similares = Similar words

To write in the Search bar firstly highlight it with the mouse.
This program only highlights searchings in a black background.

Prepared and compiled by Macric. May MMV.


Fichero HTMLHelp creado usando:

Web2HTMLHelp 		De descarga gratuita desde:
http://www.web2htmlhelp.co.uk

También disponible en:
HTMLHelp ePublisher
La creación de eDocumentos HTMLHelp hecha fácil

De descarga gratuita desde:
http://www.htmlhelp-epublisher.co.uk

Traducido al español por Cbf.
http://hispanicoweb.miarroba.com

[ Atrás ]