            /*************************************************/
            /****************BUNDLE.spot V 1.3****************/
            /*************************************************/

/*************************************************************************/
/******************* Check for Rexxreqtools.Library***********************/
/*************************************************************************/

IF ~ EXISTS("libs:rexxreqtools.library") THEN DO
    SAY "Can't find rexxreqtools.library, aborting.."
    EXIT
    END

IF ~ SHOW('L',"rexxreqtools.library") THEN DO
    ADDLIB('rexxreqtools.library',0,-30,0)
    END  

/*************************************************************************/
/************************ Initialise some variables***********************/
/*************************************************************************/

OPTIONS RESULTS  
NL = '0a'x
STAMP = 0
VAR_STRING = "SPOT_PATH SPOT_CONFIG USER_NAME BOSS_NAME USER_ADDRESS ",
             "BOSS_ADDRESS BBS_NAME BBS_LIST SEARCH_DIR ARCHIVE_NAME ",
             "ARCHIVE_DIR NETMAIL_AREA LOG_NAME"

signal on syntax
signal on failure     

/**********************************************************************/
/**************** Check for a current prefs file **********************/
/**********************************************************************/

IF ~EXISTS('S:BUNDLE.PREFS') THEN DO
        CALL rtezrequest('Can''t find S:BUNDLE.prefs,'NL,
                         'You must first run the Prefs'NL,
                         'editor to create a new prefs file....','OK','Bundle.prefs','rtez_flags = ezreqf_centertext',)
        NEW_PREFS = 1
        SIGNAL MAIN
        END

/**********************************************************************/
/************************ Opening requester ***************************/
/**********************************************************************/
COMMENCE:

CALL rtezrequest("Welcome to BUNDLE.spot"NL,
                 "What do you want to do ?","BUNDLE|CONFIGURE|ABOUT|QUIT"  ,"Bundle.spot","rtez_flags=ezreqf_centertext",)

IF rtresult = 0 THEN DO             /*    "QUIT"   */
              CALL FINISHED
              EXIT
              END
IF rtresult = 1 THEN DO             /* "  BUNDLE"  */
              CALL READ_IN
              CALL stamplog
              STAMP = 1
              END
IF rtresult = 2 THEN DO             /* "CONFIGURE" */
              SIGNAL MAIN_PREFS
              END
IF rtresult = 3 THEN SIGNAL ABOUT   /*   "ABOUT"   */

/************************************************************************/
/************** Open any necessary files for Reading/Writing  ***********/
/************************************************************************/

CALL OPEN(BBS,PREFS.8,READ)
CALL OPEN(fullpath,'T:fullpath.tmp',WRITE)
CALL OPEN(nopath,'T:nopath.tmp',WRITE)
                                                                        
     

/************************************************************************/
/****************  Check for SPOT and Run or Uniconify ******************/
/************************************************************************/

IF ~SHOW('PORTS','SPOT') THEN DO
SPOT_EXE =  PREFS.1||"Spot"
  ADDRESS COMMAND
  'RUN 'SPOT_EXE' CONFIGPATH 'PREFS.2
  'WaitForPort SPOT'
  QUIT = YES
END

ADDRESS 'SPOT'
'isiconified'
IF RC = 0 THEN DO
  ICON = YES
  'uniconify'
  END
'spot2front'
'lockgui'

/************************************************************************/
/**************************  Select the files ***************************/
/************************************************************************/

START:
DROP files files. ALL_FILES FILE_SIZE
CALL rtfilerequest(PREFS.9 ,, 'Bundle.spot' ,,'rt_pubscrname = SPOT rtfi_flags = freqf_multiselect', files)

IF files = 0 THEN DO
    call rtezrequest("No files selected" , " Abort " , "Bundle.spot.." , "rt_pubscrname=SPOT")
    CALL FINISHED
    SIGNAL COMMENCE
    END

