;create a FAXSEND command line

;*****************************************************************************
;*                                                                           *
;* FaxCommand.WAS                                                            *
;* Copyright (C) 1998 Symantec Corp.						                             *
;* All rights reserved.                                                      *
;*                                                                           *
;* The script will create a FAXSEND command line after the user chooses      *
;* any combination of options.  The dialog box is arranged with Group Boxes  *
;* and radio buttons to help delineate the choices.                          *
;* Where feasible, the input is checked --                                   *
;* Does the coversheet file exist?                                           *
;* Is is a valid connection directory entry?                                 *
;* Did the user enter the time in a valid format?                            *
;* This script is intended primarily to help a programmer learn about the    *
;* faxsend command and also about Dialog Boxes.  Thus, there are many        *
;* comments about how commands work and why programming choices were made.   *                            *
;*                                                                           *
;* This ASPECT SCRIPT is intended only as a sample of ASPECT programming.    *
;* Symantec 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                                                        *
;*****************************************************************************
integer radio100             ;how to select the modem
integer radio200             ;how to dial
integer radio300             ;coversheet?
integer radio400             ;which file to fax
integer Radio500             ;when to send
string ModemIndex            ;index number of the modem
string ModemName             ;name of the modem
string Faxto                 ;name of fax recipient
string FaxDial               ;number to dial for fax recipient
string ConnDirEntry          ;entry in the connection directory
string CoverSheetName        ;name of the coversheet file
string NoteString            ;string to contain the note
string TimeFax               ;time to send the fax
string DateFax               ;date to send the fax
string SingleFileFax         ;name of the file to fax
string MultiFileFax          ;name of file that contains list of files to fax
string MemoFaxFile           ;name of the text file with the memo
string CoverPath             ;current coversheet path
string OutBoxPath            ;current out box path
integer GroupCheck           ;is connection directory entry a group?
integer NoteCheck            ;include a note on the coversheet?
integer BinaryCheck          ;is this a binary file transfer?


;*****************************************************************************
;*                                                                           *
;* MAIN                                                                      *
;* The Main procedure calls GetFaxSettings to retrieve coversheet settings   *
;* and the current date and time.  Then it calls FaxChoices to display the   *
;* Fax Command dialog window.  The WHEN dialog command is also initialized.  *
;*                                                                           *
;* Calls: GetFaxSettings, FaxChoices                                         *
;* Modifies globals: none                                                    *
;*                                                                           *
;*****************************************************************************
proc main
                   ;call a procedure to process the events in Dialog Box 0
   when dialog 0 call Handler0
                   ;get the current coversheet settings and date/time
	GetFaxSettings ()
	                ;display the dialog box
   FaxChoices()
   
endproc



;*****************************************************************************
;*                                                                           *
;* GetFaxSettings                                                            *
;* The procedure GetFaxSettings retrieves the current coversheet settings    *
;* and the present date and time. The faxsend command will use the current   *
;* Setup Options if none are specified so it is a good idea to tell the user *
;* what the current setting are. Also, the current date and time are obtained*
;* here to use in the edit boxes to show the user what format they are in.   *
;*                                                                           *
;* Calls: none                                                               *
;* Called by: Main                                                           *
;* Modifies globals: CoverSheetName, Radio300, TimeFax, DateFax              *
;*                                                                           *
;*****************************************************************************
proc GetFaxSettings
                   ; get the current coversheet
	fetch fax coversheet CoverSheetName
	                ;if the default is NONE, then set the appropriate radio
	                ;button and blank out the edit box
	if strfind CoverSheetName "None"
		Radio300 = 302
		CoverSheetName = ""
		             ;if there is a chosen coversheet, use it in the edit box 
		             ;and set the radio button
	else 
		radio300 = 301
	endif
	                ;get the current time and date so we can use them in the
	                ;edit boxes as templates.
	TimeFax = $TIME
	DateFax = $DATE

endproc



