[The Graham Utilities: the largest, most comprehensive suite of utilities for OS/2. (click here).] [BMT Micro - Registration site for the best OS/2 shareware applications available. (click here).]

[Previous]
The OS/2 Project
 [Next]

If you're looking for interesting and innovative ways to take advantage of OS/2's power, or if you just want a neat trick to impress you're friends, this is the place to look! "The OS/2 Project" chronicles small endeavours intended to improve our systems, make us more productive and just generally make our lives easier.

This issue, we take a look at how to create a Desktop object to check HTML files with "Weblint".

* * *

Purpose

As the world has become addicted to the Internet, so have we become fascinated with tinkering with our own web sites. Many of us have thrown our digital etchings up on the web for the world to see. Whether it is a corporate intranet site, a mom and pop storefront on the web or your family's home page, it has become common for us to present ourselves to the world with HTML.

There are various tools to assist beginners with finding and correcting errors in HTML pages, including the granddaddy of them all, "Weblint". There are many Weblint "gateways" on the Internet which allow you to enter a URL and check a page already on the 'net, but some people prefer to check pages on their local hard drive before uploading them to the WWW. Luckily Weblint works just as well from a local hard drive as it does on the 'net. Unfortunately, the basic program is not quite as pretty.

Since Weblint is primarily a command line program, we set out to create an OS/2 Desktop object that would allow us to drag and drop HTML text files on it to auto-check them. Ideally, we wanted our object to open a window which would display any errors Weblint found in the file and then wait for us to dismiss it.

The Basics

For this project, we need to download Weblint, a programming language called Perl (because Weblint uses it) and the EMX runtime DLL (because Perl uses it). While you will likely find that older versions of these programs will do the job, we suggest grabbing the latest versions of each just to be sure. (See below for download details.)

Everything else you will need is already built into OS/2.

Setting It Up

Our first step is to download and install the EMX runtime DLLs. The EMX runtime DLLs are a set of add-on DLLs for OS/2 that allow some ported Unix programs to work on an OS/2 machine. Chances are, if you download much OS/2 shareware or freeware, you may have already downloaded and installed them. If not, grab a copy from the link below and follow the simple installation instructions included. Don't forget to reboot!

Next, download and install Perl v5.002 Beta 3 (ZIP, 1.4meg) for OS/2. As noted above, Perl is a programming language. Versions of Perl are available as freeware for various operating systems and will allow you to do a great deal more than we will describe here.

The installation of Perl v5.002 may seem a bit tedious and complicated, but here is a quick tip: for this project, you only need four files out of the many in the archive:

Also, for our project, you do not need to worry about putting these files in directories referenced in PATH or LIBPATH statements in your CONFIG.SYS. Just create a directory wherever you prefer called "Weblint" and stick the four files above in it. If you do the above, no reboot is required to get our Weblint project running.

But remember, if you want to take full advantage of Perl for other projects, you'll probably want to properly install the full package.

Next, download and install the latest version of Weblint (v1.020) (ZIP, 43k). Weblint is a Perl script (as opposed to a Rexx script) so we need to do a little modifying to be able to run the "weblint" file included in this archive. Again, for this simple project we don't need all the bells and whistles that are included in weblint.zip. If you want to do a quick and dirty installation you can just follow these instructions:

  1. unzip weblint.zip to a temporary directory
  2. rename "weblint" to "weblint.cmd"
  3. delete the first three lines in "weblint.cmd":
    : # use perl                                -*- mode: Perl; -*-
    	eval 'exec perl -S $0 "$@"'
    		if $runnning_under_some_shell;
  4. add the lines:
       extproc perl -x
       #! perl
    at the very TOP of "weblint.cmd"
  5. move "weblint.cmd" to the Weblint directory you created earlier
  6. delete all the other files that were in weblint.zip -- you won't need them for this project

At this point you should have EMX, Perl and Weblint all installed and working. If you open an OS/2 command window and switch to the "Weblint" directory where all these files reside, you should be able to run Weblint with commands similar to:

   weblint \Files\HTML\test.html
