Using PV-WAVE® as a Web Browser Helper Application

The goal of a helper app is to allow users to distribute PV-WAVE.pro and .cpr files over the Web. Click on a UR,L which links to a Wave file, and WOW! Wave fires up and executes the application on your machine!

Here is how it works:

Client-Side PV-WAVE Helper App Benefits

  • Data can be on Client, Server or both. See the OpenURL utility in the PV-WAVE Web Kit to see how to access data from the Web from any Wave application.
  • Uses Client Performance and Rendering capabilities
  • Instant Versioning
  • Less Bandwidth -- download and disconnect
  • Any Server

If a server-side implementation seems more appropriate, go to Wapplet . For a complete discussion and comparison of the implementations, go to PV-WAVE Net Possibilities

The one requirement for creating a helper app which is a PV-WAVE procedure (.pro) or compiled procedure (.cpr) but NOT a command file (.cmd), as implemented here, is that the PV-WAVE code that you want to serve must include a procedure called MAIN, as this will be the entry point executed when PV-WAVE runs the code. Also, the a procedure file should have the extension .wpr (for Wave PRocedure) rather than .pro, so that downloading source procedure files from our ftp site or other sites is not affected. (Note: The name of the file does not have to be main.xxx, it just has to have the extension .wpr or .cpr) A PV-WAVE command file, which is usually executed by typing "@filename" at the Wave prompt, cannot contain procedures so this is not an issue for .cmd files.

The first goal in the Helper App Implementation was to define a Wave MIME type. A MIME type maps a file distributed over the Web to an application that interprets and uses the file. For Wave, there are two types, one for .pro files and the other for .cpr files.

Basically, defining a MIME type is a two-step process; you need to configure both the server and the browser for the MIME type so that they both know what to do.

Server Configuration