;*****************************************************************************
;*                                                                           *
;* FaxChoices                                                                *
;* The procedure FaxChoices create the main dialog box for the creation of   *
;* the sendfax command.                                                      *
;*                                                                           *
;* Calls: none                                                               *
;* Called by: Main                                                           *
;* Modifies globals: Radio200, Radio100, ModemIndex, ModemName, FaxTo,       *
;*     FaxDial, ConnDirEntry, GroupCheck, Radio300, CoverSheetName,          *
;*     NoteCheck, NoteString, Radio400, SingleFileFax, MultiFileFax,         *
;*     MemoFaxFile, BinaryCheck, Radio500, TimeFax, DateFax                  *
;*                                                                           *
;*****************************************************************************
proc FaxChoices

                   ;
                   ;Create a dialog box with a style of 74 = 64 + 8 + 2
                   ;64 = suspend the script while the dialog box is displayed
                   ; 8 = trap exit methods
                   ; 2 = movable with caption
	dialogbox 0 7 17 529 315 74 "FaxSend Command" 
                   ;The group box surrounds all the choices for choosing the
                   ;modem and the recipient
   	groupbox 5 2 7 240 272 "Who and How to Dial" 
                   ;the two main choices are to specify a modem and a recipient
                   ;with a fax number or to specify a dialing directory entry
	   radiogroup 200 radio200
   	   radiobutton 201 9 26 78 11 "Specify Modem" 
      	radiobutton 202 11 189 80 11 "Dialing Directory" 
	   endgroup
                   ;this is the group box for specifying the modem
   	groupbox 1 26 46 210 135 
                   ;the modem may be specified 4 different ways
	   radiogroup 100 Radio100
   	   radiobutton 101 31 60 42 11 "Index" 
      	radiobutton 102 31 80 57 11 "Modem Name" 
	      radiobutton 103 31 106 64 11 "Current Modem" 
   	   radiobutton 104 31 123 73 11 "First Available" 
	   endgroup
                   ;if you choose to use the modem index then this is where
                   ;it is written
   	editbox 3 103 61 34 11 ModemIndex 
                   ;if you want to use the modem name then this is where you
                   ;write it
	   editbox 4 103 82 125 11 ModemName 
                   ;no matter how you specify the modem you must give the
                   ;recipient and the fax number
	   editbox 35 103 143 125 11 FaxTo 
   	editbox 36 103 163 125 11 FaxDial 
	   text 7 31 143 18 11 "To:" left 
   	text 11 31 160 46 11 "Fax Number:" left 
                   ;this group box goes around the connection directory choices
	   groupbox 34 26 202 210 56 
                   ;the connection directory entry will be checked later to be 
                   ;sure it exists
   	editbox 8 105 218 125 11 ConnDirEntry 
	   text 9 31 220 34 11 "Entry:" left 
                   ;use this checkbox if the entry is a group so we will know
                   ;to dial all members of the group
   	checkbox 10 31 239 42 11 "Group" GroupCheck
                   ;this group box encloses the choices for what to send
	   groupbox 31 270 7 250 225 "What to Send"
                   ;group box for coversheet choices 
   	groupbox 46 281 18 234 95 "Cover Sheet" 
                   ;the user can choose a coversheet or not
	   radiogroup 300 radio300
   	   radiobutton 301 287 35 57 11 "Cover Sheet" 
      	radiobutton 302 287 55 70 11 "No Cover Sheet" 
	   endgroup
                   ;the initial entry in this edit box is the current
                   ;coversheet, if there is one in Setup, or it is blank
   	editbox 33 355 37 105 11 CoverSheetName 
                   ;if you don't know the exact name of a file, this will
                   ;activate a Standard Browse box.
	   pushbutton 50 470 37 40 11 "Browse"
                   ;use this check box if you want to include a Note on
                   ;the coversheet
   	checkbox 44 300 75 42 11 "Note" NoteCheck
                   ;enter the Note in this edit box
	   editbox 18 355 70 155 40 NoteString MULTILINE
                   ;this group box surrounds the choices for the files to fax
   	groupbox 21 281 120 234 100 "Fax File" 
                   ;there are 3 choices for which files to fax
	   radiogroup 400 Radio400
   	   radiobutton 401 287 135 42 11 "Single" 
      	radiobutton 402 287 155 42 11 "Multiple" 
	      radiobutton 403 287 175 54 11 "Memo Fax" 
   	endgroup
                   ;you can enter a file name, which will be checked for
                   ;validity later, or you can browse to find a file
	   editbox 49 355 135 105 11 SingleFileFax 
   	pushbutton 51 470 135 40 11 "Browse"
                   ;You can enter the name of a text file which has the 
                   ;names of the multiple files to fax or you can browse
                   ;to select the files
	   editbox 40 355 155 105 11 MultiFileFax
   	pushbutton 52 470 155 40 11 "Browse"
                   ;use this checkbox if there should be a binary file transfer 
                   ;instead of a fax send
	   checkbox 41 287 195 58 11 "Binary File" BinaryCheck
                   ;enter the name of the text file with the Memo or you
                   ;can browse
   	editbox 13 355 175 105 11 MemoFaxFile 
	   pushbutton 53 470 175 40 11 "Browse"
                   ;group box to surround the time choices
   	groupbox 14 270 239 250 70 "When to send" 
                   ; the choices are now or later
	   radiogroup 500 Radio500
   	   radiobutton 15 287 250 42 11 "Now" 
      	radiobutton 16 287 270 42 11 "Later" 
	   endgroup
                   ;the time and date have been filled in as the current
                   ;time and date in order to give the user a template for 
                   ;the formats.  These entries will be checked later for
                   ;validity.
   	editbox 17 315 290 55 11 TimeFax
	   editbox 48 415 290 55 11 DateFax
   	text 208 290 290 22 11 "Time" left 
   	text 209 390 290 22 11 "Date" left 
	                 ;If you choose exit, you will exit the program immediately
   	pushbutton 19 217 290 40 13 "Exit" CANCEL 
                   ;if you choose OK, the script will process the contents
                   ;of the window edit boxes, etc.  Where possible, the
                   ;entries will be checked for validity.  If there are
                   ;problems, the user will be returned to this dialog box
                   ;with all the current contents intact.
	   pushbutton 20 118 290 40 13 "OK" OK DEFAULT
                   ;if you choose clear, all the contents of the edit boxes,
                   ;check boes, etc., will be cleared and the dialog box
                   ;will appear as it did when you first entered the script.
   	pushbutton 22 18  290 40 13 "Clear"
	enddialog 
			
