TIP: Click on subject to list as thread! ANSI
echo: os2rexx
to: All
from: Jonathan de Boyne Pollard
date: 1999-11-03 10:23:08
subject: A script that generates FILES.BBS files

/* CONVERT_GLOBAL.CMD -- Convert 00GLOBAL.TXT to FILES.BBS */
/*
 * This is a REXX script that takes the 00GLOBAL.TXT file that can be found
 * in the root directory on most FTP sites, and which is next to useless, and
 * generates from it in the appropriate subdirectories a set of FILES.BBS
 * files, which are a *LOT* more useful, understood as they are by a wide
 * range of file management tools from InspectA to the DIR command in 4DOS
 * and Take Command.
 *
 * (c) Copyright 1997 Jonathan de Boyne Pollard.  All rights reserved.
 *
 * Permission is hereby granted for you to use, copy, modify, and redistribute
 * this script to your heart's content, as long as you make no money from
 * doing so, and as long as you realise that I accept no responsibility for
 * whatever posession or use of this script may do to your machine, data,
 * cat, or marital status.
 *
 * NOTE: This script requires Object REXX.
 */

call RxFuncAdd 'SysMkDir','RexxUtil','SysMkDir'

directory_prefix='./'
DescriptionFile = .stream~new('00GLOBAL.TXT')
FilesBBS = .stream~new("FILES.BBS")
FilesBBS~lineout('-')
FilesBBS~lineout('- Added to FILES.BBS from 00GLOBAL.TXT on ',
                ||date('S')||' '||time('N'))
FilesBBS~lineout('-')
do while DescriptionFile~lines() \= 0
        Line = DescriptionFile~linein()
        select
        when line~left(directory_prefix~length()) == directory_prefix then do
                parse var Line (directory_prefix) dir':'
                dir = translate(dir, '\', '/')
                if dir~right(1) == '\' then
                        dir = dir~left(dir~length()-1)
                call MakeDirectory dir
                say dir':'
                error = FilesBBS~close()
                drop FilesBBS
                FilesBBS = .stream~new(dir||"\FILES.BBS")
                FilesBBS~lineout('-')
                FilesBBS~lineout('- Added to FILES.BBS from 00GLOBAL.TXT on ',
                                ||date('S')||' '||time('N'))
                FilesBBS~lineout('-')
        end
        when line \= '' then do
                parse var Line name . . description
                if name~right(1) == '/' then
                        name = name~left(name~length()-1)
                if strip(description) \= '' then
                        FilesBBS~lineout(name||description)
        end
        otherwise nop
        end
end
drop FilesBBS
exit

MakeDirectory: procedure
        parse arg dir

        rc = SysMkDir(dir)
        if rc == 3 then do
                parent = filespec("Drive",dir)||filespec("Path",dir)
                rc = MakeDirectory(parent)
                if rc \= 0 then return rc
                rc = SysMkDir(dir)
        end

return rc

/* ¯ JdeBP ® */

--- FleetStreet 1.22 NR
209/7211
103
* Origin: JdeBP's point, using Squish (2:257/609.3)

SOURCE: echoes via The OS/2 BBS

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™.