This tip contains information about launching Windows applications and documents from Comet98. We have included a number of practical examples to demonstrate this feature.
Launching a Windows application from Comet98 is comparable to activating an MTB program in a background partition. However, launching offers the ability to start another program running under Windows (which the ACTIVATE command does not provide). Here are some possible applications:
In addition to launching programs, Comet98 can launch documents. For example, if Comet98 launches a text file, Windows will run the associated text editor (Notepad or Wordpad, for example) and open the specified file. We provide several practical examples of this capability below.
In an upcoming release, the launch feature will also be available in the Comet Help System, NOVA, and SuperNova.
The launch feature may remind you of the "shell to DOS" feature in Comet 504. In fact, when used under Comet98, SHELL and LAUNCH are identical. In other words, the SHELL command in QMONITOR performs the same function as the LAUNCH command, and the (Shell to DOS) mnemonic in MTB performs the same function as the (Launch) mnemonic. Why, then, do we have two commands for the same function? Simple -- we wanted to make our commands match the correct terminology for the Windows environment. ("A rose by any other name...")
If you include a Windows program name on the command line,
Comet98 launches that program. For example:
launch c:\msoffice\excel\excel.exe
If you include a document name, Comet98 launches that document
(which, in turn, launches the associated Windows program).
This example launches a spreadsheet file. Based on the "xls"
extension, Windows runs the Excel program:
launch c:\budget\1998.xls
In the MTB language, you can use the (Launch) mnemonic to
launch a Windows application. The following examples are based on
this simple program:
LENGTH 254
LOCAL A$
A$ = ...
PRINT (0) (Launch=A$)
RUN "QMONITOR"
where A$ is a string containing the
name of the Windows program or document to be launched.
A$="c:\msoffice\excel\excel.exe"
A$="c:\msoffice\excel\excel.exe c:\budget\1998.xls"
A$="c:\budget\1998.xls"When an "xls" file is launched, Windows automatically runs the Excel program (based on the file extension).
A$="c:\memos\report.doc"When a "doc" file is launched, Windows automatically runs the Word program.
A$="c:\text\sample.txt"When a "txt" file is launched, Windows automatically runs the associated text editor (Notepad, Wordpad, etc.).
A$="c:\images\logo.gif"When a "gif" file is launched, Windows automatically runs the associated graphics viewer.
A$="c:\aol\gotmail.wav"When a "wav" file is launched, Windows automatically runs the associated audio player.
A$="c:\intranet\home.htm"When a local "htm" file is launched, Windows automatically runs the default web browser and displays the HTML document.
A$="http://www.signature.net/signature/index.html"When the launch string starts with "http://", Windows runs the default web browser, connects to the Internet (if not already connected), and displays the named web page.
Oops, wrong commercial. Sorry about that.
Seriously, we wanted to show you an example that really puts the launch feature to the test. Here's what we came up with. Using the launch feature in an MTB program, you can track shipments via the United Parcel Service web site.
Here are the required items:
After doing some research, here's what we found:
The filed named "tracking.cgi" is a Common Gateway Interface (CGI) program that runs on the UPS server. An MTB program can send data to this program in order to track a specific package. (This is similar to the way MTB programs send data to each other via COMMON.)
Note: We figured this out by direct observation of the tracking program. We did not get specifications from UPS. Therefore, it's possible that UPS could change this string format in the future, in which case we'd have to figure it out again... Keep that in mind if you implement this example.
The next part is a snap. We put this information into a
small MTB program:
LENGTH 80
LOCAL A$, B$, C$, D$
LENGTH 254
LOCAL E$
A$="http://wwwapps.ups.com/tracking/tracking.cgi?inquiry1=" ! Header
B$="1z985854" ! This is Signature's shipper number
C$="0102302340" ! This is a sample tracking number
D$="&type1=1" ! Trailer
E$=A$+B$+C$+D$ ! Build data string for the UPS CGI program
PRINT (0) (LAUNCH=E$) ! Launch the UPS Package Tracking page
RUN "QMONITOR"
The complete launch string is:
http://wwwapps.ups.com/tracking/tracking.cgi?inquiry1=1z9858540102302340&type1=1Running this program launches the web document named in E$, runs your default web browser (if it's not already running), connects to the Internet (if you're not already connected), contacts the UPS web site, and sends the data string to the CGI program. The CGI program then displays the results of your request.
Obviously, hard-coding the tracking number is silly. A better approach is to make the tracking number a variable (a COMMON one) and to either pass that data from another program or INPUT it in the sample program. We've provided for both methods in this version of the program:
LENGTH 80
COMMON C$ ! C$ is the tracking number
! If it's null, INPUT a tracking number
! Otherwise, assume that a value was
! passed in COMMON from another program
LOCAL A$, B$, D$
LENGTH 254
LOCAL E$
IF C$ = "" THEN ! If C$ is null, then
PRINT (0) (ET)
PRINT (0) "Enter tracking number:" ! Display prompt
INPUT (0) C$ ! Input tracking number
C$ = STRIP(C$) ! Strip blanks from tracking number
ENDIF
IF C$ = "" THEN RUN "QMONITOR" ! If it's still null, then quit
A$="http://wwwapps.ups.com/tracking/tracking.cgi?inquiry1=" ! Header
B$="1z985854" ! This is Signature's shipper number
D$="&type1=1" ! Trailer
E$=A$+B$+C$+D$ ! Build data string for the UPS CGI program
PRINT (0) (LAUNCH=E$) ! Launch the UPS Package Tracking page
RUN "QMONITOR"
Suppose you compile this program and call the object program TRACK.
From the "Ready" prompt, you could:
Some other possibilities: Pass data to the TRACK program from another MTB program, make the TRACK program a subprogram, etc. We'll leave those details to you.
For example, here's the data string that the Alta Vista search
engine uses when looking for the term Signature Systems, Inc.:
http://www.altavista.com/cgi-bin/query?pg=q&kl=XX&q=%22Signature+Systems%2C+Inc.%22
We hope you use the launch feature in your MTB programs. Please report back
to us with any creative applications you develop. We'd love to include
descriptions of those programs in future Comet Tips. Thanks.