But this is not a very convenient way to check our HTML files. For one thing, the error and warning messages Weblint displays may be so long that they wrap in a "normal" sized OS/2 command window.

To do fix this, create a command file with the following contents:

   mode 100,24
   weblint -s -x Netscape %1 | more
name it "checkhtm.cmd" and save it in your "Weblint" directory. The first line, "mode 100,24" will change the dimensions of the active OS/2 command window to 100 characters wide by 24 lines high (the standard dimensions are 80 x 24). This extra width should allow error and warning messages to be printed completely on one line. The second line above, "weblint -s -x Netscape %1 | more", does a few things. First, it calls Weblint with two switches: '-s' tells Weblint we don't need it to print the filename it is working on; '-x Netscape' tells Weblint to allow Netscape extensions to HTML (if you want to check files with Internet Explorer extensions, you could use '-x Microsoft'). The '%1' in this line tells our command file to pass whatever file name we give it, to Weblint. The '| more' tells the program to pause if there is more than one screenful of error/warning messages.

So, if you now run the command file by typing:

   web \Files\HTML\test.html
It will change the size of the window and call Weblint like this:
   weblint -s -x Netscape \Files\HTML\test.html | more
That's it. All the files you need should now be in the "Weblint" directory.

[Weblint folder graphic]

The "Weblint" directory: all required files are now in place.

Now all you need to do is create a program object. Open your Templates folder (found in your "OS/2 System" folder) and drag a copy of the "Program" template to your Desktop to create a new program object. A Properties notebook (GIF, 6.4k) will pop up. In the "Path and file name" entry field, enter the path to your "Weblint" directory and the name of your file, "checkhtm.cmd". In the "Working directory" entry field, enter just the path to your "Weblint" directory. For example, if the directory you created is E:\Util\File\Weblint, enter:

   Path and file name:    E:\Util\File\Weblint\checkhtm.cmd
   Working directory:     E:\Util\File\Weblint
[Weblint Icon]If you prefer, you can add a nifty icon to the program object while you have the Properties notebook open. (I got the one displayed here from think::xels! by edv-beratung wimmers.) And don't forget to give your program object a name (how about 'Weblint'?).

There is one last (very important) thing you must do to your new object to make it useful: make sure "Close window on exit" is not checked (or the window that appears to display Weblint reports when you drop files on the object will close before you get a chance to read it). In the second page of the object's Properties notebook (the "Session" page) click the "Close window on exit" button to uncheck it.

Using Your New Object

Now, when you want to check the validity of an HTML file, just open the folder containing the file, drag the file and drop it on your Weblint object. An OS/2 Command window will pop up, resize itself to 100 x 24, and display any error messages Weblint finds. If you have multiple files you want to check, highlight them all and drop them on the Weblint object all at once. A separate window will open for each file (each window will display a command line indicating which file is being checked). When Weblint is finished checking the files, the window will display "Completed: Weblint" in the title bar. When you drop files on your Weblint object, after you finish reading the error and warning messages (if there are any), just close the window by clicking its close button (for Warp 4) or double clicking its system icon button.

If you have questions or suggestions for improvements to this project, let us know. Until then, enjoy!

* * *

Tools used in this project:

Weblint v1.020

by Neil Bowers
download from the Weblint FTP Site (ZIP, 43k)
Registration: FREE

Perl v5.002á3

by Larry Wall
OS/2 port by Andreas Kaiser
download from the OS/2 Supersite (ZIP, 1.4meg)
Registration: FREE

EMX v0.9c

by Eberhard Mattes
download from the OS/2 Supersite (ZIP, 538k)
Registration: FREE

think::xels!

by edv-beratung wimmers
download from BMT Micro (ZIP, 1.2meg)
Registration: US$36.00

[Previous]
 [Index]
 [Feedback]
 [Next]

[Our Sponsor: Indelible Blue - OS/2 software and hardware solutions to customers worldwide.]

Copyright © 1998 - Falcon Networking ISSN 1203-5696