IF files == 1 THEN DO
  CALL OPEN('REQ_TEXT','T:ReqText.tmp',WRITE) /* OPEN REQ_TEXT for WRITING  */
  DO i = 1 to files.count
  CALL WRITECH('REQ_TEXT',files.i NL)         /* Write ALL the files to it  */
  DROP files.i
  END



  CALL OPEN('REQ_TEXT','T:ReqText.tmp',READ)  /* OPEN REQ_TEXT for READING  */
  FILE_SIZE = SEEK('REQ_TEXT',0,'END')        /* Get number of CHARS in REQ_TEXT*/
  CALL SEEK('REQ_TEXT',0,'BEGIN')             /* Go to start of REQ_TEXT */
  ALL_FILES = READCH('REQ_TEXT',FILE_SIZE)    /* READ all the characters */
  CALL SEEK('REQ_TEXT',0,'BEGIN')             /* Return to start         */

   CALL rtezrequest(ALL_FILES, 'OK|RESELECT|ABORT'  ,  'You picked '||files.count||' files..' ,'rt_pubscrname = SPOT' ,CONFIRM)

   IF CONFIRM = 1 THEN DO               /* Pressed OK       */
            DROP CONFIRM
            CALL CLOSE('REQ_TEXT')
            IF EXISTS('T:ReqText.tmp') THEN DO
                IF FILES_BUNDLED = 1 THEN DO
                     address command
                     Delete 't:ReqText.tmp' QUIET
                     END
                END
            ADDRESS
            SIGNAL ALL_DONE
            END
   IF CONFIRM = 2 THEN DO               /* Pressed RESELECT */
            DROP CONFIRM
            CALL CLOSE('REQ_TEXT')
            IF EXISTS('T:ReqText.tmp') THEN DO
                address command
                Delete 't:ReqText.tmp' QUIET
                END
            SIGNAL START
            END
   IF CONFIRM = 0 THEN DO               /* Pressed ABORT    */
            DROP CONFIRM
            CALL CLOSE('REQ_TEXT')
            IF EXISTS('T:ReqText.tmp') THEN DO
                     address command
                     Delete 't:ReqText.tmp' QUIET
                     END
                END
            CALL FINISHED
            SIGNAL COMMENCE
            END


END

ALL_DONE:

list = ALL_FILES
total = files.count

/************************************************************************/
/*************  Begin extraction and searching routine ******************/
/************************************************************************/

ADDRESS SPOT
options results

'progressopen TITLE "Searching..." PROMPT "  "'
preq = result

misses = 0
hits = 0

DO i= 1 to total

  fullfile =  word(list,i)                                        /* Get name + full path */

  CALL Getfile(fullfile)                                          /* Extract name only via 'Getfile'  */
                                                                  /* returned in variable 'file'      */
'progressupdate' preq i total PROMPT "..."||file
IF rc = 5 THEN DO
      SEARCH_ABORT = 1
      CALL FINISHED
      SIGNAL COMMENCE
      END
CALL Checkbbs                                                     /* Check the BBS list               */
CALL Checklog                                                     /* Check the log file               */

   IF CHECK_LIST = 0 THEN DO              /* If not found, add to list   */
      CALL WRITELN(fullpath,fullfile)     /* for archiving and for log.  */
      CALL WRITELN(nopath,file)           /* Create the 'nopath' file    */
      misses = misses + 1
   END

   IF CHECK_LIST = 1 THEN DO         /* If found count as a 'hit'   */
      call rtezrequest(file||" already held or uploaded..","OK","Dupe report..","rt_pubscrname=SPOT")
      hits = hits +1
   END


END

'progressclose' preq

/************************************************************************/
/******************  Report any duplicates found ************************/
/************************************************************************/

SELECT
WHEN hits = 0 THEN call rtezrequest("No duplicates found", " Continue " , "Search report.." , "rt_pubscrname=SPOT")
WHEN hits =  total THEN DO
           call rtezrequest("All files already held or uploaded", " Exit " ,,"rt_pubscrname=SPOT")
           CALL FINISHED
           SIGNAL COMMENCE
           END
