/*
**
**    $VER: AminetFTPMail 2.1 (24-12-1998) © Yves Grabowsky
**
*/

/*----------*/
/* add libs */
/*----------*/

IF ~show('L','tritonrexx.library') then do
   IF ~addlib("tritonrexx.library",5,-30) then do
      SAY "Couldn't open tritonrexx.library!"
      exit(20)
      end
   end
IF ~show('L','rexxtricks.library') then do
   IF ~addlib('rexxtricks.library',1,-30) then do
      say "Couldn't open rexxtricks.library"
      exit(20)
      end
   end
IF ~show('L','rexxreqtools.library') then do
   IF ~addlib("rexxreqtools.library",0,-30) then do
      say "Couldn't open rexxreqtools.library"
      exit(20)
      end
   end

/*---------*/
/* Options */
/*---------*/

OPTIONS RESULTS
OPTIONS FAILAT 20

/*---------------*/
/* Debug routine */
/*---------------*/

IF GETENV('DEBUG') = "1" then do
   TRACE(RESULTS)
   end
ELSE do
	TRACE(OFF)
	end

/*------------*/
/* Interrupts */
/*------------*/

SIGNAL ON BREAK_C
SIGNAL ON HALT
SIGNAL ON IOERR
SIGNAL ON SYNTAX

/*-----------*/
/* some vars */
/*-----------*/

NL = "0A"x
pos = "rt_reqpos=reqpos_centerscr"
totalmails = 0
dontopen = 0

/*-----------------*/
/* load configfile */
/*-----------------*/

IF EXISTS("S:AminetFTPMail.config") then do
	CALL loadsettings("S:AminetFTPMail.config")
	end
ELSE do
	mailaddress = "ftp-mail@uni-paderborn.de"
	mailsize = "16k"
	readme = "0"
	fontname = "topaz.font"
	fontsize = "8"
	multimail = "0"
	delmail = "0"
	pubscreen = "Workbench"
	fwfont = "topaz.font"
	fwsize = "8"
	uheight = "8"
	uwidth = "65"
	wheight = "5"
	wwidth = "75"
	config.15 = "LOCALE:AminetFTPMail/English.lang"
	startconfig = 1
	dontopen = 1
	CALL readlangmod("LOCALE:AminetFTPMail/English.lang")
	end

/*---------------------------*/
/* search for recent mail(s) */
/*---------------------------*/

IF multimail = 0 then do
	CALL scanmail("NOMULTI")
	end

IF multimail = 1 then do
	CALL scanmail("MULTI")
	end

order.0 = 0
order2.0 = 0
mails.0 = 0
mails2.0 = 0

/*--------------------*/
/* create application */
/*--------------------*/

apptags = 'TRCA_Name     AminetFTPMail',
          'TRCA_LongName "AminetFTPMail 2.1 © Yves Grabowsky"',
          'TRCA_Version  2.1',
          'TRCA_Release  6',
          'TRCA_Date     24.12.98'

app = TR_CreateApp(apptags)

/*-------------*/
/* Open window */
/*-------------*/

IF startconfig = 1 then do
	CALL config
	startconfig = 0
	end
ELSE do
	CALL openwin("OPEN")
	end

CALL TR_SetAttribute(project,'15','TRAT_Text',totalmails)          /* set "mails" field */

/*-------------*/
/* GUI routine */
/*-------------*/

DO WHILE exit ~= 1
   CALL TR_Wait(app,'')
   DO WHILE TR_HandleMsg(app,event)
      IF event.trm_class = "TRMS_CLOSEWINDOW" then do
         signal quit
         end
      IF event.trm_id = "5" then do                /* upload selected */
         CALL selupload
         end
      IF event.trm_id = "6" then do                /* remove entry from wishlist */
         CALL rementry
         end
      IF event.trm_id = "9" then do                /* quit */
         signal quit
         end
      IF event.trm_id = "8" then do                /* write the mail */
			IF order.0 ~= 0 then do
				exit = 1
				end
         end
      IF event.trm_id = '13' then do               /* jump mail */
         CALL jumpmail
         end
      IF event.trm_id = '16' then do					/* config */
      	CALL config
      	end
		IF event.trm_id = '17' then do					/* about window */
			CALL about
			end
		IF event.trm_id = '18' then do					/* snapshot win */
			CALL savewin
			end
		IF event.trm_id = '19' then do					/* load settings */
			file = rtfilerequest('S:','AminetFTPMail.config',MSG_selfile,,pos)
			IF file ~= "" then do
				CALL loadsettings(file)
				CALL openwin("REFRESH")
				end
			end
		IF event.trm_id = '20' then do 					/* save settings */
			CALL WRITEFILE('S:AminetFTPMail.config',config)
			end
		IF event.trm_id = '21' then do					/* save settings as */
			file = rtfilerequest('S:','AminetFTPMail.config',MSG_selfile,,pos)
			IF file ~= "" then do
				CALL WRITEFILE(file,config)
				end
			end
		IF event.trm_id = '22' then do
			CALL register
			end
		IF event.trm_class = "TRMS_KEYPRESSED" then do
			IF event.trm_code = 223 then do
				say "GodofWisdom"
				say "GGS"
				say "Rexxmaster@gmx.net"
				say "© by GGS GoW" 
				end
			end
      end
   end

/*--------------*/
/* close window */
/*--------------*/

CALL TR_CloseProject(project)
CALL TR_DeleteApp(app)

/*-------------------------------*/
/* format orderlist for tempfile */
/*-------------------------------*/

DO i=1 to order.0
   filename = WORD(order.i,1)
   dir = WORD(order.i,2)
   order.i = "get /pub/aminet/"dir"/"filename
   end

order2.0 = order.0

/*------------------------------------------*/
/* format second orderlist for readme files */
/*------------------------------------------*/

IF readme = 1 then do
   DO i=1 to order2.0
      dotpos = LASTPOS('.',order.i)
      order2.i = DELSTR(order.i,dotpos)
      order2.i = order2.i".readme"
      end
   end

/*-----------------*/
/* tempfile header */
/*-----------------*/

head.0 = 3
head.1 = "begin"
head.2 = "binary"
head.3 = "size" mailsize

/*--------------*/
/* tempfile end */
/*--------------*/

end.0 = 4
end.1 = "end"
end.2 = "--"
end.3 = "Mail written with AminetFTPMail © Yves Grabowsky"
end.4 = "http://members.tripod.com/~rexxmaster/"

