;RSETUP.INC Setup utility for OFFLINE.WAX replies.

;*****************************************************************************
;*                                                                           *
;* RSETUP.INC                                                                *
;* Copyright (C) 1996 Datastorm Technologies, Inc.                           *
;* All rights reserved.                                                      *
;*                                                                           *
;* This script allows the user to configure reply options for OFFLINE.WAX.   *
;*                                                                           *
;* This ASPECT SCRIPT is intended only as a sample of ASPECT programming.    *
;* DATASTORM makes no warranty of any kind, express or implied, including    *
;* without limitation, any warranties of merchantability and/or fitness      *
;* for a particular purpose.  Use of this program is at your own risk.       *
;*****************************************************************************



;****************************************************************************
;*     GLOBAL VARIABLES                                                     *
;****************************************************************************

string Offline_INI                     ;Full path to the .INI file.
integer ZoneSelect                     ;Time-zone selected to the 



proc RSetup

;*****************************************************************************
;*                                                                           *
;* RSETUP                                                                    *
;* Copyright (C) 1996 Datastorm Technologies, Inc.                           *
;* All rights reserved.                                                      *
;*                                                                           *
;* This procedure creates/edits the INI file for OFFLINE.WAX.                *
;*                                                                           *
;* Calls: CleanUp                                                            *
;* Called by: Main, Selection, ServerConnect, Delivery, Results              *
;*                                                                           *
;*****************************************************************************


   string NewsServerName               ;News server address.
   string MailServerName               ;Mail server address.
   string ReplyName                    ;User-configured 'posting' alias.
   string UserEMail                    ;User's e-mail address.
   string ReplyPrefix                  ;Text to precede quoted lines.
   string ReplySuffix                  ;Text to follow quoted lines.
   string SigFile                      ;Filespec of signature file.
   string QuotePrefix                  ;Text to precede all quoted lines.
   string Message                      ;Text field in message dialogs.
   string QuoteLines                   ;Number of original lines to quote.
   integer LinesToQuote                ;Number of original lines to quote.
   integer UseSuperTCP                 ;Tells script whether to use SUPERTCP.
   integer Initializing                ;Loop for main dialog.
   integer Looping                     ;Loop for dlg event checking.
   integer Event                       ;Current dialog event.
   integer DlgID                       ;Windows ID of the dialog box.
   integer StillThere                  ;Checks for presence of dialog box.
   integer FoundINI                    ;TRUE when .ini file already exists.
   integer Choice                      ;User choice in message dialogs.
   
   
   
   strfmt Offline_INI "%s`\OFFLINE.INI" $PWLOCALPATH
                                       ;Format filespec for .ini file.
   isfile Offline_INI FoundINI         ;See if the .ini file already exists.
   
   if ! FoundINI                       ;If the .ini file does not exist,
      fetch news serveraddress NewsServerName
                                       ;Get news server from setup.
      fetch mail serveraddress MailServerName
                                       ;Get mail server from setup.
      fetch news username ReplyName    ;Get user name from setup.
      fetch mail address UserEMail     ;Get email address from setup.
      strcpy ReplyPrefix "This line precedes quoted text....."
                                       ;Initialize reply prefix.
      strcpy ReplySuffix ".....and this line follows quoted text."
                                       ;Initialize reply suffix.
      strfmt SigFile "%s`\SIG.TXT" $PWLOCALPATH
                                       ;Format filespec for sig file.
      ZoneSelect = 5                   ;
      QuotePrefix = ">"
      QuoteLines = "100"
      UseSuperTCP = 1
   else                                ;Read parameters from .ini if found.
      profilerd Offline_INI "PostReply" "NewsServer" NewsServerName
      profilerd Offline_INI "PostReply" "MailServer" MailServerName
      profilerd Offline_INI "PostReply" "UserName" ReplyName
      profilerd Offline_INI "PostReply" "EMailAddress" UserEMail
      profilerd Offline_INI "PostReply" "ReplyPrefix" ReplyPrefix
      profilerd Offline_INI "PostReply" "ReplySuffix" ReplySuffix
      profilerd Offline_INI "PostReply" "QuotePrefix" QuotePrefix
      profilerd Offline_INI "PostReply" "QuoteLines" LinesToQuote
      itoa LinesToQuote QuoteLines
      profilerd Offline_INI "PostReply" "Signature" SigFile
      profilerd Offline_INI "PostReply" "TimeZone" ZoneSelect
      profilerd Offline_INI "PostReply" "UseSuperTCP" UseSuperTCP
   endif
   
   Initializing = 1
   while Initializing
   
      dialogbox 70 99 67 314 251 7 "PROCOMM PLUS 3.0 Off-line News Reader - \
Setup Utility"
         groupbox 1 225 9 77 61 "Time Zone"
         radiogroup 11 ZoneSelect
            radiobutton 2 230 22 32 10 "EST"
            radiobutton 3 230 33 32 10 "EDT"
            radiobutton 4 230 44 32 10 "CST"
            radiobutton 5 230 54 32 10 "CDT"
            radiobutton 6 265 22 32 10 "MST"
            radiobutton 7 265 33 32 10 "MDT"
            radiobutton 8 265 44 32 10 "PST"
            radiobutton 9 265 55 32 10 "PDT"
         endgroup
         editbox 12 18 13 185 13 NewsServerName
         editbox 31 18 47 185 13 MailServerName
         editbox 13 18 81 185 13 ReplyName
         editbox 14 18 115 185 13 UserEMail
         editbox 15 18 149 185 13 ReplyPrefix
         editbox 16 18 183 185 13 ReplySuffix
         editbox 17 18 217 185 13 SigFile
         groupbox 19 10 2 200 32 "News Server"
         groupbox 10 10 36 200 32 "Mail Server"
         groupbox 20 10 70 200 32 "User Name"
         groupbox 21 10 104 200 32 "E-mail Address"
         groupbox 22 10 138 200 32 "Reply Prefix"
         groupbox 23 10 172 200 32 "Reply Suffix"
         groupbox 24 10 206 200 32 "Signature File"
         groupbox 25 225 80 77 32 "Quote Prefix"
         text 26 226 116 78 35 "Reply Prefix and Suffix use %s for article\
 originator, and %u for user name." LEFT
         pushbutton 27 230 212 70 14 "Save Setup" DEFAULT
         pushbutton 28 230 228 70 14 "Exit Without Saving"
         text 29 234 153 67 8 "Max Lines to Quote:" LEFT
         editbox 30 249 163 32 12 QuoteLines 3
         editbox 18 240 92 51 12 QuotePrefix 5
         checkbox 32 231 186 8 10 "" UseSuperTCP
         text 33 242 186 60 17 "Use PROCOMM's stack and dialer." LEFT
      enddialog
      dlgwin 70 DlgID
      Looping = 1
      while Looping
         dlgevent 70 Event
         switch Event
            case 1
            case 2
            case 3
            case 4
            case 5
            case 6
            case 7
            case 8
            case 9
            case 10
            case 11
            case 12
            case 13
            case 14
            case 15
            case 16
            case 17
            case 18
            case 19
            case 20
            case 21
            case 22
            case 23
            case 24
            case 25
            case 26
            endcase                    ;Ignore everything but Save and Exit.
            case 27                    ;If Save is chosen,
               dlgdestroy 70 OK
               if ! FoundINI           ;Create the .ini if not found.
                  fopen 70 Offline_INI CREATE
                  while FAILURE
                     Choice = 8
                     strfmt Message "Unable to open file:`r`n`r`n%s" Offline_INI
                     sdlgmsgbox "File Error!" Message EXCLAMATION RETRYCANCEL Choice
                     if Choice != 4
                        CleanUp()
                     endif
                     fopen 70 Offline_INI CREATE
                  endwhile
               endif
               atoi QuoteLines LinesToQuote
               if LinesToQuote > 200
                  LinesToQuote = 200
               elseif LinesToQuote < 0
                  LinesToQuote = 0
               endif  
                                       ;Write paramters to the .ini file.
               profilewr Offline_INI "PostReply" "NewsServer" NewsServerName
               profilewr Offline_INI "PostReply" "MailServer" MailServerName
               profilewr Offline_INI "PostReply" "UserName" ReplyName
               profilewr Offline_INI "PostReply" "EMailAddress" UserEMail
               profilewr Offline_INI "PostReply" "ReplyPrefix" ReplyPrefix
               profilewr Offline_INI "PostReply" "ReplySuffix" ReplySuffix
               profilewr Offline_INI "PostReply" "QuotePrefix" QuotePrefix
               profilewr Offline_INI "PostReply" "QuoteLines" LinesToQuote
               profilewr Offline_INI "PostReply" "Signature" SigFile
               profilewr Offline_INI "PostReply" "TimeZone" ZoneSelect
               profilewr Offline_INI "PostReply" "UseSuperTCP" UseSuperTCP
            endcase
            case 28
               dlgdestroy 70 CANCEL
               Looping = 0
               Initializing = 0
            endcase
            case 31
            endcase
            default
               winexists DlgID StillThere
               if ! StillThere
                  Looping = 0
                  Initializing = 0
               endif
            endcase
         endswitch
      endwhile
   endwhile
endproc
            


