home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
new
/
comm
/
mail
/
thor
/
thor.lha
/
rexx
/
CEDDownload.thor
< prev
next >
Wrap
Text File
|
1994-08-06
|
3KB
|
137 lines
/* CEDDownload.thor · by Troels Walsted Hansen
** $VER: CEDDownload.thor v1.2 (23.02.94)
**
** An ARexx script that creates a download event for the file
** under the cursor in CED.
**
** Get-file-name code is a slightly modified version of
** something I found in insert_adr.ced by Dirk Federlein. :^)
*/
/* user varibles. edit to your hearts content */
bbsname = "REQUEST" /* Change REQUEST to a BBS name if you like.. */
/* this is where the action begins.. */
options results
address 'rexx_ced'
/* needs Thor, CED and rexxsupport.library */
if(substr(address(),1,4) ~= "THOR") then do
parse arg portname
if~(show(p, portname)) then do
if ~(show(p, "THOR.01")) then do
say "No THOR port found!"
exit
end
else portname = "THOR.01"
end
end
else portname = address()
if ~show('ports','rexx_ced') then do
say "Sorry, CED's ARexx port was not found. Aborting script.."
exit
end
if ~show(l, 'rexxsupport.library') then do
if ~addlib('rexxsupport.library', 0, -30) then do
say "Please install rexxsupport.library in your libs: directory"
exit
end
end
/* get filename */
tabchar = '09'X
cr = '0A'X
/* Get contents of current line: */
status 55
line = result
/* Get tab size: */
status 8
tabadjust = result - 1
/* Get cursor x position (relative to beginning of line = 1): */
status 46
cur = result + 1
i = index(line,tabchar)
DO while i > 0 & i <= cur - tabadjust
cur = cur - tabadjust
i = index(line,tabchar,i+1)
END
/* If the current character is non-alphabetic, then start one character
** over to the left. This allows the cursor to be immediately after
** the key word (say on a space or bracket.)
*/
char = substr(line,cur,1)
if (~(datatype(char,'A') | char = '.' | char = '-' | char = '_' | char = '+') & cur > 1) then
cur = cur - 1
/* Find leftmost and rightmost alphabetic character adjacent to current: */
right = cur - 1
left = cur + 1
char = 'A'
DO while (datatype(char,'A') | char = '.' | char = '-' | char = '_' | char = '+') & (left > 0)
left = left - 1
if left > 0 then
char = substr(line,left,1)
END
char = 'A'
DO while (datatype(char,'A') | (char = '.' | char = '-' | char = '_' | char = '+'))
right = right + 1
char = substr(line,right,1)
END
if right-left <= 1 then
DO
address(portname)
THORTOFRONT
REQUESTSTRING TITLE '"Enter name of file to download:"' BT '"_Ok|_Cancel"' MAXCHARS 40
filetodl = result
if(rc ~= 0) then do
REQUESTNOTIFY TEXT '"Need a filename to create a download event."' BT '"_Ok"'
address 'rexx_ced'
CEDTOFRONT
exit
end
END
else
DO
filetodl = substr(line,left+1,right-left-1)
END
/* create upload event */
address(portname)
if(BBSname = "REQUEST") then do
THORTOFRONT
REQUESTLIST BBSLIST
BBSName = result
if(rc ~= 0) then do
REQUESTNOTIFY TEXT '"Need a bbsname to create a download event."' BT '"_Ok"'
address 'rexx_ced'
CEDTOFRONT
exit
end
end
ADDEVENT BBS '"'bbsname'"' DOWNLOAD FILENAME '"'filetodl'"'
if(rc ~= 0) then REQUESTNOTIFY TEXT '"Didn''t succeed in creating a download event for the file"' BT '"_Ok"'
/* bye.. */
address 'rexx_ced'
CEDTOFRONT
exit