/*----------------*/
/* write tempfile */
/*----------------*/

CALL WRITEFILE('T:AFTPMail.temp',head)					/* head */
CALL WRITEFILE('T:AFTPMail.temp',order,A)				/* body */
IF readme = 1 then do
   CALL WRITEFILE('T:AFTPMail.temp',order2,A)		/* readme's */
   end
CALL WRITEFILE('T:AFTPMail.temp',end,A)				/* foot */

/*----------------------------*/
/* tell yam to write the mail */
/*----------------------------*/

IF delmail = 1 then do                       /* with delete after send flag */
   ADDRESS YAM
   MAILWRITE
   WRITESUBJECT "Request"
   WRITETO mailaddress
   WRITELETTER "T:AFTPMail.temp"
   WRITEOPTIONS DELETE
   WRITEQUEUE
   end
ELSE do
   ADDRESS YAM                               /* without delete after send flag */
   MAILWRITE
   WRITESUBJECT "Request"
   WRITETO mailaddress
   WRITELETTER "T:AFTPMail.temp"
   WRITEQUEUE
   end

/*------------------*/
/* delete tempfiles */
/*------------------*/

IF multimail = 1 then do
   ADDRESS COMMAND
   "delete >NIL: T:AFTPMail.temp"
   "delete >NIL: T:AFTPMail-2.temp"
   end
exit

/*---------------*/
/* Load settings */
/*---------------*/

loadsettings:
parse arg cfgfile

CALL READFILE(cfgfile,config)
IF config.1 ~= "CONFIG.1" then do									/* mailaddress */
	mailaddress = config.1
	end
ELSE do
	mailaddress = "ftp-mail@uni-paderborn.de"
	end
IF config.2 ~= "CONFIG.2" then do									/* mailsize */
	mailsize = config.2
	end
ELSE do
	mailsize = "16k"
	end
IF config.3 ~= "CONFIG.3" then do									/* readme */
	readme = config.3
	end
ELSE do
	readme = 0
	end
IF config.4 ~= "CONFIG.4" then do									/* fontname */
	fontname = config.4
	end
ELSE do
	fontname = "topaz.font"
	end
IF config.5 ~= "CONFIG.5" then do									/* fontsize */
	fontsize = config.5
	end
ELSE do
	fontsize = "8"
	end
IF config.6 ~= "CONFIG.6" then do									/* multimail */
	multimail = config.6
	end
ELSE do
	multimail = 0
	end
IF config.7 ~= "CONFIG.7" then do									/* delmail */
	delmail = config.7
	end
ELSE do
	delmail = 0
	end
IF config.8 ~= "CONFIG.8" then do									/* pubscreen */
	pubscreen = config.8
	end
ELSE do
	pubscreen = "Workbench"
	end
IF config.9 ~= "CONFIG.9" then do									/* fwfont */
	fwfont = config.9
	end
ELSE do
	fwfont = "topaz.font"
	end
IF config.10 ~= "CONFIG.10" then do									/* fwsize */
	fwsize = config.10
	end
ELSE do
	fwsize = "8"
	end
IF config.11 ~= "CONFIG.11" then do									/* u height */
	uwidth = config.11
	end
ELSE do
	uwidth = "55"
	end
IF config.12 ~= "CONFIG.12" then do									/* u width */
	uheight = config.12
	end
ELSE do
	uheight = "6"
	end
IF config.13 ~= "CONFIG.13" then do									/* w height */
	wwidth = config.13
	end
ELSE do
	wwidth = "60"
	end
IF config.14 ~= "CONFIG.14" then do									/* w width */
	wheight = config.14
	end
ELSE do
	wheight = "5"
	end
IF config.15 ~= "CONFIG.15" then do
	IF ~EXISTS(config.15) then do
		CALL readlangmod("LOCALE:AminetFTPMail/English.lang")
		config.15 = "LOCALE:AminetFTPMail/English.lang"
		end
	ELSE do
		CALL readlangmod(config.15)
		end
	end
ELSE do
	CALL readlangmod("LOCALE:AminetFTPMail/English.lang")
	config.15 = "LOCALE:AminetFTPMail/English.lang"
	end
 
IF config.0 ~= 15 then do
	startconfig = 1
	dontopen = 1
	end

return

/*----------------------*/
/* Read language module */
/*----------------------*/

readlangmod: 
langmod = ARG(1)

IF ~READFILE(langmod,language) then do
	CALL rtezrequest("Failed to read language module:" || NL || langmod,,"AminetFTPMail",pos)
	end

MSG_selfile = language.13
MSG_noyam = language.17
MSG_norecent = language.21
MSG_appbusy = language.25
MSG1_notemp = language.29
MSG2_notemp = language.33
MSG3_notemp = language.37
MSG_project = language.41
MSG_writem = language.45
MSG_about = language.49
MSG_quit = language.53
MSG_settings = language.57
MSG_setts = language.61
MSG_snapwin = language.65
MSG_loadsetts = language.69
MSG_savesetts = language.73
MSG_savesettsas = language.77
MSG_mailfrom = language.81
MSG_uploads = language.85
MSG_wishlist = language.89
MSG_adr = language.93
MSG_maxsize = language.97
MSG_nummails = language.101
MSG_write = language.105
MSG_cancel = language.109
MSG1_fonterr = language.113
MSG2_fonterr = language.117
MSG3_fonterr = language.121
MSG4_fonterr = language.125
MSG1_guierr = language.129
MSG2_guierr = language.133
MSG_ml = language.137
MSG_mls = language.141
MSG_startup = language.145
MSG_pubscr = language.149
MSG_aminet = language.153
MSG_fmadr = language.157
MSG_getread = language.161
MSG_delmail = language.165
MSG_lists = language.169
MSG_uplst = language.173
MSG_width = language.177
MSG_height = language.181
MSG_wshlst = language.185
MSG_fonts = language.189
MSG_winfont = language.193
MSG_changewinfnt = language.197
MSG_lstfnt = language.201
MSG_changelstfnt = language.205
MSG_ok = language.209
MSG_cancl = language.213
MSG_selfont = language.217
MSG_halt = language.221
MSG_lang = language.225
MSG_register = language.229
MSG_reghead = language.233
MSG1_regintro = language.237
MSG2_regintro = language.245
MSG_name = language.249
MSG_email = language.253
MSG_street = language.257
MSG_city = language.261
MSG_country = language.265
MSG_rate = language.269
MSG_regme = language.273
return

