ARexx (8/84)

From:mrdo
Date:7 Mar 2001 at 02:54:25
Subject:2 questions

Hello,

/* A Problem: Say I have the following twelve paths: */

pat.1 = "dir1/file1"
pat.2 = "dir1/file2"
pat.3 = "dir1/file3"
pat.4 = "dir2/file1"
pat.5 = "dir2/file2"
pat.6 = "dir3/file1"
pat.7 = "dir3/file2"
pat.8 = "dir3/file3"
pat.9 = "dir3/file4"
pat.10 = "dir4/file1"
pat.11 = "dir5/file1"
pat.12 = "dir5/file2"

/* First I want to extract the directories and filenames from the paths: */

do i = 1 to 12
dir.i = left(pat.i,lastpos("/",pat.i))
fil.i = substr(pat.i,lastpos("/",pat.i)+1)
end

/*

And I get:

> dir1/ file1
> dir1/ file2
> dir1/ file3
> dir2/ file1
> dir2/ file2
> dir3/ file1
> dir3/ file2
> dir3/ file3
> dir3/ file4
> dir4/ file1
> dir5/ file1
> dir5/ file2

*/

/* a) - To find out how many different directories I have: */

newdir.1 = dir.1
j = 1
do i = 2 to 12
do k = 1 to j
if dir.i = newdir.k then flag = FALSE
end
if flag ~= FALSE then do
j = j + 1
newdir.j = dir.i
files.j = 1
end
flag = TRUE
end

/*
Using this check loop:

do k = 1 to j
say k newdir.k
end

I get

> 1 dir1/
> 2 dir2/
> 3 dir3/
> 4 dir4/
> 5 dir5/

b) But then I'd like to relate the files to their dirs, to get this output:

> dir1
> file1
> file2
> file3
> dir2
> file1
> file2
> dir3
> file1
> file2
> file3
> dir4
> file1
> file2
> dir5
> file1
> dir6
> file1
> file2

My questions are:
1. How can I do b)?
2. Is there a better way to do what I did in a), or is it ok the way it is?

Can anyone please help? I'm trying, but no good results yet :(
Kind regards



MrDoc

------------------------ Yahoo! Groups Sponsor ---------------------~-~>
Find software faster. Search more than 20,000
software solutions on KnowledgeStorm. Register
now and get started.
http://us.click.yahoo.com/cPNRrC/INSCAA/Jh4EAA/stAVlB/TM
---------------------------------------------------------------------_->

ARexx mailing list - No flames, no overquoting, no crossposting.
Unsubscribe: Blank mail to mailto:arexx-unsubscribe@onelist.com

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