WHEN hits > 1 THEN call rtezrequest(hits||" duplicates found.." , " OK " , "Dupe report.." , "rt_pubscrname=SPOT")
WHEN hits == 1 THEN call rtezrequest("1 duplicate found"," OK " , "Dupe report.." , "rt_pubscrname=SPOT")
END

/************************************************************************/
/*********************  Start archiving options *************************/
/************************************************************************/

arcname = rtgetstring(PREFS.10,'Enter a name for the archive...',misses||" files for archiving",'OK|ABORT',"rt_pubscrname=SPOT")
IF arcname == "" THEN DO
           CALL FINISHED
           SIGNAL COMMENCE
           END
DROP RESPONSE
CALL rtgetstring(PREFS.11,arcname||'.lha will be placed in your '||PREFS.11||' directory.','Begin archiving..','OK|CHANGE DIRECTORY|ABORT',"rt_pubscrname=SPOT",RESPONSE)
IF RESPONSE = 0 THEN DO
        CALL FINISHED
        SIGNAL COMMENCE
        END
IF RESPONSE = 2 THEN DO
        DROP RESPONSE
        PREFS.11 = rtfilerequest(,,'Pick volume',,'rtfi_flags = freqf_nofiles rt_pubscrname=SPOT')
        END
/************************************************************************/
/*********************** Make log of files archived *********************/
/************************************************************************/

CALL SEEK(nopath,0,BEGIN)           /* Go to start of 'nopath' file  */
DO FOREVER
    sendfile = READLN(nopath)       /* Read each file in turn        */
    IF EOF(nopath) = 1 THEN LEAVE   /* If end of the file then leave */
    CALL WRITELN(log,sendfile)      /* Write the filename to the log */
END                                 /* Finished                      */
CALL CLOSE(nopath)                  /* Close the 'nopath' file       */
CALL WRITELN(log,'+------------------+')

/************************************************************************/
/********************* Commence archiving *******************************/
/************************************************************************/

CALL CLOSE(fullpath)

ADDRESS command
'lha -I a 'PREFS.11||arcname' @T:fullpath.tmp'

ADDRESS
IF EXISTS('T:fullpath.tmp') THEN DO
   ADDRESS COMMAND
   Delete 't:fullpath.tmp' QUIET
   END

/************************************************************************/
/********************* Write message for file attach ********************/
/************************************************************************/

ADDRESS SPOT
UPLOAD_BANNER = 'Bulk upload from 'PREFS.3' @ 'PREFS.5' to 'PREFS.7
CALL OPEN(nopath,'T:nopath.tmp',READ)    /* Open 'nopath' file for reading*/
CALL OPEN(message,'T:message.tmp',WRITE)
CALL WRITELN(message,UPLOAD_BANNER)
CALL WRITELN(message,NL)

/************************************************************************/
/************  Compile text file of files + descriptions ************** */
/************************************************************************/

CALL SEEK(nopath,0,BEGIN)           /* Go to the start of 'nopath' file */
DO FOREVER
       FILE = READLN(nopath)        /* Read each file from 'nopath'     */
       IF EOF(nopath) THEN DO       /* If end of 'nopath' reached then  */
            CALL CLOSE(nopath)      /* delete it and leave              */
            ADDRESS COMMAND
            'DELETE t:nopath.tmp QUIET'
            ADDRESS
            LEAVE
            END
       DESC = rtgetstring(,'Enter description for 'FILE,'Bundle.spot','OK' ,'rt_pubscrname = SPOT',)
       CALL WRITELN(message,FILE'............'DESC)
       CALL WRITELN(message,NL)
END  

CALL CLOSE(message)

/************************************************************************/
/******************** Write the message to the Sysop ********************/
/************************************************************************/

gotoarea PREFS.12
messages

subj_line = PREFS.11||arcname||'.lha'
temp_file = 'T:message.tmp'

'write TO "'PREFS.4'" TOADDR "'PREFS.6'" FROM "'PREFS.3'" SUBJECT "'subj_line'" FILE 'temp_file' NOEDIT NOGUI NOSIG'