/*----------*/
/* Scanmail */
/*----------*/

scanmail:
parse arg mode

IF ~show("P","YAM") then do
	call rtezrequest(MSG_noyam,,"AminetFTPMail",pos)
	exit(20)
	end

IF mode = "NOMULTI" then do								/* multimail disabled */
   ADDRESS YAM
   MAILINFO STEM 'mailinfo.'
   check1 = POS('Aminet',mailinfo.subject)
   IF check1 >0 then do
      check2 = POS('uploads',mailinfo.subject)
      IF check2 >0 then do
         check = 1
         end
      ELSE do
         check = 0
         end
      end
   ELSE do
      check = 0
      end
   IF check = 0 then do
      call rtezrequest(MSG_norecent,,'AminetFTPMail',pos)
      exit(20)
      end
   file = mailinfo.filename
   subject = mailinfo.subject
   weeklypos = POS('week''s',mailinfo.subject)   /* check for date of mail */
   IF weeklypos > 0 then do                     /* weekly mail */
      date = WORD(mailinfo.subject,'6')
      end
   ELSE do                                      /* daily mail */
      date = WORD(mailinfo.subject,'5')
      end
   'MAILSTATUS O'                               /* mark recent mail as read */   
   nomulti = 1
   CALL READFILE(file,'recent')
   dates.0 = 1
   dates.1 = date
   end

IF mode = "MULTI" then do									/* multimail enabled */
   ADDRESS YAM
   'APPBUSY "AminetFTPMail: Searching for recent mails..."'
   MAILINFO STEM "res."
   FOLDERINFO STEM 'folder.'
   ADDRESS YAM
   DO i=0 to folder.total
      ADDRESS YAM
      SETMAIL i
      MAILINFO STEM 'mailinfo.'
      aminet1 = POS('Aminet',mailinfo.subject)
      IF aminet1 >0 then do
         aminet2 = POS('uploads',mailinfo.subject)
         IF aminet2 >0 then do
            aminet = 1
            end
         ELSE do
            aminet = 0
            end
         end
      ELSE do
         aminet = 0
         end
      IF aminet = 1 then do                           /* write filename to 1st tempfile */
         file.0 = 1
         file.1 = mailinfo.filename
         'MAILSTATUS O'                               /* mark recent mail as read */   
         IF EXISTS('T:AFTPMail.temp') then do
            CALL WRITEFILE('T:AFTPMail.temp',file,A)
            end
         ELSE do
            CALL WRITEFILE('T:AFTPMail.temp',file)
            end
         date.0 = 1
         weeklypos = POS('week''s',mailinfo.subject)   /* check for date of mail */
         IF weeklypos > 0 then do                     /* weekly mail */
            date.1 = SUBWORD(mailinfo.subject,6,1)
         	end
         ELSE do                                      /* daily mail */
            date.1 = WORD(mailinfo.subject,'5')
            end
         date.1 = WORD(mailinfo.subject,'5')
         IF EXISTS('T:AFTPMail-2.temp') then do       /* write date to 2nd tempfile */
            CALL WRITEFILE('T:AFTPMail-2.temp',date,A)
            end
         ELSE do
            CALL WRITEFILE('T:AFTPMail-2.temp',date)
            end
         end
      end
   nomulti = 0
   IF ~READFILE('T:AFTPMail.temp',files) then do      /* read 1st tempfile */
		call rtezrequest(MSG1_notemp || NL || MSG2_notemp || NL || MSG3_notemp,,"AminetFTPMail",pos)
		APPNOBUSY
		exit(20)
		end
   CALL READFILE(files.1,'recent')                    /* read first mail */
   mailnum = 1
   CALL READFILE('T:AFTPMail-2.temp',dates)           /* read 2nd tempfile */
   date = dates.1
   SETMAIL res.index
   APPNOBUSY
   end

DO o=1 to recent.0                                    /* check for begin of uploads list */
   begin = POS('|--',recent.o)
   IF begin >0 then do
      startline = o
      LEAVE
      end
   end


CALL STEMREMOVE(recent,'1',startline)                 /* cut out unused mailpart */

return


/*-------------*/
/* Open window */
/*-------------*/

openwin:
parse arg mode

IF mode = "REFRESH" then do
	IF dontopen = 0 then do
		CALL TR_CloseProject(project)
		end
	ELSE do
		dontopen = 0
		end
	CALL readlangmod(config.15)
	end

/*--------------*/
/* Define Fonts */
/*--------------*/

propfont.ta_name = fontname
propfont.ta_ysize = fontsize
fwfont.ta_name = fwfont
fwfont.ta_ysize = fwsize

/*---------------*/
/* define window */
/*---------------*/

win = WindowTitle('AminetFTPMail'),
      ScreenTitle('AminetFTPMail 2.1 (24-12-1998) © Yves Grabowsky'),
      WindowID('1'),
      WindowPosition('TRWP_CENTERSCREEN'),
		PubscreenName(pubscreen),
      'TRWI_PropFontAttr propfont',
      'TRWI_FixedWidthFontAttr fwfont',
		BeginMenu(MSG_project),
		MenuItem('W_'MSG_writem,'8'),
		ItemBarlabel,
		MenuItem('R_'MSG_register,'22'),
		MenuItem('A_'MSG_about,'17'),
		ItemBarlabel,
		MenuItem('Q_'MSG_quit,'9'),
		BeginMenu(MSG_settings),
		MenuItem('S_'MSG_setts,'16'),
		MenuItem(MSG_snapwin,'18'),
		ItemBarlabel,
		MenuItem(MSG_loadsetts,'19'),
		MenuItem(MSG_savesetts,'20'),
		MenuItem(MSG_savesettsas,'21'),
      VertGroupA,
         Space,
         NamedSeparator('AminetFTPMail 2.1'),
         Space,
         HorizGroupA,
            Space,
            VertGroupA,
               Space,
               CenteredText3(MSG_mailfrom),
               Space,
               ListSSN(dates,'13','1','0'),
               Space,
            Endgroup,
            Space,
            VertGroupA,
               Space,
               CenteredText3(MSG_uploads),
               Space,
               'TROB_Listview "recent" TRAT_Flags TRLV_SELECT|TRLV_FWFONT|TRLV_NOCURSORKEYS TRAT_ID "5" TRAT_MinWidth' uwidth 'TRAT_MinHeight' uheight 'TRAT_Value "0" TRLV_Top "0"',
               Space,
            Endgroup,
            Space,
         Endgroup,
         SpaceS,
         CenteredText3(MSG_wishlist),
         Space,
         HorizGroupA,
            Space,
            'TROB_Listview "order" TRAT_Flags TRLV_SELECT|TRLV_FWFONT TRAT_ID "6" TRAT_MinWidth' wwidth 'TRAT_MinHeight' wheight ' TRAT_Value "0" TRLV_Top "0"',
            Space,
            FWListROCN(mails,'14','0'),
            Space,
         Endgroup,
         Space,
         HorizGroupA,
          	Space,
           	TextN(MSG_adr),
            Space,
            GroupBox,
            HorizGroupA,
               Space,
               TextN(mailaddress),
               Space,
            Endgroup,
            Space,
            TextN(MSG_maxsize),
            Space,
            GroupBox,
            HorizGroupA,
               Space,
               TextN(mailsize),
               Space,
            Endgroup,
            Space,
            TextN(MSG_nummails),
            Space,
            GroupBox,
            HorizGroupA,
               Space,
               TextID('000','15'),
               Space,
            Endgroup,
            Space,
         Endgroup,
         Space,
         HorizSeparator,
         Space,  
			HorizGroupEA,
            Space,
            Button(MSG_write,'8'),
            SpaceB,
            Button(MSG_cancel,'9'),
            Space,
         Endgroup,
         Space,
      Endgroup,
      Endproject