endproc



;*****************************************************************************
;*                                                                           *
;* Handler0                                                                  *
;* The procedure Handler0 processes events from Dialog Box 0. Only the events*
;* which require immediate response are responded to.  The edit boxes, check *
;* boxes, etc., which have contents for the faxsend command are evaluated    *
;* only after the OK button has been pressed.                                *
;*                                                                           *
;* Calls: CreateFaxSendCommand                                               *
;* Called by: Main                                                           *
;* Modifies globals: ModemIndex, ModemName, FaxTo, FaxDial, CoverSheetName,  *
;*     NoteString, SingleFileFax, MultiFileFax, MemoFaxFile, TimeFax,        *
;*     DateFax, CoverPath, OutBoxPath                                        *
;*                                                                           *
;*****************************************************************************
proc Handler0
integer Event0               ;which element caused an event in Dialog Box 0
string FName                 ;temporary variable to create file names

                   ;find out which event happened
	dlgevent 0 Event0
	
	                ;make decisions based on the event
	switch Event0
	                ;OK button so go create the fax send command
		case 20
			CreateFaxSendCommand ()
		endcase
		             ;exit button so exit the script immediately
		case 19
			exit
		endcase
		             ;clear button so reset all the edit boxes.
		             ;The method here is to set the variable to " " then
		             ;update the element. The exception to this is TimeFax
		             ;and DateFax which are reset to the current time and
		             ;date.
		case 22
			ModemIndex = " "
			ModemName = " "
			dlgupdate 0 3 4
			FaxTo = " "
			FaxDial = " "
			dlgupdate 0 35 36
			CoverSheetName = " "
			dlgupdate 0 33
			NoteString = " "
			dlgupdate 0 18
			SingleFileFax = " "
			MultiFileFax = " "
			dlgupdate 0 40
			dlgupdate 0 49
			MemoFaxFile = " "
			dlgupdate 0 13
			TimeFax = $TIME
			dlgupdate 0 17
			DateFax = $DATE
			dlgupdate 0 48
		endcase
		             ;browse button for coversheet
		             ;find out the path for the coversheets and change to 
		             ;that directory.  Then open a standard file open box
		             ;to allow the user to choose a coversheet.
		case 50
			fetch fax path coversheet CoverPath
			chdir CoverPath
			sdlgfopen "Coversheets" "*.cvr" SINGLE FName
			getfilename CoverSheetName FNAME
			dlgupdate 0 33
		endcase
		             ;browse button for single file to fax
		             ;retrieve the Out Box Path because that is the default
		             ;for this command.  Change to that directory and open a
		             ;standard file open box.  The user can choose a file in
		             ;this or any other directory.  The full path is retained
		             ;in either case.
		case 51
			fetch fax path outbox OutBoxPath
			chdir OutBoxPath
			sdlgfopen "File to Fax" "*.fax" SINGLE SingleFileFax
			dlgupdate 0 49
		endcase
		             ;browse button for multiple files to fax
		             ;retrieve the Out Box Path because that is the default
		             ;for this command.  Change to that directory and open a
		             ;standard file open box.  The user can choose a file in
		             ;this or any other directory.  The full path is retained
		             ;in either case.  Since MULTIPLE is specified for this
		             ;element, it returns the name of the file which has the
		             ;multiple files listed in it.  This is the same thing
		             ;which is needed for faxing multiple faxes.
		case 52
			fetch fax path outbox OutBoxPath
			chdir OutBoxPath
			sdlgfopen "Files to Fax" "*.fax" MULTIPLE MultiFileFax
			dlgupdate 0 40
		endcase
		             ;browse button for memo fax
		             ;retrieve the Out Box Path because that is the default
		             ;for this command.  Change to that directory and open a
		             ;standard file open box.  The user can choose a file in
		             ;this or any other directory.  The full path is retained
		             ;in either case.
		case 53
			fetch fax path outbox OutBoxPath
			chdir OutBoxPath
			sdlgfopen "Memo to Fax" "*.txt" SINGLE MemoFaxFile
			dlgupdate 0 13
		endcase
	endswitch

