BMT Micro - Registration site for the best OS/2 shareware applications available. (click here).Improve OS/2's performance with Priority Master II (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
Password Generator
Open folder
Recursive delete
Disk usage
Sorting stems
Advanced math
Automatic archiving
Browsers and cookies


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: It's easy to get your folders' "Tree View" to show all objects. Dirk shows you how, using a Rexx script by Marco Steinbach

Marco Steinbach sent me a cool little Rexx script this month and I thought I would share it with you. As you know, the WPS Folder has three views for displaying its contents: Icon view where objects are displayed as independent icons, Details view where objects are displayed in rows with information like size, creation date and so on, and Tree view where objects are displayed as a connected tree with folders leading to deeper branches.

The Tree view is similar to the view displayed by the File Manager of Windows 3.1 and Windows Explorer in Win 95/98/NT. However, by default the Tree view in a WPS folder shows only Folder objects. To see the Program objects in a folder, you would have to open the Folder object in Icon or Details view. The ability to display other objects is built into the Tree view, however, and Marco's script shows how to enable it.

The key to this script is the SysCreateObject function in the RexxUtil library. The calling form of this function is as follows:

result=SysCreateObject(classname, title, location <,setup>, <,duplicateflag>)
classname:
The name of the class of which this object is a member.
title:
The object title as displayed under the icon
location:
The object location. This can be specified as either an object ID (for example, ) or a file system path (for example, C:\OS2).
setup:
A WinCreateObject setup string. More on this below.
duplicateflag:
This parameter indicates what action should be taken when the Setup string specifies an object ID, and an object with that object ID already exists. (In our case, we will be updating the object since the file system folders already exist.) "U" means update the object, "R" replace the object, and "F" fail if the object exists.
result:
The return code. It equals 1 (TRUE) if the creation of the object succeeded and 0 (FALSE) if it failed.

For a given folder, Marco calls SysCreateObject like so:

rc = SysCreateObject("WPFolder",FolderName,FolderLocation,
   "ALWAYSSORT=YES;ICONVIEW=NONFLOWED, MINI;MENUBAR=NO;SHOWALLINTREEVIEW=YES",
   "u")
(I have broken the code across multiple lines here to make it more readable, but it would all be on one line in your script.)

The key element in the setup string is the SHOWALLINTREEVIEW=YES entry. That is the setting that forces the display of all objects in Tree view.

For this setting to be most useful, you need to set the SHOWALLINTREEVIEW setting for all of the subfolders of the current folder as well. Otherwise when you expanded a subfolder it would only show its folder objects. So, we need to get a list of of the folders underneath the given one. Another RexxUtil function makes that pretty easy: SysFileTree. We used this function previously in our recursive delete script. In that script we needed a list of files to be returned. Here we need a list of directories but that requires only a small change in the function call:

rc = SysFileTree(Folder'\*', 'Files','DSO')
Recall that the calling form for SysFileTree is
SysFileTree(Mask, Results, Attributes)
where Mask is the selection mask (like *.txt), Results is a stem variable that holds all of the objects that match the search criteria, and Attributes allows you to specify things about the search's scope (current directory or subdirectories, files only, directories only, etc.). In Marco's script, the variable Folder holds the path of the directory we are working on and he adds "\*" to that all objects will match regardless of their names. The variable Files is the stem variable that holds the results. And the attribrutes are set to look only for directories (D), scan subdirectories (S), and report only fully qualified path names (O). Once this call is made, Files will contain a list of all the subfolders of the directory we are working on. Now all we have to do is loop through all of them and call SysCreateObject to update them with the SHOWALLINTREEVIEW=YES attribute. Marco's code loop looks like this:
DO I = 1 TO Files.0
   Folder         = Files.I
   FolderLocation = Folder
   FolderLocation = LEFT(FolderLocation, LASTPOS("\", FolderLocation)-1)
   IF LENGTH(FolderLocation)=2 THEN FolderLocation = FolderLocation'\'
   FolderName     = SUBSTR(Folder, LASTPOS("\", Folder)+1)
   Call DispStat
   rc = SysCreateObject("WPFolder", FolderName,  FolderLocation,
      "ALWAYSSORT=YES;ICONVIEW=NONFLOWED,MINI;MENUBAR=NO;SHOWALLINTREEVIEW=YES", "u")
   IF  rc \=1 THEN SAY 'Folder could not be updated ...'
END
The call to routine DispStat displays a nice progress bar showing how far along the script is in its processing. I thank Marco for sending his script to me and if you have a script that you think would be educational and useful for others, please let me know.
[Previous]
 [Index]
 [Feedback]
 [Next]
Copyright © 1999 - Falcon Networking ISSN 1203-5696
June 1, 1999