10 - 9 - 8 - 7 - 6 - 5 - 4 - 3 - 2 - 1

Launching Windows Applications from Comet98


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.

Please note that the launch feature is available in Comet98 (starting with REL version 99.01) running in a Windows 95 and greater environment. This feature is not available in earlier versions of Comet.

Some important background information

As of this writing, the launch feature is available in two places in Comet98:

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...")

And now, here are some examples

If you type the "launch" command (upper or lower case) at the "Ready" prompt in QMONITOR, Comet98 launches "My Computer" for the current drive.

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.

But wait, there's more...

"How much would you pay for a knife that slices, dices, ... ?"

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:

  1. The web page is http://wwwapps.ups.com/tracking/tracking.cgi.

    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.)

  2. The data string for the CGI program includes these items, in this order:

    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=1
Running 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.

A final word (for now, at least)

The UPS package tracking example demonstrates how an MTB program can pass data to a CGI program that runs on a web server. There are many web-based applications that use CGI, including most of the search engines. If you can figure out the format of the data string for the CGI program, you can write an MTB application that serves as a "front end" for these programs.

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.


F e e d b a c k

Tip:
This tip was: Very useful Somewhat useful No opinion Not useful
Comments:
Action:


Back to the Comet Tips page.