TIP: Click on subject to list as thread! ANSI
echo: os2user-l
to: All
from: Herbert Rosenau
date: 2005-03-30 12:23:14
subject: Re: REXX - Light My String ?

Don{ald} O. Woodall schrieb:
> In , on 03/29/2005 
>    at 12:46 PM, Herbert Rosenau  said:
> 
> Hi Herbert
> 
> 
>>Make things so simple as possible:
> 
> 
>      Sounds good to me.  However, my simple isn't always the other
> person's simple.

You are thinking much too complicated!

Here is a simple procedure that does nothing as to read multiple 
drives at once, starting with the root directory and there calls a 
simple procedure with each file there with full qualified path.
The procedure does nothing than list the path/file on screen yet.

After listing all files it will list all directories and for each 
directory call itself to list all files therein and thereafter call 
all directories to list.......

No need to fiddle around with writing intermediate files only to read 
them to get what you needs.

Simply recurse through all directories and work with each file and 
directory one by one.

+-+-+-+-+-
/* Display dir list */

'mode 60,80'   /* make window 60 columns wide, 80 high */
/* we need the rexxutils, so load them when not already done */
rc = RxFuncAdd('SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs')
if rc > 1 then do
    say ''
    say 'Unable to Add Function SysLoadFuncs from DLL RexxUtil (rc = 
'rc')'
    say 'Please insure that the REXXUTIL.DLL exists in a subdirectory 
contained'
    say 'in the LIBPATH statement in your CONFIG.SYS file.'
    exit
end
else call SysLoadFuncs

/* numeric digits 10 */

/* list of drives to watch on */
pathes.0 =  3      /* number of drive to list */
pathes.1 = "L:"
pathes.2 = "W:"
pathes.3 = "M:"

/* for all drives do */
do i = 1 to pathes.0
    /* files and directories in root dir */
    rc = filesindir(pathes.i)
    /* handle any directory in root directory */
end /* do */
return

/* argument: directory to look through
filesindir: procedure
    arg dirs
    /* look at each file in this directory, ignore directories */
    rc = SysFileTree(dirs'\*', sdirs., "FO")
    if rc = 0 then do
       say 'files readed: 'sdirs.0
       /* handle files themself */
       do j = 1 to sdirs.0
          parse upper var sdirs.j filepath
          /* do real work with this file */
          rc = do_whatever_you_like_with_file(filepath)
       end /* do */
    end /* do */
    /* look at each directory here now, but ignore files */
    rc = SysFileTree(dirs'\*', sdirs., "DO")
    if rc = 0 then do
       say 'dirs readed: 'sdirs.0
       do j = 1 to sdirs.0
           /* do something with this directory itself */
           parse upper var sdirs.j filepath
          say sdirs.j
          /* and then handle its content */
          call filesindir(filepath)
       end /* do */
    end /* do */
return 0


do_whatever_you_like_with_file: procedure
    arg file
    say 'filename is: 'file
return 0
-+-+-+-+-

It lefts to you to handle the files other than only list theyr path. 
It lefts to you to handle each directory name other than list its content.

Any filename will be converted to uppercase while looking at it.

Something above can written much shorter but I have decided to use the 
longest form because it results in better readability.

You've gotten a hint how to create a directory or file with and 
without spaces in its path or name. The procedures above handles 
spaces in path and name well too.

Don't use cmd.exe when you have REXX APIs who does things much easier.

Hint: dont call procedures who likes to give a result saying "fail" or 
"success" in theyr result. You would have a need to check it to avoid 
some possible misbehavior.

The procedures above are tested and debugged.

It is time now for you to learn really REXX to get your work done
- quicker
- more errorfree
in total much better.

-- 
Tschau/Bye

Herbert Rosenau                    eCS 1.2 Deutsch bestellen bei
EDV Beratung & Programmierung           http://pc-rosenau.de
Eichelsdorfer Str. 15                   http://ecomstation.de
97461 Hofheim i.UFr.

Tel: 49-9523-502834
Fax: 49-9523-502823                     http://www.dv-rosenau.de/


 
Yahoo! Groups Links

 To visit your group on the web, go to:
    http://groups.yahoo.com/group/os2user/

 To unsubscribe from this group, send an email to:
    os2user-unsubscribe{at}yahoogroups.com

 Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




---
* Origin: Waldo's Place USA Internet Gateway (1:3634/1000)
SEEN-BY: 633/267 270 5030/786
@PATH: 3634/1000 12 106/2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.