home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of Mecomp Multimedia 1
/
Mecomp-CD.iso
/
amiga
/
tools
/
opus
/
opus-tools_4.x
/
arexx
/
selectfileslha.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-07-01
|
4KB
|
196 lines
/*rx
*
* SelectFilesLhA.rexx - Allow the user to select files in an LhA buffer
* window via a search pattern.
*
* $VER: SelectFilesLhA 40.4 (22/05/94) by Geoff Seeley
*
* Usage: ARexx command SelectFilesLhA.rexx (from DOpus)
*
*/
/* configuration variables (change these to suit your setup) */
GetSizesLhARexx = "RX DOpus:ARexx/GetSizesLhA.rexx"
/*--------------------------------------------------------------------------*/
/* misc. variables */
DOpusPort = 'DOPUS.1'
LhaExt1 = '.lha'
LhaExt2 = '.lzh'
LhaHeader = '--------'
SelectAll = 0
State = 1 /* select */
if ~show(l,"rexxsupport.library") then
call addlib("rexxsupport.library",0,-30,0)
/* make sure we've got somebody to talk to */
if showlist('Ports', DOpusPort) = 0 then do
say 'Directory Opus ARexx port not found. Aborting.'
call CleanUp
end
address 'DOPUS.1'
options results
/* get window information from DOpus */
Status 3
CurrentWindow = result
/* get the path/name of the LhA archive file */
Status 14 CurrentWindow
LhaArchive = result
/* make sure it's an LhA archive listing buffer */
if right(LhaArchive, 4, ' ') ~= LhaExt1 & right(LhaArchive, 4, ' ') ~= LhaExt2 then do
Notify "Sorry, buffer isn't an LhA archive.\You must use the ListLha button first."
call CleanUp
end
TopText "Selecting Files in an LhA Archive Matching Sub-String"
Busy on
/* ask user for a search pattern */
Status 26
OldOkay = result
Status 27
OldCancel = result
Status 26 set 'Select'
Status 27 set 'Cancel'
MsgString = '"Please Enter A Pattern To Match:"'
GetString MsgString
DoSelect = RC
Pattern = Result
/* reset previous values */
Status 26 set OldOkay
Status 27 set OldCancel
if DoSelect = "0" then do
/* select the files */
TopText "Checking Entries. Please Wait..."
call ValidatePattern
call SelectFiles
/* list totals */
GetSelectedAll
SelectedEntries = result
if SelectedEntries = 'RESULT' then
TopText "No Files Currently Selected."
else
address command GetSizesLhARexx
end
else do
TopText "File Selection Aborted..."
call CleanUp
end
call CleanUp
exit
/*--------------------------------------------------------------------------*/
SelectFiles: /* select files based on pattern */
Index = 1
Entry = ""
Pattern = upper(Pattern)
do while Entry ~= LhaHeader
GetEntry Index
Entry = result
if Entry ~= LhaHeader then do
/* grab file name/path, protect in quotes */
File = upper(substr(Entry, 10))
if SelectAll = 1 then
StrIdx = 1
else do
PatternMatch Pattern File
StrIdx = RESULT
end
if StrIdx > 0 then do
selection = Index - 1 ||' '|| State ||' '|| 0
SelectEntry selection
end
Index = Index + 1
end
end
'DisplayDir -1'
return
/*--------------------------------------------------------------------------*/
ValidatePattern: /* make sure pattern is ok */
/* special cases */
if Pattern = "*" then do
SelectAll = 1
return
end
if Pattern = "~" then do
SelectAll = 1
State = -1
return
end
if Pattern = "" then do
SelectAll = 1
State = 0
return
end
/* remove leading/trailing spaces */
Pattern = strip(Pattern)
return
/*--------------------------------------------------------------------------*/
CleanUp: /* clean up files and exit */
Busy off
exit
return