Program to Compile QuickBasic Programs from Macintosh Desktop (36644)
The information in this article applies to:
- Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
- Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0a
- Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0b
This article was previously published under Q36644 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 versions 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: | Major | Last Reviewed: | 10/20/2003 |
---|
Keywords: | KB36644 |
---|
|