lastmessage
setflags FILEATTACH

CALL FINISHED
ADDRESS COMMAND
DELETE 'T:message.tmp' QUIET
ADDRESS
FILES_BUNDLED = 1
SIGNAL COMMENCE

/************************************************************************/
/****************************  THE PREFS EDITOR *************************/
/************************************************************************/

MAIN_PREFS:

/*************************************************************************/
/**** Read the contents of the prefs file into the 'PREFS.' variable *****/
/* If NO current prefs file then assign NULL string to PREFS.1 - PREFS.13*/
/*************************************************************************/

IF ~EXISTS('S:BUNDLE.PREFS') THEN DO
        CALL rtezrequest('Cannot find S:BUNDLE.prefs,'NL'do you wish to create a new file?','OK|QUIT','Bundle.prefs','rtez_flags = ezreqf_centertext',)
            IF rtresult = 0 THEN DO
            CALL FINISHED
            SIGNAL COMMENCE
            END
               DO i = 1 to 13
               PREFS.i = ""
               END
            SIGNAL MAIN
        END

CALL READ_IN

/*************************************************************************/
/* Advise if current settings found and give option to edit or creat new */
/*************************************************************************/

CALL rtezrequest('S:BUNDLE.prefs found.'NL'Do you wish to edit current'NL'file or create a new prefs file?','EDIT|NEW|LEAVE','Bundle.prefs','rtez_flags = ezreqf_centertext',)

IF rtresult = 2 THEN DO           /*    File exists but selected "NEW"    */
              SIGNAL MAIN         /* Therefore DON'T set 'NEW_PREFS' flag */
              END
IF rtresult = 1 THEN SIGNAL EDIT      /* Pressed "EDIT"  */
IF rtresult = 0 THEN SIGNAL COMMENCE  /* Pressed "LEAVE" */

/*************************************************************************/
/******************* CHOOSE WHICH SETTING(S) TO EDIT *********************/
/*************************************************************************/

EDIT:   /*   The Reqrexxtools 'rtlong' requester  */

CUR_SET = "Enter the number of the item you wish to edit.."||NL

DO i = 1 to 13
  CUR_SET = CUR_SET||NL||"("i")      "||WORD(VAR_STRING,i)"    =    "||PREFS.i
END

number=rtgetlong(,VALUE('CUR_SET'),'Bundle.prefs','FINISHED','rtgl_min = 1 rtgl_max = 13',)


IF number = "" THEN DO
    EDIT_MARKER = 0
    CALL WRITE_PREFS             /* Nothing entered..pass save routine */
    END
IF number > 0 THEN DO            /* Pass to specific prefs routine     */
    EDIT_MARKER = 1
    OLD_SETTING.number = PREFS.number
    SIGNAL VALUE('PREFS_'||number)
    END
ELSE DO
   EDIT_MARKER = 0
   SIGNAL COMMENCE               /* Else go back to 'commence'         */
   END

/*************************************************************************/
/*************** The individual PREFS editors, numbered 1 -13 ************/
/*************************************************************************/

MAIN:

IF CUR_PREFS ~= 1 THEN DO
             DO i = 1 to 13
             PREFS.i = ""
             END
             END

PREFS_1:
MARKER = 1
CALL rtezrequest('Where can I find SPOT?..','Take me there..','Bundle.prefs','rtez_flags = ezreqf_centertext',)
PREFS.1 = rtfilerequest('SPOT:',,'Bundle.prefs','OK','rtfi_flags = freqf_nofiles',)
IF PREFS.1 == "" THEN DO
             STEP = PREFS_1
             CALL CHECK_QUIT
             END
IF ~EXISTS(PREFS.1||'SPOT') THEN DO
             CALL rtezrequest('Cannot find SPOT there..','Try again','ERROR',,)
             SIGNAL PREFS_1
             END

CALL ED_CHECK