/*--------------*/
/* open project */
/*--------------*/

project = TR_OpenProject(app,win)

/*---------------*/
/* Error in GUI? */
/*---------------*/

error = TR_GetLastError(app)

IF error ~= "0" then do
   IF error = "3" then do
      call rtezrequest(MSG1_fonterr || NL || MSG2_fonterr || NL || MSG3_fonterr || NL || MSG4_fonterr,,"AminetFTPMail",pos)
		dontopen = 1
		call config
		call openwin("OPEN")
      end
   ELSE do
      string = TR_GetErrorString(error)
      call rtezrequest(MSG1_guierr || NL || MSG2_guierr || NL || string,,"AminetFTPMail",pos)
      exit(20)
      end
   end

CALL TR_SetAttribute(project,'15','TRAT_Text',totalmails)          /* set "mails" field */

return

/*-----------------*/
/* Upload selected */
/*-----------------*/

selupload:

uploadnum = event.trm_data+1                                   
newvalue = order.0+1                                           
order.newvalue = recent.uploadnum
order2.newvalue = recent.uplaodnum
order.0 = order.0+1
order2.0 = order2.0+1

/* uploadsize */

uploadsize = WORD(recent.uploadnum,'3')
uploadpos = POS('K+',uploadsize)
IF uploadpos >0 then do
   uploadsize = LEFT(uploadsize,uploadpos)
   uploadpos = POS('K',uploadsize)
   uploadpos = uploadpos-1
   uploadsize = SUBSTR(uploadsize,'1',uploadpos)
   maxsize = SUBSTR(mailsize,'1',POS('k',mailsize)-1)
   mailnums = TRUNC(uploadsize/maxsize)
   n = 0
   DO n=n+1
      IF mailnums < n then do
         mailnums = n
         LEAVE
         end
      end
   mails.0 = mails.0+1
   listnum = mails.0
   IF mailnums = "1" then do
      mails.listnum = mailnums MSG_ml
      end
   ELSE do
      mails.listnum = mailnums MSG_mls
      end
   mails2.0 = mails.0
   mails2.listnum = mails.listnum
   end
ELSE do
   uploadpos = POS('M+',uploadsize)
   uploadsize = LEFT(uploadsize,uploadpos)
   uploadpos = POS('M',uploadsize)
   uploadpos = uploadpos-1
   uploadsize = SUBSTR(uploadsize,'1',uploadpos)
   uploadsize = uploadsize*1024
   maxsize = SUBSTR(mailsize,'1',POS('k',mailsize)-1)
   mailnums = TRUNC(uploadsize/maxsize)
   n = 0
   DO n=n+1
      IF mailnums < n then do
         mailnums = n
         LEAVE
         end
      end
   mails.0 = mails.0+1
   listnum = mails.0
   IF mailnums = "1" then do
      mails.listnum = "1" MSG_ml
      end
   ELSE do
      mails.listnum = mailnums MSG_mls
      end
   mails2.0 = mails.0
   mails2.listnum = mails.listnum
   end

totalmails = totalmails+mailnums

/* set upload */
stemvar = TR_GetAttribute(project,'6','TROB_Listview')
If stemvar = "order" then do
   CALL TR_SetAttribute(project,'6','TROB_Listview','order2')
   end
ELSE do
   CALL TR_SetAttribute(project,'6','TROB_Listview','order')
   end

/* set uploadsize */
stem = TR_GetAttribute(project,'14','TROB_Listview')
If stem = "mails" then do
   CALL TR_SetAttribute(project,'14','TROB_Listview','mails2')
   end
ELSE do
   CALL TR_SetAttribute(project,'14','TROB_Listview','mails')
   end

/* set total mails */
CALL TR_SetAttribute(project,'15','TRAT_Text',totalmails)

return      

/*----------------------------*/
/* remove entry from wishlist */
/*----------------------------*/

rementry:

removenum = event.trm_data+1
CALL STEMREMOVE(order,removenum,1)
CALL STEMREMOVE(order2,removenum,1)
stemvar = TR_GetAttribute(project,'6','TROB_Listview')
If stemvar = "order" then do
   CALL TR_SetAttribute(project,'6','TROB_Listview','order2')
   end
ELSE do
   CALL TR_SetAttribute(project,'6','TROB_Listview','order')
   end

listnum = removenum
mailnums = WORD(mails.listnum,1)
IF mailnums = 0 then do
   totalmails = 0
   end
ELSE do
   IF totalmails = mailnums then do
      totalmails = 0
      end
   ELSE do
      totalmails = totalmails-mailnums
      end
   end

CALL STEMREMOVE(mails,removenum,1)
CALL STEMREMOVE(mails2,removenum,1)

stem = TR_GetAttribute(project,'14','TROB_Listview')
If stem = "mails" then do
   CALL TR_SetAttribute(project,'14','TROB_Listview','mails2')
   end
ELSE do
   CALL TR_SetAttribute(project,'14','TROB_Listview','mails')
   end


/* set total mails */
CALL TR_SetAttribute(project,'15','TRAT_Text',totalmails)

return

/*-----------*/
/* Jump mail */
/*-----------*/