endproc



;*****************************************************************************
;*                                                                           *
;* CreateFaxSendCommand                                                      *
;* The procedure CreateFaxSendCommand creates the actual command from the    *
;* options chosen in the dialog box.  To the extent possible, each input     *
;* is checked for validity.  There is also checking for completeness of      *
;* choices so that both recipients name and number must be entered if that   *
;* was the option chosen.  The final output is in an edit box so it could    *
;* be copied to an actual script.  This script will not fax by itself because*
;* the command is created as a string.                                       *
;*                                                                           *
;* There are several levels of checking in this script.                      *
;*  If you chose a radio button, did you fill in any necessary edit boxes?   *
;*  Is the information in the edit box valid?                                *
;*    Does the Connection Directory Entry exist?                             *
;*    Does the coversheet file exist?                                        *
;*    Does the file you chose to fax exist?                                  *
;*    Did you enter the time and date in valid formats?                      *
;*                                                                           *
;* If the result is "No" for any of these queries, a USERMSG reports the     *
;* problem to the user then ErrorFlag is set to 1 which exits the            *
;* "WHILE !ErrorFlag" loop and redisplays the original dialog box.           * 
;*                                                                           *
;* Calls: none                                                               *
;* Called by: Handler0                                                       *
;* Modifies globals: CoverPath, CoverSheetName, OutBoxPath                   *
;*                                                                           *
;*****************************************************************************
proc CreateFaxSendCommand
string FaxCommand            ;This is where we build the faxcommand
string StrTemp               ;temporary string used to format options
long LongTimeSend            ;time for scheduled faxsend
integer ErrorFlag            ;flag for when an error occurs in any of the input

                   ;initialize the faxsend command
	FaxCommand = "faxsend"
	                ;initialize the error flag
	ErrorFlag = 0
	                ;this WHILE loop encompasses most of the procedure.  If an
	                ;error is found in the user input, the user is informed of the
	                ;error then we exit this loop and redisplay the original
	                ;dialog box.
	while !Errorflag
	                ;option for specifying how and to whom the fax is sent
	                ;The dialog event is the RADIOGROUP -- not the individual
	                ;radio buttons.  Thus the RADIOGROUP variable, Radio200, is
	                ; set to either 201 or 202 depending on which radio button 
	                ;clicked.
		switch Radio200
	                ;specify modem
			case 201
			          ;The variable Radio100 is set according to which radio 
			          ;button in its group was clicked
			   switch radio100
			          ;use the Modem Index to specify the modem
		   		case 101
		   		    ;if you clicked this radio button, you must have entered
		   		    ;something in the associated edit box.  Nullstr tests to
		   		    ;see if the string is blank.  Note we are not testing to
		   		    ;see if the index itself is valid.  
		   			if nullstr ModemIndex
		   				usermsg "You selected to use the Modem Index but the input is blank"
		   				ErrorFlag = 1
			   		endif
			   		 ;we want to add "(space) ModemIndex" to the faxcommand so
			   		 ;this has to be formatted before it is concatenated.  The 
			   		 ;strcat command doesn't provide for any formatting.
			   		strfmt StrTemp " %s" ModemIndex
		   			strcat FaxCommand StrTemp
		   		endcase
		   		    ;Use the modem name to identify the modem
			   	case 102
			   	    ;check to see that something was entered into the edit
			   	    ;box for modem name.  This must be entered exactly as it
			   	    ;appears in the TAPI modem list but we don't test to see
			   	    ;if the name is valid.  
			   		if nullstr ModemName
			   			usermsg "You selected to use the Modem Name but the input is blank"
		   				ErrorFlag = 1
		   			endif
		   			 ;the modem name must be formatted with a space in front
		   			 ;of it and the name enclosed in quotes.  The use of the 
		   			 ;escape sequence `" (backtick double-quote) allows us to
		   			 ;put a quote in the string without it being interpreted.
		   			strfmt StrTemp " `"%s`"" ModemName
			   		strcat FaxCommand StrTemp
			   	endcase
			   	    ;Use the Current modem selected in Setup Options
			   	    ;We don't need to format this with a leading space 
			   	    ;beforehand because this isn't a string variable
			   	case 103
		   			strcat FaxCommand " CURRENT"
			   	endcase
			   		 ;Use the First Available modem                   
			   	    ;We don't need to format this with a leading space 
			   	    ;beforehand because this isn't a string variable
			   	case 104
			   		strcat FaxCommand " FIRST"
		   		endcase
			   endswitch
			          ;There must be a Fax Recipient entered here but there is no
			          ;way to check the validity of the entry.
		   	if nullstr FaxTo
   				usermsg "You chose to specify the modem but the Fax Recipient is blank"
   				ErrorFlag = 1
	   		endif
	   		       ;There must be a Fax Number entered here but there is no
			          ;way to check the validity of the entry.
   			if nullstr FaxDial
   				usermsg "You chose to specify the modem but the Fax Number is blank"
   				ErrorFlag = 1
	   		endif
	   		       ;The Fax Recipient must be enclosed in quotes and a space put
	   		       ;in front of it.  The quotes are inserted in the string using
	   		       ;the escape sequence `" (backtick quote).
			   strfmt StrTemp " `"%s`"" FaxTo
			   strcat FaxCommand StrTemp
			          ;The Fax Number must be enclosed in quotes and a space put
	   		       ;in front of it.  The quotes are inserted in the string using
	   		       ;the escape sequence `" (backtick quote).
		   	strfmt StrTemp " `"%s`"" FaxDial
			   strcat FaxCommand StrTemp
			endcase
		             ;use dialing directory
			case 202
			          ;Since we are using the Connection Directory, the first 
			          ;addition to the faxsend command is DIALDIR with a space
			          ;in front of it
				strfmt StrTemp " DIALDIR"
				strcat FaxCommand StrTemp
				       ;If the entry is a group name then we must add GROUP to
				       ;the faxsend command
				if GroupCheck
					strcat FaxCommand " GROUP"
				endif
				       ;check to be sure something was entered into the edit box.
				if nullstr ConnDirEntry
	   			usermsg "You selected to use a Connection Directory Entry but the Entry is blank"
   				ErrorFlag = 1
   			endif
   			       ;Does the variable in the edit box exist in the Connection
   			       ;Directory?  Use EXACT here because that is what the 
   			       ;faxsend command will implicitly use.
	   		dialfind FAX ConnDirEntry EXACT
	   		       ;dialfind sets the SUCCESS/FAILURE flag so if there
	   		       ;is a problem, notify the user.
   			if FAILURE
   				usermsg "You entered an invalid Connection Directory Entry"
   				ErrorFlag = 1
	   		endif
	   		       ;If all is in order, then format the entry by enclosing
	   		       ;it in quotes and adding a space in fron of it.
				strfmt StrTemp " `"%s`"" ConnDirEntry
				strcat FaxCommand StrTemp
			endcase
		endswitch
                   ;coversheet
		switch radio300
		             ;We are going to specify whether or not to use a 
		             ;coversheet even though it isn't alsways necessary.
		             ;The faxsend command will use the setting from the
		             ;Setup Options if nothing is specified in the command.
		             ;The Dialog Box was initialized with the Setup Options
		             ;so the user will know what the defaults are.
			case 301
			          ;Check to see if something was entered into the edit box
				if nullstr CoverSheetName
   				usermsg "You selected to use a Cover Sheet but the Cover Sheet Name is blank"
   				ErrorFlag = 1
	   		endif
	   		       ;The coversheet name might have been entered without the
	   		       ;cvr extension.  If it isn't there, then add it.
   			if not strfind CoverSheetName ".cvr"
  					strcat CoverSheetName ".cvr"
  				endif
   			       ;Retreive the coversheet path.
   			fetch fax path coversheet CoverPath
	   		       ;Add the coversheet path name to the file name so we
	   		       ;can check to see if the file exists.  This assumes that
	   		       ;the coversheet is in the coversheet directory.  If it
	   		       ;is in a different directory, there would have to be
	   		       ;some more checking done in the script.
  				addfilename CoverPath CoverSheetName
  				       ;If the file doesn't exist, then report to the user.
   			if not isfile CoverPath
  					usermsg "The Coversheet you specified does not exist"
  					ErrorFlag = 1
   			endif
   			       ;format the addition to the command with the word
   			       ;COVERSHEET and the coversheet file name in quotes.
				strfmt StrTemp " COVERSHEET `"%s`"" CoverSheetName
				strcat FaxCommand StrTemp
				       ;check to see if a Note should be added to the Note field
				       ;on the coversheet.
				if NoteCheck
				       ;Is there anything in the edit box variable?
					if nullstr NoteString
   					usermsg "You selected to use a Note on the Coversheet but the Note is blank"
   					ErrorFlag = 1
   				endif
   				    ;Format the addition to the command with the word NOTES and
   				    ;the note enclosed in quotes.  Remember that the NoteString
   				    ;is limited to 256 characters because that is the maximum
   				    ;length of a character variable.
					strfmt StrTemp " NOTES `"%s`"" NoteString
					strcat FaxCommand StrTemp
				endif
			endcase
			          ;If there is to be no coversheet, we declare that.
			          ;Remember that if the COVERSHEET isn't specified, the
			          ;faxsend command would use the Setup Options.
			case 302
				strcat FaxCommand " COVERSHEET NONE"
			endcase
		endswitch
	
	                ;when to send fax
		switch Radio500
		             ;Send it now so nothing added to the command
			case 15
			endcase
			          ;send it at a later time
			case 16
			          ;convert the date and time into a long integer which
			          ;is the number of seconds since January, 1970.  The 
			          ;format for the date and time is taken from the 
			          ;Windows specification for "short time" and "short 
			          ;date".  If there is a failure in the conversion, it 
			          ;is probably because the time or date was entered
			          ;incorrectly.  As an aid to the user, update the
			          ;dialog boxes with the current date and time so
			          ;the formats will be apparent.
				strsltime DateFax TimeFax LongTimeSend
				if FAILURE
					usermsg "You entered an incorrect date or time"
					TimeFax = $TIME
					dlgupdate 0 17
					DateFax = $DATE
					dlgupdate 0 48
   				ErrorFlag = 1
	   		endif
	   		       ;If there were no problems, convert the long integer to
	   		       ;a string variable and add it with a leading space to 
	   		       ;the faxsend command
				ltoa LongTimeSend StrTemp
				strcat FaxCommand " "
				strcat FaxCommand StrTemp
			endcase
		endswitch
	
	                ;Fax File
		switch Radio400
		             ;Single file.  The file name will be the actual file to
		             ;be faxed
			case 401
			          ;Check to be sure something was entered in the edit box
				if nullstr SingleFileFax
	   			usermsg "You didn't specify the Fax File"
   				ErrorFlag = 1
   			endif
   			       ;Confirm that the file exists
	   		if not isfile SingleFileFax
   				usermsg "The File you wanted to fax does not exist"
   				ErrorFlag = 1
   			endif
   			       ;format the file name inside of quotes with a leading
   			       ;blank
				strfmt StrTemp " SINGLE `"%s`"" SingleFileFax
				strcat FaxCommand StrTemp
				       ;If this is a binary file transfer, then add the word
				if BinaryCheck
					strcat FaxCommand " BINARY"
				endif
			endcase
			          ;Multiple files.  The file name will be the text file with
			          ;the names of the files to fax.
			case 402
			          ;Check to be sure something was entered in the edit box
				if nullstr MultiFileFax
   				usermsg "You didn't specify a file with the list of files to fax"
   				ErrorFlag = 1
   			endif
   			       ;Assume that the file is in the out box path so add
   			       ;that to the file name
	   		fetch fax path outbox OutBoxPath
   			addfilename OutBoxPath MultiFileFax
   			       ;Confirm that the file exists.
   			if not isfile OutBoxPath
   				usermsg "The File with the list of files you wanted to fax does not exist"
   				ErrorFlag = 1
	   		endif
	   		       ;Format the file name inside of quotes with a leading space
				strfmt StrTemp " MULTIPLE `"%s`"" MultiFileFax
				strcat FaxCommand StrTemp
				       ;If this is a binary file transfer then add the work
				if BinaryCheck
					strcat FaxCommand " BINARY"
				endif
			endcase
			          ;Memo Fax.  The file is the text file containing the memo
			          ;fax.
			case 403
			          ;Check to see if something was entered in the edit box 
				if nullstr MemoFaxFile
   				usermsg "You didn't specify the file with the Memo Fax text"
	   			ErrorFlag = 1
   			endif
   			       ;Confirm that the file exists
   			if not isfile MemoFaxFile
   				usermsg "The File with the text of your Memo Fax does not exist"
   				ErrorFlag = 1
	   		endif
	   		       ;Format the additioin to the faxsend command by enclosing
	   		       ;the file name in quotes and adding the word MEMO
				strfmt StrTemp " MEMO `"%s`"" MemoFaxFile
				strcat FaxCommand StrTemp
			endcase
		endswitch
	
	                ;Output the total faxsend command in an edit box so that it
	                ;can be copied to an actual script.  Since the pushbutton is
	                ;an "OK" button, it will destroy the dialog window when it is
	                ;clicked and there is no need to process any events in this
	                ;dialog window.
	                ;This dialog window is a Style 71 =
	                ;64 -- suspend script while the dialog box is displayed.
	                ; 4 -- modeless
	                ; 2 -- movable witha caption
	                ; 1 -- centered with respect to its parent
		dialogbox 0 8 20 492 69 71 "Your FAXSEND Command" 
	   	text 1 22 7 77 11 "The command is:" left 
	   	editbox 2 14 16 466 23 FaxCommand MULTILINE
		   pushbutton 3 226 48 40 13 "OK" OK DEFAULT
		enddialog 
		             ;After the command is displayed and the dialog box is
		             ;destroyed, then exit the script
		exit
                   ;This is the end of the "While !errorflag" loop so we jump
                   ;here if an error occurs.
	endwhile
                   ;We get here only if an error occurs so redisplay the big
                   ;dialog window.
	FaxChoices ()
	
endproc