PREFS_2:
MARKER = 2
CALL rtezrequest('Where can I find SPOT.prefs?..','Take me there..','Bundle.prefs','rtez_flags = ezreqf_centertext',)
PREFS.2 = rtfilerequest('SPOT:',,'Bundle.prefs','OK','rtfi_flags = freqf_nofiles',)
IF PREFS.2 == "" THEN DO
             STEP = PREFS_2
             CALL CHECK_QUIT
             END
IF ~EXISTS(PREFS.2||'SPOT.prefs') THEN DO
             CALL rtezrequest('Cannot find SPOT.prefs there..','Try again','ERROR',,)
             SIGNAL PREFS_2
             END 

CALL ED_CHECK

PREFS_3:
MARKER = 3
PREFS.3 = rtgetstring(PREFS.3,'Enter your full name..','Bundle.prefs','OK|CANCEL',,)
IF PREFS.3 == "" THEN DO
             STEP = PREFS_3
             CALL CHECK_QUIT
             END
CALL ED_CHECK

PREFS_4:
MARKER = 4
PREFS.4 = rtgetstring(PREFS.4,'Enter your bosses full name..','Bundle.prefs','OK|CANCEL',,)
IF PREFS.4 == "" THEN DO
             STEP = PREFS_4
             CALL CHECK_QUIT
             END
CALL ED_CHECK

PREFS_5:
MARKER = 5
PREFS.5 = rtgetstring(PREFS.5,'Enter your full 4D Fido address'NL'(e.g. 2:440/7.19)','Bundle.prefs','OK|CANCEL',,)
IF PREFS.5 == "" THEN DO
             STEP = PREFS_5
             CALL CHECK_QUIT
             END
IF INDEX(PREFS.5,":")=0|INDEX(PREFS.5,"/")=0|INDEX(PREFS.5,".")=0 THEN DO
             CALL rtezrequest('That is not a full 4D Fido address..','Try again','ERROR',,)
             SIGNAL PREFS_5
             END

CALL ED_CHECK




PREFS_6:
MARKER = 6
PREFS.6 = rtgetstring(PREFS.6,'Enter your Bosses full 4D Fido address'NL'(e.g. 2:440/7.0)','Bundle.prefs','OK|CANCEL',,)
IF PREFS.6 == "" THEN DO
             STEP = PREFS_6
             CALL CHECK_QUIT
             END
IF INDEX(PREFS.6,":")=0|INDEX(PREFS.6,"/")=0|INDEX(PREFS.6,".")=0 THEN DO
             CALL rtezrequest('That is not a full 4D Fido address..','Try again','ERROR',,)
             SIGNAL PREFS_6
             END   

CALL ED_CHECK



PREFS_7:
MARKER = 7
PREFS.7 = rtgetstring(PREFS.7,'Enter the full name of your BBS..','Bundle.prefs','OK|CANCEL',,)
IF PREFS.7 == "" THEN DO
             STEP = PREFS_7
             CALL CHECK_QUIT
             END
CALL ED_CHECK



PREFS_8:
MARKER = 8
CALL rtezrequest('Now you must select a file list'NL'for Bundle.spot to search..','OK','Bundle.prefs','rtez_flags = ezreqf_centertext',)
PREFS.8 = rtfilerequest(,,'Bundle.prefs','OK',,)
IF ~EXISTS(PREFS.8) THEN DO
             CALL rtezrequest('Cannot find the specified file list...','Try again','ERROR',,)
             SIGNAL PREFS_8
             END
IF PREFS.8 == "" THEN DO
             STEP = PREFS_8
             CALL CHECK_QUIT
             END
CALL ED_CHECK



PREFS_9:
MARKER = 9
CALL rtezrequest('Now you must select the default directory'NL'from which to select your files..','OK','Bundle.prefs','rtez_flags = ezreqf_centertext',)
PREFS.9 = rtfilerequest(,,'Bundle.prefs','OK','rtfi_flags = freqf_nofiles',)
IF PREFS.9 == "" THEN DO
             STEP = PREFS_9
             CALL CHECK_QUIT
             END