jumpmail:

mailnum = event.trm_data
mailnum = mailnum+1
CALL TR_SetAttribute(project,'12','TRAT_Text',dates.mailnum)

file = files.mailnum
CALL READFILE(file,recent)
DO o=1 to recent.0
   begin = POS('|--',recent.o)
   IF begin >0 then do
      startline = o
      LEAVE
      end
   end
file = files.mailnum
CALL READFILE(file,recent2)
DO o=1 to recent2.0
   begin = POS('|--',recent2.o)
   IF begin >0 then do
      startline = o
      LEAVE
      end
   end
CALL STEMREMOVE(recent,'1',startline)
CALL STEMREMOVE(recent2,'1',startline)

stemvar = TR_GetAttribute(project,'5','TROB_Listview')   /* send new mail to listview */
IF stemvar = "recent" then do
   CALL TR_SetAttribute(project,'5','TROB_Listview','recent2')
   end
ELSE do
   CALL TR_SetAttribute(project,'5','TROB_Listview','recent')
   end

CALL TR_SetAttribute(project,'5','TRAT_Value',1)

return

/*------------------*/
/* Save window data */
/*------------------*/

savewin:

IF EXISTS('ENV:Triton/AminetFTPMail.win.1') then do			/* main win */
   ADDRESS COMMAND
   "copy ENV:Triton/AminetFTPMail.win.1 ENVARC:Triton/"
   end
IF EXISTS('ENV:Triton/AminetFTPMail.win.2') then do			/* config win */
   ADDRESS COMMAND
   "copy ENV:Triton/AminetFTPMail.win.2 ENVARC:Triton/"
   end

CALL BEEP()

return

/*--------*/
/* Config */
/*--------*/

config:
exit = 0
/*-----------------*/
/* lock mainwindow */
/*-----------------*/

IF dontopen = 0 then do
	call TR_Lockproject(project)
	end

/*----------------------*/
/* Get language modules */
/*----------------------*/

CALL GETDIR('LOCALE:AminetFTPMail/','#?.lang','lang','F','P')

DO i=1 to lang.0
   IF FILEPART(config.15) = FILEPART(lang.i) then do
      listnum = i
      LEAVE
      end
   end
 
language.0 = lang.0
modulepath.0 = lang.0

DO i=1 to lang.0
   modulepath.i = PATHPART(lang.i)
   language.i = FILEPART(lang.i)
   langpos = LASTPOS('.',language.i)
   language.i = DELSTR(language.i,langpos)
   end

listnum = listnum-1
 
/*--------------*/
/* define lists */
/*--------------*/

size.0 = 6 
size.1 = "16k"
size.2 = "32k"
size.3 = "64k"
size.4 = "128k"
size.5 = "256k"
size.6 = "512k"

site.0 = 3
site.1 = 'Aminet Paderborn/Germany'
site.2 = 'US Aminet Mirror'
site.3 = '-- Other --'


/*--------------*/
/* Define Fonts */
/*--------------*/

propfont.ta_name = fontname
propfont.ta_ysize = fontsize
fwfont.ta_name = fwfont
fwfont.ta_ysize = fwsize

/*---------------*/
/* define window */
/*---------------*/

win = WindowID('2'),
      WindowTitle(MSG_setts),
      ScreenTitle('AminetFTPMail 2.1 (24-12-1998) © Yves Grabowsky'),
      WindowPosition('TRWP_Centerscreen'),
		PubscreenName(pubscreen),
      'TRWI_PropFontAttr propfont',
      VertGroupA,
         Space,
         NamedSeparator(MSG_settings),
         Space,
			HorizGroupA,
				Space,
   	      VertGroupA,
      	      Space,
					NamedSeparator(MSG_startup),
					HorizGroupA,
						Space,
						VertGroupA,
							SpaceB,
							TextN(MSG_lang),
							SpaceB,
							TextN(MSG_pubscr),
   	            	SpaceB,
	   	            TextN('Multi mails:'),
						Endgroup,
						Space,
						VertGroupA,
							TextN('                                        '),
							CycleGadget(language,listnum,'30'),
							Space,
							StringGadget('Workbench','17'),
		 					Space,
      		         CheckBox('15'),
						Endgroup,
						Space,
					Endgroup,
					Space,
					NamedSeparator('FTP mail'),
					Space,
					HorizGroupA,
						Space,
   	      	   VertGroupA,
      	      	   SpaceB,
         	         TextN(MSG_aminet),
     	      	      SpaceB,
               	   TextN(MSG_fmadr),
 							SpaceB,
	   	            TextN(MSG_maxsize),
   		     	      SpaceB,
	            	   TextN(MSG_getread),
   	   	         SpaceB,
      	   	      TextN(MSG_delmail),
						Endgroup,
						Space,
						VertGroupA,
  		               Space,
   		            CycleGadget(site,'0','5'),
							Space,
      	   	      'TROB_String "ftp-mail@uni-paderborn.de" TRAT_Disabled 1 TRAT_Flags TRST_NORETURNBROADCAST TRAT_ID "6"',
							Space,
         	      	CycleGadget(size,'5','10'),
	               	SpaceB,
		               CheckBoxC('7'),
      	      	   SpaceB,
         	      	CheckBox('16'),
            		Endgroup,
						Space,
					Endgroup,
      	      Space,
					NamedSeparator(MSG_lists),
					Space,
					HorizGroupA,
						Space,
            		VertGroupA,
							SpaceS,
							TextN(MSG_uplst),
							Space,
							TextN(MSG_width),
							Space,
							TextN(MSG_height),
		           	Endgroup,
		            Space,
						VertGroupA,
   	   	         Space,
							SpaceB,
							SpaceS,
							SliderGadget('30','100','65','22'),
							Space,
							SliderGadget('2','20','8','23'),
						Endgroup,
						Space,
						VertGroupA,
							Space,
							SpaceB,
							TextID('000','26'),
							Space,
							TextID('00','27'),
						Endgroup,
						SpaceB,
						VertGroupA,
							SpaceS,
							TextN(MSG_wshlst),
							Space,
							TextN(MSG_width),
							Space,
							TextN(MSG_height),
						Endgroup,
						Space,
						VertGroupA,
							Space,
							SpaceB,
							SpaceS,
							SliderGadget('30','100','75','24'),
							Space,
							SliderGadget('2','20','5','25'),
						Endgroup,
						Space,
						VertGroupA,
							Space,
							SpaceB,
							TextID('000','28'),
							Space,
							TextID('00','29'),
						Endgroup,
						Space,
					Endgroup,
           	Endgroup,
				Space,
				VertSeparator,
				Space,
   	      HorizGroupA,
	            Space,
   	         VertGroupA,
						Space,
						NamedSeparator(MSG_fonts),
      	         Space,
						VertGroupA,
							Space,
							TextN(MSG_winfont),
							Space,
							VertGroupA,
								Space,
								'TROB_String "XHelvetica.font" TRAT_FLAGS TRST_NORETURNBROADCAST TRAT_ID "11"',
								Spaces,
							  	'TROB_String "11" TRAT_FLAGS TRST_NORETURNBROADCAST TRAT_ID "13" TRAT_Value "3"',
            	   		Space,
							Endgroup,
							Space,
							CenteredButton(MSG_changewinfnt,'12'),
							Space,
						Endgroup,
						Space,
               	VertGroupA,
							Space,
							TextN(MSG_lstfnt),
							Space,
							VertGroupA,
								Space,
         	      		'TROB_String "XHelvetica.font" TRAT_FLAGS TRST_NORETURNBROADCAST TRAT_ID "18"',
								SpaceS,
         	      		'TROB_String "11" TRAT_FLAGS TRST_NORETURNBROADCAST TRAT_ID "19" TRAT_Value "3"',
            	   		Space,
							Endgroup,
							Space,
							CenteredButton(MSG_changelstfnt,'21'),
			           	Space,
						Endgroup,
						Space,
          	   Endgroup,
            	Space,
         	Endgroup,
			Endgroup,
         Space,
			HorizSeparator,
			Space,
			HorizGroupEA,
   	      Space,
      	   Button(MSG_ok,'8'),
         	Space,
         	Button(MSG_cancl,'9'),
         	Space,
      	Endgroup,
			Space,
		Endgroup,
      Endproject