To configure the server for the WAVE MIME type, do the following (This was done with CERN 3.0, but the idea is similar for other servers).

  • Add these lines to the server configuration file:
    AddType .cmd application/x-wavecmd 8bit 1.0
    AddType .wpr application/x-wavepro 8bit 1.0
    AddType .cpr application/x-wavecpr 8bit 1.0
    

    This maps files with a .pro extension to the mime type "application/x-wavepro." The "x" is a customary prefix that shows that this MIME type has not been officially adopted by the governing boards of the internet (governing? Yes, that's right...). The x-wavecpr and x-wavecmd do the same for .cpr and .cmd files.

  • Restart the server

Browser Configuration

UNIX Instructions

On UNIX machines, there are two files which map MIME types, your .mime.types and .mailcap files in your home directory are used by Netscape (and other applications such as exmh...) to map MIME types. The latest version of Netscape will help you through this by editing your files for you, but you can edit the files manually as well.

Below are shell scripts that will fire up PV-WAVE and pass it a .cmd file, .wpr file or .cpr file respectively. These scripts start up an xterm and run PV-WAVE in it, so that you will have a Wave prompt in addition to any graphics/widgets the code might create. For the compiled procedure script, you could also specify a runtime license to be used for PV-WAVE, in which case you would see the stdout from Wave in the xterm but would not get a Wave prompt.

The wavepro and wavecpr scripts require that a trivial two-line PV-WAVE command file be created to tell PV-WAVE to run the MAIN procedure. This file can be placed anywhere, but the WAVE_PATH environment variable must include the directory in which it is placed. WAVE_PATH also needs to include the /tmp directory, as this is where the downloaded code will be placed. WAVE_PATH is modified in the wavepro and wavecpr scripts to do this.

Below are the scripts discussed above. All are executable scripts saved somewhere in your PATH:

  • wavecmd:
    #!/bin/csh
    #
    source <path>/vni/wave/bin/wvsetup
    xterm -geometry 80x35+10+10 -title "Wave Command File" \
    -font "-*-courier-*-r-normal--*-120-*" -e \
    <path>/vni/wave/bin/wave $1 
    
    
  • wavepro:
    
    #!/bin/csh
    #
    source <path>/vni/wave/bin/wvsetup
    setenv WAVE_PATH /tmp:{$WAVE_PATH}:<path to where gomain.pro is located>
    cp $1 /tmp/main.pro
    xterm -geometry 80x35+10+10 -title "Wave Procedure" \
    -font "-*-courier-*-r-normal--*-120-*" -e \
    <path>/vni/wave/bin/wave gomain.pro 
    rm /tmp/main.pro
    
    
  • wavecpr (version that uses a development license):
    
    #!/bin/csh
    #
    source <path>/vni/wave/bin/wvsetup
    setenv WAVE_PATH /tmp:{$WAVE_PATH}:<path to where gomain.pro is located>
    cp $1 /tmp/main.cpr
    xterm -geometry 80x35+10+10 -title "Wave Compiled Procedure" \
    -font "-*-courier-*-r-normal--*-120-*" -e \
    <path>/vni/wave/bin/wave gomain.pro 
    rm /tmp/main.cpr
    
    
  • wavecpr (version to use runtime license):
    
    #!/bin/csh
    #
    source <path>/vni/wave/bin/wvsetup
    setenv WAVE_PATH /tmp:{$WAVE_PATH}
    cp $1 /tmp/main.cpr
    xterm -geometry 80x35+10+10 -title "Wave Compiled Procedure" \
    -font "-*-courier-*-r-normal--*-120-*" -e \
    <path>/vni/wave/bin/wave -r main
    rm /tmp/main.cpr
    
    
  • gomain.pro (startup command file for PV-WAVE used by wavepro & wavecpr):
    
    PRINT, 'Calling Main program...'
    MAIN
    

You need to replace <path> above with the appropriate paths to where your PV-WAVE installation exists and to where you have placed the gomain.pro file. (One suggestion would be to place it in $WAVE_DIR/LIB/USER, as this directory is already in the PV-WAVE search path).

Basically what happens here is that the script will rename the unique file created by the browser in /tmp to /tmp/main.pro or /tmp/main.cpr as appropriate. If a PV-WAVE procedure is being served, Wave is started and executes the commands in gomain.pro, which just causes main.pro to be compiled and run. In the case of .cpr files, Wave can be run using a runtime license with the .cpr file passed as an argument (or just run in the same way as wavepro if desired).

Configuring your UNIX MIME types

If you have a new verison of Navigator, then you can try to let the helper app widget adjust your mailcap and mime.types files automatically. If not, make the following changes.

Add the following to .mime.types

application/x-wavecmd \
type=application/x-wavecmd \
exts="cmd" \
desc="PV-WAVE command file"

application/x-wavepro \
type=application/x-wavepro \
exts="wpr" \
desc="PV-WAVE procedure file"

application/x-wavecpr \
type=application/x-wavecpr \
exts="cpr" \
desc="PV-WAVE compiled procedure file"

And to your .mailcap file

application/x-wavecmd;wavecmd %s
application/x-wavepro;wavepro %s
application/x-wavecpr;wavecpr %s

You can replace "wavepro" and "wavecpr" with the full path to these scripts if the directory they are placed in is not in your PATH.

Windows® Instructions

For Windows it's pretty much the same as for UNIX, in that you tell Internet Explorer or Netscape to run a script somewhere that copies the temporary file to "main.pro" or "main.cpr" and runs Wave.

The instructions below assume that PV-WAVE is installed in C:\VNI (adjust the paths as neccessary). Also, you need to create the directory C:\VNI\helper-1_0 and under it a \bin and \lib directory. There are other ways to accomplish the same, but creating a directory like this ensures that Wave will find the procedures needed without having to modify the !PATH environment variable in Wave to look somewhere else. The alternative is to place the files anywhere you want but make sure you edit C:\VNI\wave\bin\wavestartup so that !PATH points to the directory where the .pro and .cpr files are located.

Below are batch files needed to fire up Wave:

  • C:\Vni\helper-1_0\bin\wavecmd.bat
    
    C:\Vni\WAVE\BIN\BIN.i386NT\WAVE.EXE %1
    
    
  • C:\Vni\helper-1_0\bin\wavepro.bat
    
    copy %1 C:\Vni\helper-1_0\lib\main.pro
    C:\Vni\WAVE\BIN\BIN.i386NT\WAVE.EXE gomain
    del C:\Vni\helper-1_0\lib\main.pro
    
    
  • C:\Vni\helper-1_0\bin\wavecpr.bat (version which uses a development license):
    
    copy %1 C:\Vni\helper-1_0\lib\main.cpr
    C:\Vni\WAVE\BIN\BIN.i386NT\WAVE.EXE gomain
    del C:\Vni\helper-1_0\lib\main.cpr
    
    
  • C:\Vni\helper-1_0\bin\wavecpr.bat (version to use runtime license):
    
    copy %1 C:\Vni\helper-1_0\lib\main.cpr
    C:\Vni\WAVE\BIN\BIN.i386NT\WAVE.EXE -r main
    del C:\Vni\helper-1_0\lib\main.cpr
    
    
  • C:\Vni\helper-1_0\lib\gomain.pro (startup command file for PV-WAVE used by wavepro & wavecpr):
    
    PRINT, 'Calling Main program...'
    MAIN
    

Configuring your Windows MIME types

The instructions below are for Microsoft's Internet Explorer version 3.0. Similar instructions could be used with Netscape or other browsers (but we do not have them right now).

In Internet Explorer select: View-> Options -> Programs tab -> File Types -> New Type
and add a new type for each of the following:

Description of type:    PV-WAVE Command File
Associated Extension:   cmd
Content Type(MIME):     application/x-wavecmd
Actions:   select New then fill in the dialog:
           Actions:     open
           Application: C:\VNI\wave\helper-1_0\bin\wavecmd.bat

Description of type:    PV-WAVE Procedure
Associated Extension:   mpr
Content Type(MIME):     application/x-wavepro
Actions:   select New then fill in the dialog:
           Actions:     open
           Application: C:\VNI\wave\helper-1_0\bin\wavepro.bat

Description of type:    PV-WAVE Compiled Procedure
Associated Extension:   cpr
Content Type(MIME):     application/x-wavecpr
Actions:   select New then fill in the dialog:
           Actions:     open
           Application: C:\VNI\wave\helper-1_0\bin\wavecpr.bat


Here is a demo of a PV-WAVE helper app in action that you can test with:


Company Products & Services Solutions Success Stories Support Downloads Email this page
© Copyright 2010 Visual Numerics, Inc. All Rights Reserved Legal Privacy Sitemap