OS/2 e-Zine! - Now on CD (Click here)
[Previous]
The Rexx File - by Dr. Dirk Terrell
[Next]
OS/2 e-Zine!

Go to a Printer Friendly version of this page



Dr. Dirk Terrell is an astronomer at the University of Florida specializing in interacting binary stars. His hobbies include cave diving, martial arts, painting and writing OS/2 software such as HTML Wizard.

Related Articles
Recursive delete
Disk usage
Sorting stems
Advanced math


Blast Back! Send a private message directly to Dr. Dirk Terrell with your thoughts:

Contact OS/2 e-Zine!

Sponsored links:
The OS/2 Supersite
WarpCast

Summary: Just a quickie this month. Dirk shows how to open a desktop folder from the command line.

This month I'll share with you a simple script but one that I use many times a day. I call it "of.cmd", the "of" meaning "open folder." The reason why I find OS/2 so much better than other operating systems is that it has both a powerful graphical user interface and a powerful command line interface. With Rexx you can build some powerful connections between the two. The of.cmd script allows you to open the WPS folder for a specified directory or the current directory if one is not specified.

Because of the extensive functions of the RexxUtil library that comes with OS/2, this script is actually very simple. All we have to do is use the SysOpenObject() function to open the directory of interest. The first step is to load the function from the RexxUtil library:

Call RxFuncAdd "SysOpenObject", "RexxUtil", "SysOpenObject"

The next thing to do is parse the command line arguments for the directory to open. If none is specified, we will open the folder for the current directory:

Parse Arg Directory .
If Directory="" then Directory=Directory()
View="ICON"

The Directory() function, when called without parameters, will return the current directory. If the user doesn't specify a directory, then variable named 'Directory' will be null, so we test on that and assign the return value of the Directory() function to it if it is null. Note that when a directory is specified, it must be a full path, including the drive letter, e.g. c:\os2.

Now that we know which directory folder we want to open, all we have to do is make the call to SysOpenObject():

call SysOpenObject Directory, View, 1
call SysOpenObject Directory, View, 1

And no, that isn't a typo. We want to call the function twice. The first call opens the folder and the second one gives it the focus. And that's all there is to it. Maybe you will find this little script as useful as I do. Some things more easily done from the command line and others are more easily done with the WPS and this script gives you quick access to WPS objects from the command line.

Download the source code for this month's Rexx File.

[Previous]
 [Index]
 [Feedback]
 [Next]
Copyright © 1999 - Falcon Networking ISSN 1203-5696
March 16, 1999