CALL ED_CHECK



PREFS_10:
MARKER = 10
PREFS.10 = rtgetstring(PREFS.10,'Enter a default name for your archived files..','Bundle.prefs','OK|CANCEL',,)
PREFS.10 = COMPRESS(PREFS.10)
IF PREFS.10 == "" THEN DO
             STEP = PREFS_10
             CALL CHECK_QUIT
             END
CALL ED_CHECK



PREFS_11:
MARKER = 11
CALL rtezrequest('Now you must select the default directory'NL'in which to place the archived files..','OK','Bundle.prefs','rtez_flags = ezreqf_centertext',)
PREFS.11 = rtfilerequest(,,'Bundle.prefs','OK','rtfi_flags = freqf_nofiles',)
IF PREFS.11 == "" THEN DO
             STEP = PREFS_11
             CALL CHECK_QUIT
             END
CALL ED_CHECK



PREFS_12:
MARKER = 12
PREFS.12 = rtgetstring(PREFS.12,'Now enter the Fidonet Netmail area in which'NL,
                        'to address the message to your boss.'NL,
                        '*THIS MUST BE EXACTLY AS IT APPEARS IN SPOT*'NL,
                        '*AND SHOULD ALSO BE A NETMAIL/MATRIX AREA*'NL,
                        'If you wish I will start SPOT and allow you'NL,
                        'to select it from there..','Bundle.prefs','OK|START SPOT|CANCEL','rtez_flags = ezreqf_centertext',)
IF rtresult = 2 THEN CALL START_SPOT
IF PREFS.12 == "" THEN DO
             STEP = PREFS_12
             CALL CHECK_QUIT
             END
CALL ED_CHECK



PREFS_13:
MARKER = 13
CALL rtezrequest('Now you must select a directory and'NL'enter a name for your log file.'NL'The default is S:Bundle.log','OK','Bundle.prefs','rtez_flags = ezreqf_centertext',)
PREFS.13 = rtfilerequest('S:','Bundle.log','Bundle.prefs','OK',,)
IF PREFS.13 == "" THEN DO
             STEP = PREFS_13
             CALL CHECK_QUIT
             END
CALL ED_CHECK

/*************************************************************************/
/************* Write the PREFS settings to S:BUNDLE.prefs ****************/
/*************************************************************************/

CALL WRITE_PREFS
CALL rtezrequest('Bundle.prefs finished, you are now free'NL'to enjoy the delights of Bundle.spot!','EXIT','Goodbye from Bundle.prefs!','rtez_flags = ezreqf_centertext',)

SIGNAL READ_IN

/*************************************************************************/
/********************* PREFS EDITOR PROCEDURES ***************************/
/*************************************************************************/
READ_IN:

    CALL OPEN('PREFS_FILE','S:Bundle.prefs',READ)
    i = 1
    DO FOREVER
      ITEM =  READLN('PREFS_FILE')
      SELECT
        WHEN INDEX(ITEM,"#") THEN ITERATE
        WHEN EOF('PREFS_FILE') THEN LEAVE
        WHEN ITEM = "" THEN ITERATE
        OTHERWISE NOP
      END
   PREFS.i = ITEM
   i = i + 1
   END
CALL CLOSE('PREFS_FILE')

/*  IF CORRUPT  */

IF i ~= 14 THEN DO
      CORRUPT = 1
      EDIT_MARKER = 0
      CALL rtezrequest("*ERROR*"NL,
                       "S:Bundle.prefs appears corrupt"NL,
                       "Please run Prefs editor to create"NL,
                       "a new Prefs file.","OK","ERROR in S:Bundle.prefs","rtez_flags = ezreqf_centertext",)
              DO i = 1 to 13
              PREFS.i = ""
              END
      SIGNAL MAIN
      END
RETURN

        


ED_CHECK:
IF EDIT_MARKER = 1 THEN DO
        EDIT_MARKER = 0
        SIGNAL EDIT
        END