/*--------------*/
/* open project */
/*--------------*/

cfgproject = TR_OpenProject(app,win)

error = TR_GetLastError(app)

IF error ~= "0" then do
   string = TR_GetErrorString(error)
   call rtezrequest(MSG1_guierr || NL || MSG2_guierr || NL || string,,"AminetFTPMail",pos)
   exit(20)
   end

/*-----------------*/
/* set old configs */
/*-----------------*/

IF mailaddress = 'ftp-mail@uni-paderborn.de' then do							/* set mail address */
   CALL TR_SetAttribute(cfgproject,'5','TRAT_Value','0')
   CALL TR_SetAttribute(cfgproject,'6','TROB_String',mailaddress)
   end
ELSE do
   IF mailaddress = 'ftpmail@pub1.bryant.vix.com' then do
      CALL TR_SetAttribute(cfgproject,'5','TRAT_Value','1')
      CALL TR_SetAttribute(cfgproject,'6','TROB_String',mailaddress)
      end
   ELSE do
      CALL TR_SetAttribute(cfgproject,'5','TRAT_Value','2')
      CALL TR_SetAttribute(cfgproject,'6','TROB_String',mailaddress)
      end
   end
IF mailsize = '16k' then do														/* set mailsize */
   CALL TR_SetAttribute(cfgproject,'10','TRAT_Value',0)
   end
IF mailsize = '32k' then do
   CALL TR_SetAttribute(cfgproject,'10','TRAT_Value',1)
   end
IF mailsize = '64k' then do
   CALL TR_SetAttribute(cfgproject,'10','TRAT_Value',2)
   end
IF mailsize = '128k' then do
   CALL TR_SetAttribute(cfgproject,'10','TRAT_Value',3)
   end
IF mailsize = '256k' then do
   CALL TR_SetAttribute(cfgproject,'10','TRAT_Value',4)
   end
IF mailsize = '512k' then do
   CALL TR_SetAttribute(cfgproject,'10','TRAT_Value',5)
   end
CALL TR_SetAttribute(cfgproject,'7','TRAT_Value',readme)					/* set readme */
CALL TR_SetAttribute(cfgproject,'11','TROB_String',fontname)			/* set fontname */
CALL TR_SetAttribute(cfgproject,'13','TROB_String',fontsize)			/* set fontsize */
CALL TR_SetAttribute(cfgproject,'15','TRAT_Value',multimail)			/* set multimail */
CALL TR_SetAttribute(cfgproject,'16','TRAT_Value',delmail)				/* set delete mail */
CALL TR_SetAttribute(cfgproject,'17','TROB_String',pubscreen)			/* set pubscreen */
CALL TR_SetAttribute(cfgproject,'18','TROB_String',fwfont)				/* set fixed width font */
CALL TR_SetAttribute(cfgproject,'19','TROB_String',fwsize)				/* set fixed width size */
CALL TR_SetAttribute(cfgproject,'22','TRAT_Value',uwidth)				/* set u width */
CALL TR_SetAttribute(cfgproject,'23','TRAT_Value',uheight)				/* set u height */
CALL TR_SetAttribute(cfgproject,'24','TRAT_Value',wwidth)				/* set w width */
CALL TR_SetAttribute(cfgproject,'25','TRAT_Value',wheight)				/* set w height */
CALL TR_SetAttribute(cfgproject,'26','TRAT_Text',uwidth)				/* set u width */
CALL TR_SetAttribute(cfgproject,'27','TRAT_Text',uheight)				/* set u height */
CALL TR_SetAttribute(cfgproject,'28','TRAT_Text',wwidth)				/* set w width */
CALL TR_SetAttribute(cfgproject,'29','TRAT_Text',wheight)				/* set w height */

