| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Help With Rexx Program |
HERBERT BOUKNIGHT had something deep to write about Help with REXX
program
HB> I need some help from you REXX programmers out there. I
HB> need a REXX script to do the following:
I'll try not to do the whole thing for you, but I will show you most
of the critical parts you'll need. You ought to look at the online
REXX reference, especially the sections on REXX Utility Functions
(REXXUtil), Keywords and Functions.
There are two easy ways to find out if a file exists.
/* A REXX script must begin with '/' and '*' as the first characters
of the first line You'll need to load all or certain parts of the
REXXUtil functions: */
call RxFuncAdd "SysLoadFuncs", "REXXUtil",
"SysLoadFuncs"
call SysLoadFuncs
/* or */
call rxfuncadd "sysfiletree", "REXXUtil",
"sysfiletree"
patha="C:\DIR_A\"
pathb="C:\DIR_B\"
call sysfiletree patha'*', 'files', 'FO' /* read up on sysfiletree to learn more */
for n=1 to files.0 /* this is the count of files found, if any */
filename=filespec('name',files.n)
if ''=stream(pathb||filename,'C','query exists') then 'copy 'patha||filename pathb
else do; /* do some things because filename already exists */
do i=1 to 999; /* this is the hard way, looking 1 file at a time */
if ''=stream(pathb||filename'.'right(i,3,'0'),'c','Query Exists') then do;
'copy 'patha||filename pathb||filename'.'right(i,3,'0')
leave
end
end
end
/* note: the 'copy '... becomes an instruction to CMD.EXE */
/* '{at}copy '... would work too */
You can use the following in place of the hard way:
call sysfiletree bpath||filename'.*', 'file', 'FO' /* look at many
files at once */
i=file.0 /* i=number of matches to DIR_B\filename.* */
i=file.i /* i=last match, for HPFS, also largest #, doesn't work for FAT */
'copy' patha||filename pathb||filename'.'right(i+1,3,'0')
The indentation is not necessary, but makes reading, and matching 'DO'
to 'END' easier. REXX is rarely picky about cAsE. || is a way to
join strings, but simply abuting (filename'.'right...) also works, as
does separating two strings by a space ('copy' patha) For more REXX
info, see the online reference, look for REXXTUT2 on your favorite
OS/2 BBS, ask more questions, or look for a book on REXX.
* KWQ/2 1.2g * Software Upgrade Installed: Press Your Luck to Continue
--- QScan v1.12b / 01-0093
* Origin: (1:381/123)SEEN-BY: 12/2442 54/54 620/243 624/50 632/348 640/820 690/660 711/409 410 413 SEEN-BY: 711/430 807 808 809 934 942 949 712/353 623 713/888 800/1 @PATH: 381/123 900 3615/50 229/2 12/2442 711/409 54/54 711/808 809 934 |
|
| 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™.