ELSE RETURN



WRITE_PREFS:
CALL rtezrequest("Save settings to S:Bundle.prefs?","YES PLEASE|NO THANKS","Bundle.spot","rtez_flags=ezreqf_centertext",)
IF rtresult = 0 THEN SIGNAL COMMENCE
CALL OPEN('PREFS_FILE','S:Bundle.prefs',WRITE)
DO i = 1 to 13
CALL WRITELN('PREFS_FILE',"#"WORD(VAR_STRING,i))
CALL WRITELN('PREFS_FILE',PREFS.i)
END
CALL CLOSE('PREFS_FILE')
CALL rtezrequest('Settings saved to S:BUNDLE.prefs..','OK' ,'Bundle.Prefs',,)
DROP NEW_PREFS
DROP CORRUPT
SIGNAL COMMENCE
RETURN


CHECK_QUIT:
DROP CONFIRM
CALL rtezrequest('You entered nothing..'||NL||'Leave or try again?','Again|Leave','Bundle.prefs',,CONFIRM)



IF CONFIRM = 1 & CORRUPT = 1 THEN DO           /* Pressed 'AGAIN' & flagged  */
            SIGNAL VALUE(STEP)                 /* 'corrupt'                  */
            END  
IF CONFIRM = 0 & CORRUPT = 1 THEN DO           /* Pressed 'LEAVE' & flagged  */
            CALL FINISHED                      /* 'corrupt'                  */
            SIGNAL COMMENCE
            END
IF CONFIRM = 1 & EDIT_MARKER = 1 THEN DO       /* Pressed 'AGAIN' and called */
            PREFS.MARKER = OLD_SETTING.MARKER  /* From 'EDIT'                */
            DROP EDIT_MARKER
            SIGNAL VALUE(STEP)
            END
IF CONFIRM = 0 & EDIT_MARKER = 1 THEN DO       /* Pressed 'LEAVE' and called */
            PREFS.MARKER = OLD_SETTING.MARKER  /* From 'EDIT'                */
            DROP EDIT_MARKER
            SIGNAL EDIT
            END
IF CONFIRM = 1 & NEW_PREFS = 1 THEN DO         /* Pressed 'AGAIN' and called */
            SIGNAL VALUE(STEP)                 /* from "NEW"                 */
            END   
IF CONFIRM = 0 & NEW_PREFS = 1 THEN DO         /* Pressed 'LEAVE' and called */
            CALL FINISHED                      /* from 'NEW'                 */
            EXIT
            END
IF CONFIRM = 1 THEN DO                         /* Pressed 'AGAIN'            */
            SIGNAL VALUE(STEP)
            END
IF CONFIRM = 0 THEN DO                         /* Pressed 'LEAVE'            */
            CALL FINISHED
            SIGNAL COMMENCE
            END
RETURN




START_SPOT:
SPOT_EXE =  PREFS.1||"Spot"

IF ~SHOW('ports','SPOT') THEN DO
  ADDRESS COMMAND
  'RUN 'SPOT_EXE' CONFIGPATH '||PREFS.2
  'WaitForPort SPOT'
  QUIT = YES
END

ADDRESS 'SPOT'
OPTIONS RESULTS
'isiconified'
IF RC = 0 THEN DO
  ICON = YES
  'uniconify'
END
'spot2front'
'isarealist'
IF RC = 5 THEN DO
  'arealist'
END

'requestarea TITLE "Bundle.prefs" ALL'
PREFS.12 = RESULT
IF ICON = YES THEN DO
     'ICONIFY NOREQ NOSAVE'
     END
IF QUIT = YES THEN DO
     'QUITSPOT NOREQ NOSAVE'
     END
RETURN  


/************************************************************************/
/****************************  BUNDLE PROCEDURES ************************/
/************************************************************************/