DO WHILE exit ~= 1
   CALL TR_Wait(app,'')
   DO WHILE TR_HandleMsg(app,event)
      IF event.trm_class = "TRMS_CLOSEWINDOW" then do
         exit = 1
			IF dontopen = 1 then do
				call TR_CloseProject(cfgproject)
				call TR_DeleteApp(app)
				signal quit
				end
         end
      IF event.trm_id = '5' then do
         IF event.trm_data = '0' then do
            CALL TR_SetAttribute(cfgproject,'6','TROB_String','ftp-mail@uni-paderborn.de')
            CALL TR_SetAttribute(cfgproject,'6','TRAT_Disabled','1')
            end
         IF event.trm_data = '1' then do
            CALL TR_SetAttribute(cfgproject,'6','TROB_String','ftpmail@pub1.bryant.vix.com')
            CALL TR_SetAttribute(cfgproject,'6','TRAT_Disabled','1')
            end
         IF event.trm_data = '2' then do
            CALL TR_SetAttribute(cfgproject,'6','TRAT_Disabled','0')
            end
         end
      IF event.trm_id = '9' then do
         exit = 1
			IF dontopen = 1 then do
				call TR_CloseProject(cfgproject)
				call TR_DeleteApp(app)
				signal quit
				end
         end
      IF event.trm_id = '8' then do
    		getentries = 1
			exit = 1
         end
      IF event.trm_id = "12" then do
			fontname = TR_GetAttribute(cfgproject,'11','TROB_String')   /* get old font */
			fontsize = TR_GetAttribute(cfgproject,'13','TROB_String')   /* get old fontsize */
			taglist = getfont(MSG_selfont,MSG_ok,fontname,fontsize)
			bool=ASL_RequestFont(cfgproject,newfont,taglist)
			IF bool = 1 then do
   			CALL TR_SetAttribute(cfgproject,'11','TROB_String',newfont.ta_name)
   			CALL TR_SetAttribute(cfgproject,'13','TROB_String',newfont.ta_ysize)
				end
         end
		IF event.trm_id = '21' then do
			fwfont = TR_GetAttribute(cfgproject,'18','TROB_String')   /* get old font */
			fwsize = TR_GetAttribute(cfgproject,'19','TROB_String')   /* get old fontsize */
			taglist = GetFWFont(MSG_selfont,MSG_ok,fwfont,fwsize)
			bool = ASL_RequestFont(cfgproject,newfont,taglist)
			IF bool = 1 then do
   			CALL TR_SetAttribute(cfgproject,'18','TROB_String',newfont.ta_name)
   			CALL TR_SetAttribute(cfgproject,'19','TROB_String',newfont.ta_ysize)
				end
			end
		IF event.trm_id = '22' then do
			CALL TR_SetAttribute(cfgproject,'26','TRAT_Text',event.trm_data)
			end
		IF event.trm_id = '23' then do
			CALL TR_SetAttribute(cfgproject,'27','TRAT_Text',event.trm_data)
			end
		IF event.trm_id = '24' then do
			CALL TR_SetAttribute(cfgproject,'28','TRAT_Text',event.trm_data)
			end
		IF event.trm_id = '25' then do
			CALL TR_SetAttribute(cfgproject,'29','TRAT_Text',event.trm_data)
			end
      IF event.trm_id = '30' then do
         listnum = TR_GetAttribute(cfgproject,'30','TRAT_Value')
         end         
      end
   end

/*-------------*/
/* get entries */
/*-------------*/
IF getentries = 1 then do
   config.0 = 15
	config.1 = TR_GetAttribute(cfgproject,'6','TROB_String')
	num = TR_GetAttribute(cfgproject,'10','TRAT_Value')
	num = num+1
	config.2 = size.num
	config.3 = TR_GetAttribute(cfgproject,'7','TRAT_Value')
	config.4 = TR_GetAttribute(cfgproject,'11',"TROB_String")
	config.5 = TR_GetAttribute(cfgproject,'13',"TROB_String")
	config.6 = TR_GetAttribute(cfgproject,'15','TRAT_Value')
	config.7 = TR_GetAttribute(cfgproject,'16','TRAT_Value')
	config.8 = TR_GetAttribute(cfgproject,'17','TROB_String')
	config.9 = TR_GetAttribute(cfgproject,'18','TROB_String')
	config.10 = TR_GetAttribute(cfgproject,'19','TROB_String')
	config.11 = TR_GetAttribute(cfgproject,'22','TRAT_Value')
	config.12 = TR_GetAttribute(cfgproject,'23','TRAT_Value')
	config.13 = TR_GetAttribute(cfgproject,'24','TRAT_Value')
	config.14 = TR_GetAttribute(cfgproject,'25','TRAT_Value')
   mailaddress = config.1
   mailsize = config.2
   readme = config.3
   fontname = config.4
   fontsize = config.5
   multimail = config.6
   delmail = config.7
   pubscreen = config.8
	fwfont = config.9
	fwsize = config.10
	uwidth = config.11
	uheight = config.12
	wwidth = config.13
	wheight = config.14
	lang = 0
	lang = TR_GetAttribute(cfgproject,'30','TRAT_Value')+1
	CALL GetDir('LOCALE:AminetFTPMail/','#?.lang',module,'F','P')
	config.15 = module.lang
	end

/*--------------*/
/* close window */
/*--------------*/

CALL TR_CloseProject(cfgproject)

/*---------------------*/
/* refresh main window */
/*---------------------*/

IF getentries = 1 then do
	CALL openwin("REFRESH")
	end

/*----------------*/
/* Unlock mainwin */
/*----------------*/

IF dontopen = 0 then do
	call TR_UnLockproject(project)
	end
	
exit = 0

return

/*--------------*/
/* About window */
/*--------------*/

about:

CALL TR_LockProject(project)								/* lock main window */

exit = 0
about.0 = 18
about.1 = ""
about.2 = "AminetFTPMail 2.1 by Yves Grabowsky"
about.3 = ""
about.4 = ""
about.5 = ""
about.6 = "Support page:"
about.7 = "http://members.tripod.com/~rexxmaster/"
about.8 = ""
about.9 = "I would like to thank:"
about.10 = "- all my registered users!"
about.11 = "- Marc Böttcher for many many ideas"
about.12 = "  and the support homepage"
about.13 = "- Detlef Wojtaszkiewicz for many suggestions"
about.14 = "  and nonstop complaining about the fonts :-)"
about.15 = "- the beta testers"
about.16 = ""
about.17 = "My eMail address: YvesGrabowsky@t-online.de"
about.18 = ""
  
win = WindowID('3'),
		WindowTitle(MSG_about),
      ScreenTitle('AminetFTPMail 2.1 (24-12-1998) © Yves Grabowsky'),
      WindowPosition('TRWP_Centerscreen'),
		PubscreenName(pubscreen),
      'TRWI_PropFontAttr propfont',
		VertGroupA,
			Space,
			CenteredText3('AminetFTPMail 2.1'),
			Space,
			HorizGroupA,
				Space,
				'TROB_Listview "about" TRAT_Flags TRLV_READONLY TRAT_ID "1" TRAT_MinWidth "45" TRAT_MinHeight "18" TRAT_Value "0"', 
				Space,
			Endgroup,
			Space,
		Endgroup,
		Endproject

