home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of A1200
/
World_Of_A1200.iso
/
programs
/
disk
/
directory
/
dopuslharexx
/
arexx
/
selectfileslha.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1995-02-27
|
3KB
|
176 lines
/*rx
*
* SelectFilesLhA.rexx - Allow the user to select files in an LhA buffer
* window via a search pattern.
*
* $VER: SelectFilesLhA 40.3 (03/01/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
/* 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 sub-string to match on:"'
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 */
call ValidatePattern
call SelectFiles
/* list totals */
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
TopText "Checking Entry #" || Index
ScrollToShow Index
/* grab file name/path, protect in quotes */
File = substr(Entry, 10)
if SelectAll = 1 then
StrIdx = 1
else
StrIdx = index(upper(File), Pattern)
if StrIdx > 0 then do
selection = Index - 1 ||' '|| 1 ||' '|| 1
SelectEntry selection
end
Index = Index + 1
end
end
return
/*--------------------------------------------------------------------------*/
ValidatePattern: /* make sure pattern is ok */
/* special cases */
if Pattern = "*" then do
SelectAll = 1
return
end
/* remove leading/trailing spaces */
Pattern = strip(Pattern)
/* remove wildcards (for now) */
Pattern = compress(Pattern, '*?#')
return
/*--------------------------------------------------------------------------*/
CleanUp: /* clean up files and exit */
Busy off
exit
return