home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $VER: FTPGet.thor 1.0 (29.5.95)
- **
- ** by Eirik Nicolai Synnes
- **
- ** This script will let you select AmiNet files for ftp'ing either from a
- ** AmiNet RECENT listing produced by SortMail or from Thor's filebase. If
- ** the filebase window is open, the files selected there will be used.
- ** Otherwise FTPGet.thor will open a listview containing the RECENT listing.
- **
- ** FTPGet.thor is to be used together with FTPGet.daftp. The latter will
- ** read the list created by FTPGet.thor and get the files from the AmiNet
- ** site. Note that you will have to connect to the site yourself, but
- ** FTPGet.daftp will CD to the correct directory and start the downloading.
- **
- ** FTPGet.daftp has been tested with DaFTP 0.1130 and found to work
- ** satisfactory. FTPGet.thor needs Thor 2.0 or higher to work.
- **
- ** Before using these scripts, edit the listfile and getreadme variables
- ** below. FTPGet.daftp also contains two variables that must be edited
- ** before use.
- **
- */
-
- /* Edit these variables: */
- listfile = 'Thor:GetFiles.txt' /* This must be the same in FTPGet.thor and FTPGet.daftp */
- getreadme = 1 /* 0 if you don't want readme's, 1 if you do */
- /* End */
-
- options results
-
- FDF_DELETED = '00000001'x
- path = ''
-
- /* Open Thor and BBSREAD ARexx ports' */
- p=address()||' '||show('P',,);if pos('THOR.',p)>0 then thorport=word(substr(p,pos('THOR.',p)),1);else do;say 'No THOR port found!';exit(0);end
- if ~show('p', 'BBSREAD') then do; address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"; "WaitForPort BBSREAD"; end
-
- address(thorport)
- GETFILELIST OUTSTEM files
- select
- when rc = 0 then do
- CURRENTBBS STEM bbs
- if rc > 1 then do
- REQUESTNOTIFY '"'THOR.LASTERROR'"' '"Ok"'
- exit(0)
- end
-
- if exists(listfile) then call open(df, listfile, 'A')
- else call open(df, listfile, 'W')
-
- do i=1 to files.COUNT
- drop FILE. /* Important */
-
- address (bbsread)
- SEARCHBRFILE '"'bbs.BBSNAME'"' FILE SEARCH '"'files.FILENAME.i'"' NAME
- if rc ~= 0 then do
- address(thorport)
- REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"Ok"'
- exit(0)
- end
-
- if FILE.FILEAREA.COUNT ~= 0 then do
- drop FTAGS.; drop FDATA.
- READBRFILE '"'bbs.BBSNAME'"' '"'FILE.FILEAREA.1'"' FILENR files.FILENR.i tagsstem FTAGS datastem FDATA
- if(rc ~= 0) then do
- address(thorport)
- REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"Ok"'
- call close(df)
- exit(0)
- end
-
- if bitand(DATA.FLAGS,FDF_DELETED) ~= FDF_DELETED then path = do
- path = FILE.FILEAREA.1'/'FTAGS.NAME
- if getreadme = 1 then do
- path = path' 'substr(path, 1, lastpos('.', subword(path, 1, 1)))'readme'
- end
- call writeln(df, path)
- end
- end
- call close(df)
- end
- when rc = 6 then do
- REQUESTNOTIFY '"Please select some files."' '"Ok"'
- end
- when rc = 5 then do
- /* Filebase not open, get Newfiles.txt if available */
- CURRENTBBS STEM bbs
- if rc > 1 then do
- REQUESTNOTIFY '"'THOR.LASTERROR'"' '"Ok"'
- exit(0)
- end
-
- address(bbsread)
- GETBBSDATA BBSNAME '"'bbs.BBSNAME'"' STEM bbsdata
- if rc ~= 0 then do
- address(thorport)
- REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"Ok"'
- exit(0)
- end
-
- if exists(bbsdata.BBSPATH'Newfiles.txt') then do
- /* Open and read Newfiles.txt, skipping irrelevant lines */
- call open(nf, bbsdata.BBSPATH'Newfiles.txt', 'R')
- counter = 0
- do until eof(nf)
- line = readln(nf)
- if left(line, 1) ~= '|' & line ~= '' then do
- counter = counter + 1
- entry.counter = line
- end
- end
- call close(nf)
- entry.count = counter
-
- if entry.count > 0 then do
- /* Put up a listview with the files */
- address(thorport)
- REQUESTLIST INSTEM entry OUTSTEM select TITLE '"Select files"' DRAGSELECT SIZEGADGET
- if rc ~= 0 then do
- if rc > 5 then do
- REQUESTNOTIFY '"'rc'\n'THOR.LASTERROR'"' '"Ok"'
- end
- exit(0)
- end
-
- if select.COUNT = 0 then do
- /* One file was selected */
- path = subword(result, 2, 1)'/'subword(result, 1, 1)
- if substr(result, 35, 1) = '+' & getreadme = 1 then do
- path = path' 'substr(path, 1, lastpos('.', subword(path, 1, 1)))'readme'
- end
- if exists(listfile) then call open(df, listfile, 'A')
- else call open(df, listfile, 'W')
- call open(df, listfile, 'A')
- call writeln(df, path)
- call close(df)
- end
-
- else do
- if exists(listfile) then call open(df, listfile, 'A')
- else call open(df, listfile, 'W')
- do i = 1 to select.COUNT
- /* Multiple files were selected */
- path = subword(select.i, 2, 1)'/'subword(select.i, 1, 1)
- if substr(select.i, 35, 1) = '+' & getreadme = 1 then do
- path = path' 'substr(path, 1, lastpos('.', subword(path, 1, 1)))'readme'
- end
- call writeln(df, path)
- end
- call close(df)
- end
- end
- end
- else do
- /* No Newfiles.txt found */
- REQUESTNOTIFY '"No new files on system."' '"Ok"'
- end
- end
- otherwise do
- REQUESTNOTIFY '"'THOR.LASTERROR'"' '"Ok"'
- end
- end
-
- exit(0)
-