/****************************************************** *********************/
/* AutoPoll.spot      ©1994 Gert Lindstrom  2:201/411.47@fidonet           */
/*                                                                         */
/* $VER: AutoPoll.spot 1.1 (07-Jul-94)                                     */
/*                                                                         */
/* This script goes thru your OUTBOUND library and checks if there are any */
/* files to addresses not assigned to the variable NET. Then it asks if    */
/* you likes to poll those addresses before it puts up the poll requester. */
/* Very handy when you send crashmail or do some filerequesting, you dont  */
/* have to remember to poll manuelly.                                      */
/* Rename it to _poll.spot to have work autmatically                       */
/*                                                                         */
/* v1.1  Now also parses out the point.                                    */
/*       Only tries to call addresses with extensions assigned to EXTLIST  */
/*                                                                         */
/***************************************************************************/


/*******************************************/
/*  Assign all your NET's to this variable */
/*******************************************/
NETLIST = '11:100/1.0 92:901/231.0 69:4606/120.0 39:164/100.0 23:100/110.0
           2:201/411.0 2:201/417.0'

EXTLIST = 'CUT REQ'

if ~show(L, 'rexxsupport.library') then do
    call AddLib('rexxsupport.library',0,-30,0)
    end

address SPOT
options results
signal on syntax
LF      = '0d'x
TEXT.1  = 'You have some CRASH mail to send to node'
TEXT.2  = 'You have some files to get from node'
PATH    = 'MAIL:OUTBOUND/'

ANTNET = words(NETLIST)
do COUNT = 1 while NETLIST ~= ''
    parse var NETLIST NET.COUNT NETLIST
    end

ANTEXT = words(EXTLIST)
do COUNT = 1 while EXTLIST ~= ''
    parse var EXTLIST EXT.COUNT EXTLIST
    end

FILELIST = showdir(PATH, 'f')
do while FILELIST ~= ''
    parse var FILELIST FILE FILELIST
        if ExtCheck(FILE) ~= ANTEXT then do
            if NetCheck(FILE) = ANTNET then do
                if right(FILE,3) = 'CUT' then TEXT = TEXT.1
                if right(FILE,3) = 'REQ' then TEXT = TEXT.2
                address SPOT
                'requestresponse TITLE "AutoPoll" PROMPT "'TEXT LF ParseAdr(FILE)'" GADGETS "_Poll|_Delete|_Cancel" CENTER'
                if RC = 1 then do
                    address command
                    'trapdoor call' ParseAdr(FILE)
                     end
                if RC = 2 then do
                    address command
                    'delete >NIL:' PATH||FILE
                    end
                end
             end
        end
signal exit

NetCheck: Procedure expose ANTNET NET.
    TMP = arg(1)
    CHECK = 0
    do COUNT = 1 to ANTNET
        if ParseAdr(TMP) ~= NET.COUNT then CHECK = CHECK + 1
        end
    return CHECK

ParseAdr: Procedure
    parse arg ZON'.'NET'.'NODE'.'POINT'.' .
    return ZON':'NET'/'NODE'.'POINT

ExtCheck: Procedure expose ANTEXT EXT.
    TMP = arg(1)
    TMP = right(TMP,3)
    CHECK = 0
    do COUNT = 1 to ANTEXT
        if TMP ~= EXT.COUNT then CHECK = CHECK + 1
        end
    return CHECK

syntax:
say rc errortext(rc) 'in line' SIGL

exit:
address SPOT
'poll'
EXIT