ABOUT:
CALL rtezrequest("BUNDLE.spot Version 1.3"NL,
                 "by Steve Collins"NL,
                 "30-4-1995"NL NL,
                 "If you find this script useful "NL,
                 "OR"NL,
                 "you want to report a bug then"NL,
                 "please drop me a line at either.."NL NL,
                 "email- steve@stuffs.demon.co.uk"NL,
                 "or"NL,
                 "Fidonet- 2:257/99.3 or 2:440/7.19"NL NL,
                 "..and I'll also let you know of all updates"NL NL,
                 "Thanks.....","OK","BUNDLE.spot","rtez_flags=ezreqf_centertext",)
SIGNAL COMMENCE

CHECKBBS:
    CHECK_LIST = 0
    CALL SEEK(BBS,0,BEGIN)       /*  Check the BBS list  */
    DO WHILE EOF(BBS) ~= 1
       text= READLN(BBS)
              IF INDEX(text,file) ~= 0 THEN DO
              CHECK_LIST = 1
              LEAVE
              END
    END
    RETURN

CHECKLOG:
    CALL SEEK(log,0,BEGIN)      /*  Check the upload log */
    DO WHILE EOF(log) ~= 1
      text = READLN(log)
             IF INDEX(text,file) ~= 0 THEN DO
             CHECK_LIST = 1
             LEAVE
             END
    END
    RETURN

GETFILE:
    hit = LASTPOS(':',fullfile)
    IF hit ~== 0 THEN file=DELSTR(fullfile,1,hit)
    hit = LASTPOS('/',file)
    IF hit ~== 0 THEN file=DELSTR(file,1,hit)
    RETURN file

STAMPLOG:
    DATE_STAMP = date()
    TIME_STAMP = time('C')
    IF EXISTS(PREFS.13) THEN DO
       CALL OPEN(log,PREFS.13,APPEND)
       CALL WRITELN(log,'Bundle.rexx started on 'DATE_STAMP' at 'TIME_STAMP)
       END
    ELSE DO
       CALL OPEN(log,PREFS.13,WRITE)
       CALL WRITELN(log,'New log started-'DATE_STAMP' at 'TIME_STAMP)
       END 
    RETURN


FINISHED:
FAILURE:

IF STAMP = 1 THEN DO
   DROP STAMP
   CALL SEEK(log,0,END)
   CALL WRITELN(log,'+------------------+')
   END

DROP total
DROP hits
DROP misses
DROP ALL_FILES

CALL CLOSE('fullpath')
CALL CLOSE('nopath')

IF FILES_BUNDLED = 1 THEN DO
      IF EXISTS('T:nopath.tmp') THEN DO
        address command
        Delete 't:nopath.tmp' QUIET
        END
     IF EXISTS('T:fullpath.tmp') THEN DO
        address command
        Delete 't:fullpath.tmp' QUIET
        END
     IF EXISTS('T:ReqText.tmp') THEN DO
        address command
        Delete 't:ReqText.tmp' QUIET
        END
FILES_BUNDLED = 0
END


ADDRESS SPOT
IF SHOW('PORTS','SPOT') THEN DO
   ADDRESS SPOT
    'unlockgui'
    IF PREQ ~= 'PREQ' THEN
    'progressclose' PREQ    

   DROP response
    IF ICON == "YES" THEN DO
      DROP ICON
      CALL rtezrequest("Re-iconify Spot?","Iconify|Don't Iconify","Bundle.spot finished..","rt_pubscrname=SPOT",response)
           IF response = 1 THEN iconify NOREQ NOSAVE
           ELSE SIGNAL COMMENCE
           END
    IF QUIT == "YES" THEN DO
      DROP QUIT
      CALL rtezrequest("Quit Spot?","Quit|Don't Quit","Bundle.spot finished..","rt_pubscrname=SPOT",response)
           IF response = 1 THEN quitspot NOREQ NOSAVE
           ELSE SIGNAL COMMENCE
           END
END

RETURN

SYNTAX:
SAY '*SYNTAX ERROR*' C ERRORTEXT(RC) 'IN LINE' SIGL
RETURN