aboutproject = TR_OpenProject(app,win)

DO WHILE exit ~= 1
	CALL TR_WAIT(app,'')
	DO WHILE TR_HandleMsg(app,event)
		IF event.trm_class = "TRMS_CLOSEWINDOW" then do
			exit = 1
			end
		end
	end

CALL TR_CloseProject(aboutproject)
CALL TR_UnlockProject(project)
exit = 0

return
 
/*------*/
/* Quit */
/*------*/

quit:

IF dontopen = 0 then do
	CALL TR_CloseProject(project)
	CALL TR_DeleteApp(app)
	end
IF multimail = 1 then do
   ADDRESS COMMAND
   "delete >NIL: T:AFTPMail.temp"
   "delete >NIL: T:AFTPMail-2.temp"
   end

exit(0)

/*----------*/
/* Register */
/*----------*/
register:

/* define ratings */
rate.0 = 6
rate.1 = "1"
rate.2 = "2"
rate.3 = "3"
rate.4 = "4"
rate.5 = "5"
rate.6 = "6"

/* define window */
win = WindowID('4'),
      WindowTitle(MSG_register),
      ScreenTitle('AminetFTPMail 2.1 (24-12-98) © Yves Grabowsky'),
      WindowPosition('TRWP_Centerscreen'),
		PubscreenName(pubscreen),
      'TRWI_PropFontAttr propfont',
      VertGroupA,
         Space,
         NamedSeparator(MSG_reghead),
         Space,
         HorizGroupA,
            Space,
            GroupBox,
            HorizGroupA,
               Space,
               VertGroupA,
                  SpaceS,
                  CenteredText(MSG1_regintro),
                  SpaceS,
                  TextN(MSG2_regintro),
                  SpaceS,
               Endgroup,
               Space,
            Endgroup,
            Space,
         Endgroup,
         Space,
         HorizGroupA,
				Space,
				VertGroupA,
					Space,
					TextN(MSG_name),
					SpaceB,
					TextN(MSG_email),
					SpaceB,
					TextN(MSG_street),
					SpaceB,
					TextN(MSG_city),
					SpaceB,
					TextN(MSG_country),
					SpaceB,
					TextN(MSG_rate),
					Space,
				Endgroup,
            Space,
				VertGroupA,
             	StringGadget('','5'),
            	Space,
	            StringGadget('','6'),
   	         Space,
   	         Stringgadget('','7'),
	            Space,
   	         StringGadget('','8'),
	            Space,
   	         StringGadget('','9'),
	            Space,
   	         CycleGadget(rate,'0','10'),
	            Space,
      	   Endgroup,
         	Space,
			Endgroup,
			Space,
         HorizGroupEA,
            Space,
            Button(MSG_regme,'11'),
            Space,
            Button(MSG_cancl,'12'),
            Space,
         Endgroup,
         Space,
      Endgroup,
      Endproject

/* open project */
regproject = TR_OpenProject(app,win)

closewin = 0
getentries = 0

DO WHILE closewin ~= 1
   CALL TR_Wait(app,'')
   DO WHILE TR_HandleMsg(app,event)
      IF event.trm_id = '11' then do
         closewin = 1
			getentries = 1
         end
      IF event.trm_class = "TRMS_CLOSEWINDOW" then do
         closewin = 1
         end
      IF event.trm_id = '12' then do
         closewin = 1
         end
      end
   end

IF getentries = 1 then do
	/* read values */
	name = TR_GetAttribute(regproject,'5','TROB_String')
	email = TR_GetAttribute(regproject,'6','TROB_String')
	street = TR_GetAttribute(regproject,'7','TROB_String')
	city = TR_GetAttribute(regproject,'8','TROB_String')
	country = TR_GetAttribute(regproject,'9','TROB_String')
	rating = TR_GetAttribute(regproject,'10','TRAT_Value')
	rating = rating+1

	reg.0 = 10
	reg.1 = "Hi Yves!"
	reg.2 = "Please register me as AminetFTPMail user!"
	reg.3 = ""
	reg.4 = "Name:" name
	reg.5 = "eMailaddress:" email
	reg.6 = "Street:" street
	reg.7 = "City:" city
	reg.8 = "Country:" country
	reg.9 = "My rating:" rating
	reg.10 = "Program: AminetFTPMail 2.1"

	CALL WRITEFILE('T:register.tmp',reg)

	IF show('P','YAM') then do
   	ADDRESS YAM
	   MAILWRITE
   	WRITESUBJECT "AminetFTPMail-Registration"
	   WRITETO "YvesGrabowsky@t-online.de"
   	WRITELETTER "T:register.tmp"
   	WRITEQUEUE
   	end
	ELSE do
   	call rtezrequest("You must start YAM first!!!",,"Error...",pos)
   	end
	getentries = 0
	end

CALL TR_CloseProject(regproject)

closewin = 0

return

/*------------*/
/* Interrupts */
/*------------*/

HALT:
ADDRESS YAM
APPNOBUSY
IF EXISTS('T:AFTPMail.temp') then do
   ADDRESS COMMAND
   "delete >NIL: T:AFTPMail.temp"
   "delete >NIL: T:AFTPMail-2.temp"
   end
SAY MSG_halt
exit(20)

GGS

BREAK_C:
IF EXISTS('T:AFTPMail.temp') then do
   ADDRESS COMMAND
   "delete >NIL: T:AFTPMail.temp"
   "delete >NIL: T:AFTPMail-2.temp"
   end
ADDRESS YAM
APPNOBUSY
exit(10)

GGS

IOERR:
IF EXISTS('T:AFTPMail.temp') then do
   ADDRESS COMMAND
   "delete >NIL: T:AFTPMail.temp"
   "delete >NIL: T:AFTPMail-2.temp"
   end
SAY "I/O-Error in line:" SIGL
SAY "Errorcode:" RC
SAY "Error:" ERRORTEXT(RC)
SAY "Line says:" SOURCELINE(SIGL)
exit(20)

GGS

SYNTAX:
ADDRESS YAM
APPNOBUSY
IF EXISTS('T:AFTPMail.temp') then do
   ADDRESS COMMAND
   "delete >NIL: T:AFTPMail.temp"
   "delete >NIL: T:AFTPMail-2.temp"
   end
SAY "SYNTAX Error in line:" SIGL
SAY "Errorcode:" RC
SAY "Error:" ERRORTEXT(RC)
SAY "Line says:" SOURCELINE(SIGL)
exit(20)

GGS