home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 953 / SaveMailSIS.sis / SaveMail.opl (.txt) < prev    next >
Encoding:
EPOC OPL Source  |  2001-10-18  |  28.8 KB  |  1,098 lines

  1.  
  2.  
  3. REM SaveMail (for Epoc Release 5)
  4.  
  5. REM To be used with any Epoc ER5 device
  6. REM (Psion S5mx, S5mx-pro, S7, Revo, Ericsson MC218 ...)
  7. REM and the built-in Email program
  8. REM by S.Alisi - sergioalisi@geocities.com
  9. REM http://www.geocities.com/siliconvalley/bridge/1492
  10.  
  11. APP SaveMail,&100038E5    rem please do not use this UID for other programs
  12.     ICON "SaveMail.ico"
  13. ENDA
  14.  
  15. INCLUDE "System.oxh"
  16. INCLUDE "SaveMail.cst"
  17.  
  18. CONST AppName$="SaveMail"
  19. CONST AppVersion$=" v3.12 ER5"
  20.  
  21. CONST DataUID&=&10000086
  22. CONST WordUID&=&1000007F
  23. CONST EmailUID&=&10000FFB
  24. CONST Path$="\System\Apps\SaveMail\"
  25. CONST DataPath$="C:\System\Apps\SaveMail\"
  26. CONST MacroLibPath$="\System\opx\Macro5.mcx"
  27. CONST RSCfile$="SaveMail.rsc"
  28. CONST IniFile$="SaveMail.ini"
  29. CONST HelpFile$="SaveMail.hlp"
  30. CONST SourceBoxName$="SaveMail.box"
  31. CONST ClipBoard$="C:\System\Data\Clpboard.cbd"
  32. CONST ClipExt$=".cbd"
  33. CONST TempFolder$="C:\System\Temp\"
  34. CONST TempAttachFolder$="C:\_Attachments\"    rem do not change "_"
  35.  
  36. PROC Main:
  37.     GLOBAL Macros$(255),Gclip%,Thread&,Macrothread&
  38.     GLOBAL Dev$(3),RSCfileID&
  39.     GLOBAL Email$(255),Data$(255),AttachFolder$(255)
  40.     GLOBAL AttachNameSeparator%,AttachNameType%
  41.     GLOBAL PauseValue&,AttachFilter$(255)
  42.     GLOBAL NoReply%,MultiBox%,UserDialog%
  43.     GLOBAL Machine%
  44.     GLOBAL FindSct$(12),DateTxt$(10)
  45.     GLOBAL AllSct$(12),ExitSct$(12),ReplySct$(12)
  46.     GLOBAL YesSct$(1),NewSct$(12)
  47.     GLOBAL SaveAttachSct$(12),SaveSct$(12)
  48.     GLOBAL TotMsg&,NumMsg%,DelMsg%,PasteToWord%
  49.     GLOBAL CloseTarget%,IgnoreAttach%
  50.     GLOBAL Skip%,TotSkip%
  51.     GLOBAL WrongDate%,TotWrongDate%
  52.     GLOBAL LongField%,TotLongField%,AttachTooLong%
  53.     GLOBAL Date$(30),From$(250),To$(250),CC$(250),BCC$(250)
  54.     GLOBAL Attach$(250),Subject$(250),Body$(250)
  55.  
  56.     InitProc:
  57.     Macro5LibTest:
  58.     ClipClear:
  59.     TotMsg&=1 :NumMsg%=1
  60.     IF IniSetup%: :CloseHelp:(0) :RETURN :ENDIF
  61.     IF StartEmail%: :RETURN :ENDIF
  62.     GetFocus:
  63.     IF MultiBox%
  64.         IF MultiBoxProc%:(1) :CloseHelp:(1) :RETURN :ENDIF
  65.     ENDIF
  66.     IF UserDialog%
  67.         IF UserDialogProc%: :CloseHelp:(1) :RETURN :ENDIF
  68.     ENDIF
  69.     SetFolders:
  70.     WHILE NumMsg%<=TotMsg&
  71.         CopyFromEmail:
  72.         AdjustDate:
  73.         IF PasteToWord%
  74.             PasteToWord:
  75.         ELSE
  76.             PasteToData:
  77.         ENDIF
  78.         Report:
  79.     ENDWH
  80.     CleanUp:
  81.     CloseHelp:(1)
  82. ENDP
  83.  
  84. PROC InitProc:
  85.     gUSE 1
  86.     gVISIBLE off    rem to have the Email program in background
  87.     IF Device:(Path$+RSCfile$)
  88.         RSCfileID&=LoadRsc&:(Dev$+Path$+RSCfile$)
  89.     ELSE
  90.         ALERT ("Can't find:",RSCfile$)
  91.         STOP
  92.     ENDIF
  93. ENDP
  94.  
  95. PROC Macro5LibTest:
  96.     rem check if Macro5 Libraries are installed
  97.     IF Device:(MacroLibPath$)
  98.         LOADM Dev$+MacroLibPath$
  99.     ELSE
  100.         GOTO NoMacroLib::
  101.     ENDIF
  102.     rem check if Macro5 Libraries v2.40 (or later) are installed
  103.     ONERR NoMacroLib::
  104.     IF LibVersion%: >=240
  105.         Macrothread&=GetThread&:(CMD$(1))
  106.         RETURN
  107.     ENDIF
  108.     NoMacroLib::
  109.     ONERR OFF
  110.     ALERT(AppName$+AppVersion$,ReadRsc$:(Load_Macro_Libs&))
  111.     STOP
  112. ENDP
  113.  
  114. PROC IniSetup%:
  115.     LOCAL Button%
  116.     if not exist (DataPath$+IniFile$) rem Setup required
  117.         Email$=GetApp$:(EmailUID&)
  118.         if Email$=""
  119.             alert(AppName$+AppVersion$,ReadRsc$:(No_Email&))
  120.             return -1
  121.         endif
  122.         trap mkdir DataPath$
  123.         Data$="*"+Right$(SourceBoxName$,4)
  124.         if IniStep1%:
  125.             IniResult%:(-1) :return -1
  126.         endif
  127.         if MultiBoxProc%:(0)
  128.             IniResult%:(-1) :return -1
  129.         endif
  130.         if AttachFolder%:(0)
  131.             IniResult%:(-1) :return -1
  132.         endif
  133.         if IniStep4%:
  134.             IniResult%:(-1) :return -1
  135.         endif
  136.         IniSave:
  137.         IniResult%:(0)
  138.         return -1
  139.     else
  140.         if IniRead%: :return -1 :endif
  141.     endif
  142. ENDP
  143.  
  144. PROC IniStep1%:
  145.     LOCAL Button%
  146.     Start::
  147.     dinit AppName$+" "+ReadRsc$:(Setup_1&),16
  148.     dchoice Machine%,ReadRsc$:(Select_device&),"UK-US English ER5,..."
  149.     dchoice Machine%,"","German S5mx-pro & Revo,..."
  150.     dchoice Machine%,"","Netherlands S5mx,..."
  151.     dchoice Machine%,"","French S5mx,..."
  152.     dchoice Machine%,"","Italian S5mx,..."
  153.     dchoice Machine%,"","German MC218,..."
  154.     dchoice Machine%,"","Italian Revo,..."
  155.     dchoice Machine%,"","Spanish S5mx"
  156.     dcheckbox NoReply%,ReadRsc$:(Disable_date_1&)
  157.     dtext ""," "+ReadRsc$:(Disable_date_2&)
  158.     dlong PauseValue&,ReadRsc$:(Pause_value_1&)+" (8-30):",8,30
  159.     dtext ""," "+ReadRsc$:(Pause_value_2&)
  160.     dbuttons ReadRsc$:(Btn_Help&),%H,ReadRsc$:(Btn_Cancel&),27,ReadRsc$:(Btn_Continue&),13
  161.     Button%=dialog
  162.     if Button%=13
  163.         if Machine%>7
  164.             NotSupported: :return -1
  165.         endif
  166.     elseif Button%=%h
  167.         Help:
  168.         goto Start::
  169.     else
  170.         return -1
  171.     endif
  172.     if not NoReply%
  173.         dinit ReadRsc$:(Please_read_1&)
  174.         dtext "",ReadRsc$:(Please_read_2&)
  175.         dtext "",ReadRsc$:(Please_read_3&)
  176.         dbuttons ReadRsc$:(Btn_Continue&),13
  177.         dialog
  178.     endif
  179. ENDP
  180.  
  181. PROC IniStep4%:
  182.     LOCAL Button%
  183.     Start::
  184.     dinit AppName$+" "+ReadRsc$:(Setup_4&),16
  185.     dtext "",ReadRsc$:(Launch_options&)
  186.     dcheckbox MultiBox%,"1) "+ReadRsc$:(Target_file&)
  187.     dtext "","2) "+ReadRsc$:(Dialog_win_1&)
  188.     dcheckbox UserDialog%,ReadRsc$:(Dialog_win_2&)
  189.     dbuttons ReadRsc$:(Btn_Help&),%H,ReadRsc$:(Btn_Cancel&),27,ReadRsc$:(Btn_Continue&),13
  190.     Button%=dialog
  191.     if Button%=13
  192.     elseif Button%=%h
  193.         Help:
  194.         goto Start::
  195.     else
  196.         return -1
  197.     endif
  198. ENDP
  199.  
  200. PROC IniResult%:(Type%)
  201.     dinit AppName$+AppVersion$
  202.     if Type%=-1    rem Setup aborted
  203.         dtext "",ReadRsc$:(Setup_aborted_1&)
  204.         dtext "",ReadRsc$:(Setup_aborted_2&)
  205.     else    rem Setup completed
  206.         dtext "",ReadRsc$:(Setup_completed_1&)
  207.         dtext "",ReadRsc$:(Setup_completed_2&)
  208.     endif
  209.     dbuttons ReadRsc$:(Btn_Continue&),13
  210.     dialog
  211. ENDP
  212.  
  213. PROC IniSave:
  214.     create DataPath$+IniFile$,a,Email$,Data$,AttachFolder$,AttachNameSeparator%,AttachNameType%,NoReply%,MultiBox%,UserDialog%,Machine%,PauseValue&,AttachFilter$
  215.     a.Email$=Email$
  216.     a.Data$=Data$
  217.     a.AttachFolder$=AttachFolder$
  218.     a.AttachNameSeparator%=AttachNameSeparator%
  219.     a.AttachNameType%=AttachNameType%
  220.     a.NoReply%=NoReply%
  221.     a.MultiBox%=MultiBox%
  222.     a.UserDialog%=UserDialog%
  223.     a.Machine%=Machine%
  224.     a.PauseValue&=PauseValue&
  225.     a.AttachFilter$=AttachFilter$
  226.     append
  227.     close
  228. ENDP
  229.  
  230. PROC IniRead%:
  231.     onerr Wrong_ini::
  232.     open DataPath$+IniFile$,a,Email$,Data$,AttachFolder$,AttachNameSeparator%,AttachNameType%,NoReply%,MultiBox%,UserDialog%,Machine%,PauseValue&,AttachFilter$
  233.     Email$=a.Email$
  234.     Data$=a.Data$
  235.     AttachFolder$=a.AttachFolder$
  236.     AttachNameSeparator%=a.AttachNameSeparator%
  237.     AttachNameType%=a.AttachNameType%
  238.     NoReply%=a.NoReply%
  239.     MultiBox%=a.MultiBox%
  240.     UserDialog%=a.UserDialog%
  241.     Machine%=a.Machine%
  242.     PauseValue&=a.PauseValue&
  243.     AttachFilter$=a.AttachFilter$
  244.     onerr off
  245.     close
  246.     Shortcuts:
  247.     return
  248.     Wrong_ini::
  249.     dinit AppName$+AppVersion$,16
  250.     dtext "",ReadRsc$:(Wrong_ini_1&)
  251.     dtext "",ReadRsc$:(Wrong_ini_2&)
  252.     dtext "",ReadRsc$:(Wrong_ini_3&)
  253.     dbuttons ReadRsc$:(Btn_Cancel&),27,ReadRsc$:(Btn_Continue&),13
  254.     if dialog
  255.         delete DataPath$+IniFile$
  256.         IniSetup%:
  257.     endif
  258.     return -1
  259. ENDP
  260.  
  261. PROC NotSupported:
  262.     dinit AppName$+AppVersion$,16
  263.     dtext "",ReadRsc$:(Not_supported_1&)
  264.     dtext "",ReadRsc$:(Not_supported_2&)
  265.     dtext "",ReadRsc$:(Not_supported_3&),$200
  266.     dtext "",ReadRsc$:(Not_supported_4&)
  267.     dbuttons ReadRsc$:(Btn_Continue&),13
  268.     dialog
  269. ENDP
  270.  
  271. PROC Shortcuts:
  272.     rem define all the shortcuts depending on Machine% type
  273.     LOCAL StrSct$(8)
  274.     rem StrSct$(8)=[all+exit+find+reply+yes+new+save+save_attach]
  275.     if Machine%=1    rem UK-US Eglish ER5
  276.         StrSct$="aefrynss"
  277.         DateTxt$="Date:"
  278.     elseif Machine%=2    rem German S5mx-pro & Revo
  279.         StrSct$="aefbjnss"
  280.         DateTxt$="Datum:"
  281.     elseif Machine%=3    rem Netherlands S5mx-pro
  282.         StrSct$="aefrjnss"
  283.         DateTxt$="Datum:"
  284.     elseif Machine%=4    rem French S5mx
  285.         StrSct$="oqrdoass"
  286.         DateTxt$="Date :"
  287.     elseif Machine%=5    rem Italian S5mx
  288.         StrSct$="zefrsgss"
  289.         DateTxt$="Data:"
  290.     elseif Machine%=6    rem German MC218
  291.         StrSct$="aefrynss"
  292.         DateTxt$="Datum:"
  293.     elseif Machine%=7    rem Italian Revo
  294.         StrSct$="uetdsnsv"
  295.         DateTxt$="Data:"
  296.     elseif Machine%=8    rem Spanish S5mx
  297.         StrSct$="????????"
  298.         DateTxt$="?:"
  299.     endif
  300.     if Machine%=5 or Machine%=7    rem only for Italian S5mx and Revo
  301.         AllSct$="Ctrl+Shift+"+mid$(StrSct$,1,1)    rem Email/Word: "select all" ("Ctrl+a" for UK/USA)
  302.     else
  303.         AllSct$="Ctrl+"+mid$(StrSct$,1,1)            rem Email/Word: "select all" ("Ctrl+a" for UK/USA)
  304.     endif
  305.     ExitSct$="Ctrl+"+mid$(StrSct$,2,1)            rem Email: exit fax preview ("Ctrl+e" for UK/USA)
  306.     FindSct$="Ctrl+"+mid$(StrSct$,3,1)            rem Email: open Find dialog box ("Ctrl+f" for UK/USA)
  307.     ReplySct$="Ctrl+"+mid$(StrSct$,4,1)            rem Email: Reply to a message ("Ctrl+r" for UK/USA)
  308.     YesSct$=mid$(StrSct$,5,1)                                rem Email: "Yes" button keystroke to confirm deletion of a message ("y" for UK/USA)
  309.     if Machine%=4 or Machine%=7    rem only for French S5mx and Italian Revo
  310.         NewSct$="Ctrl+"+mid$(StrSct$,6,1)            rem Data: New Entry ("Ctrl+Shift+n" for UK/USA)
  311.     else
  312.         NewSct$="Ctrl+Shift+"+mid$(StrSct$,6,1)    rem Data: New Entry ("Ctrl+Shift+n" for UK/USA)
  313.     endif
  314.     SaveSct$="Ctrl+"+mid$(StrSct$,7,1)            rem Data: Save Entry ("Ctrl+s" for UK/USA)
  315.     SaveAttachSct$="Ctrl+Shift+"+mid$(StrSct$,8,1)    rem Email: Save Attachment ("Shift+Ctrl+s" for UK/USA)
  316. ENDP
  317.  
  318. PROC StartEmail%:
  319.     busy ReadRsc$:(Opening_Email_1&),3,1
  320.     if (FgApp%:(Email$))=1
  321.         busy off
  322.         GetFocus:
  323.         alert(ReadRsc$:(Opening_Email_2&),ReadRsc$:(Opening_Email_3&))
  324.         FgApp%:(Email$)
  325.         return -1
  326.     endif
  327.     busy off
  328. ENDP
  329.  
  330. PROC MultiBoxProc%:(Type%)
  331.     LOCAL ChoiceStr$(255),Action%,Button%
  332.     Start::
  333.     if Type%=1    rem call from Main: procedure
  334.         open DataPath$+IniFile$,a,Email$,Data$,AttachFolder$,AttachNameSeparator%,AttachNameType%,NoReply%,MultiBox%,UserDialog%,Machine%,PauseValue&,AttachFilter$
  335.         Data$=a.Data$
  336.         AttachFolder$=a.AttachFolder$
  337.         AttachNameSeparator%=a.AttachNameSeparator%
  338.         AttachNameType%=a.AttachNameType%
  339.         close
  340.         dinit AppName$+AppVersion$,16
  341.         dtext "",ReadRsc$:(Select_target&)
  342.     else    rem call from IniSetup%: procedure
  343.         dinit AppName$+" "+ReadRsc$:(Setup_2&)
  344.         dtext "",ReadRsc$:(Select_default_target&)
  345.     endif
  346.     dfile Data$,ReadRsc$:(File_Folder_Disk&),128+8+32,0,0,DataUID&
  347.     ChoiceStr$=ReadRsc$:(Default_choice&)+","+ReadRsc$:(New_Mailbox&)
  348.     if Type%=1
  349.         ChoiceStr$=ChoiceStr$+","+ReadRsc$:(Word_option&)+","+ReadRsc$:(New_Word_option&)+","+ReadRsc$:(Setup_option&)
  350.     endif
  351.     dchoice Action%,ReadRsc$:(Action_choice&),ChoiceStr$
  352.     dbuttons ReadRsc$:(Btn_Help&),%H,ReadRsc$:(Btn_Cancel&),27,ReadRsc$:(Btn_Continue&),13
  353.     Button%=dialog
  354.     if Button%=13
  355.         if Action%=1
  356.             if Data$=""
  357.                 giprint ReadRsc$:(No_target_file&)
  358.                 goto Start::
  359.             endif
  360.         elseif Action%=2
  361.             if NewData%:(Type%) :goto Start:: :endif
  362.         elseif Action%=3
  363.             if UseWord%: :goto Start:: :endif
  364.         elseif Action%=4
  365.             if NewWord%: :goto Start:: :endif
  366.         elseif Action%=5
  367.             if NewSetup%: :goto Start:: :endif
  368.         endif
  369.     elseif Button%=%h
  370.         Help:
  371.         goto Start::
  372.     else
  373.         return -1
  374.     endif
  375.     giprint ReadRsc$:(Target_file_is&)+" "+Data$
  376.     pause 20
  377. ENDP
  378.  
  379. PROC NewData%:(Type%)
  380.     LOCAL SetDefault%,SourceBox$(255)
  381.     if Device:(Path$+SourceBoxName$)
  382.         SourceBox$=Dev$+Path$+SourceBoxName$
  383.         Data$=Right$(SourceBoxName$,4)
  384.         dinit AppName$+AppVersion$,16
  385.         dtext "",ReadRsc$:(Create_new_MailBox&)
  386.         dfile Data$,ReadRsc$:(File_Folder_Disk&),1+8
  387.         if Type%=1
  388.             dcheckbox SetDefault%,ReadRsc$:(Set_as_default&)
  389.         endif
  390.         dbuttons ReadRsc$:(Btn_Cancel&),27,ReadRsc$:(Btn_Continue&),13
  391.         if dialog
  392.             copy SourceBox$,Data$
  393.             if SetDefault% and Type%=1
  394.                 open DataPath$+IniFile$,a,Email$,Data$,AttachFolder$,AttachNameSeparator%,AttachNameType%,NoReply%,MultiBox%,UserDialog%,Machine%,PauseValue&,AttachFilter$
  395.                 a.Data$=Data$
  396.                 update
  397.                 close
  398.             endif
  399.         else
  400.             return -1
  401.         endif
  402.     else
  403.         giprint ReadRsc$:(NEW_option_not&)
  404.         Data$=Right$(SourceBoxName$,4)
  405.         return -1
  406.     endif
  407. ENDP
  408.  
  409. PROC UseWord%:
  410.     LOCAL Button%
  411.     Start::
  412.     Data$=""
  413.     dinit AppName$+AppVersion$,16
  414.     dtext "",ReadRsc$:(Select_Word&)
  415.     dfile Data$,ReadRsc$:(File_Folder_Disk&),128+8+32,0,0,WordUID&
  416.     dbuttons ReadRsc$:(Btn_Cancel&),27,ReadRsc$:(Btn_Continue&),13
  417.     Button%=dialog
  418.     if Button%=13
  419.         if Data$=""
  420.             giprint ReadRsc$:(No_target_file&)
  421.             goto Start::
  422.         else
  423.             UseDoc%:("Word",Data$,3)    rem open in background
  424.             pause 2*PauseValue&
  425.             PasteToWord%=-1
  426.             FgApp%:(Email$)
  427.             GetFocus:
  428.         endif
  429.     else
  430.         return -1
  431.     endif
  432. ENDP
  433.  
  434. PROC NewWord%:
  435.     LOCAL Button%
  436.     Data$=""
  437.     dinit AppName$+AppVersion$,16
  438.     dtext "",ReadRsc$:(Create_Word&)
  439.     dfile Data$,ReadRsc$:(File_Folder_Disk&),1+8
  440.     dbuttons ReadRsc$:(Btn_Cancel&),27,ReadRsc$:(Btn_Continue&),13
  441.     if dialog
  442.         UseDoc%:("Word",Data$,1)    rem create new word file
  443.         pause 2*PauseValue&
  444.         PasteToWord%=-1
  445.         FgApp%:(Email$)
  446.         GetFocus:
  447.     else
  448.         return -1
  449.     endif
  450. ENDP
  451.  
  452. PROC NewSetup%:
  453.     dinit AppName$+AppVersion$
  454.     dtext "",ReadRsc$:(Relaunch_Setup_1&)
  455.     dtext "",ReadRsc$:(Relaunch_Setup_2&)
  456.     dbuttons ReadRsc$:(Btn_Cancel&),27,ReadRsc$:(Btn_Continue&),13
  457.     if dialog
  458.         delete DataPath$+IniFile$
  459.         if IniSetup%: :stop :endif
  460.     else
  461.         Data$=Right$(SourceBoxName$,4)
  462.         return -1
  463.     endif
  464. ENDP
  465.  
  466. PROC AttachFolder%:(Type%)
  467.     LOCAL Button%
  468.     Start::
  469.     if Type%=0    rem call from IniSetup%: procedure
  470.         AttachNameType%=-1
  471.         dinit AppName$+" "+ReadRsc$:(Setup_3&),16
  472.         dtext "",ReadRsc$:(Select_default_folder&)
  473.     else    rem call from UserDialogProc%: procedure
  474.         dinit AppName$+AppVersion$,16
  475.         dtext "",ReadRsc$:(Select_folder&)
  476.     endif
  477.     dfile AttachFolder$,ReadRsc$:(Folder_Disk&),4
  478.     dchoice AttachNameSeparator%,ReadRsc$:(Optimize_names_1&),ReadRsc$:(Optimize_names_2&)
  479.     dcheckbox AttachNameType%,ReadRsc$:(Use_full_pathnames&)
  480.     dbuttons ReadRsc$:(Btn_Help&),%H,ReadRsc$:(Btn_New_Folder&),%N,ReadRsc$:(Btn_Set_Filters&),%F,ReadRsc$:(Btn_Cancel&),27,ReadRsc$:(Btn_Continue&),13
  481.     Button%=dialog
  482.     if Button%=13
  483.     elseif Button%=%h
  484.         Help: :goto Start::
  485.     elseif Button%=%n
  486.         if NewAttachFolder%: :goto Start:: :endif
  487.     elseif Button%=%f
  488.         if AttachFilters%: :goto Start:: :endif
  489.     else
  490.         return -1
  491.     endif
  492.     giprint ReadRsc$:(Attachment_folder_is&)+" "+AttachFolder$
  493.     pause 20
  494. ENDP
  495.  
  496. PROC NewAttachFolder%:
  497.     Start::
  498.     dinit AppName$+AppVersion$
  499.     dtext "",ReadRsc$:(Create_new_folder&)
  500.     dfile AttachFolder$,ReadRsc$:(Folder_Path_Disk&),1+2
  501.     dbuttons ReadRsc$:(Btn_Cancel&),27,ReadRsc$:(Btn_Continue&),13
  502.     if dialog
  503.         if exist(AttachFolder$)
  504.             giprint ReadRsc$:(Folder_exists&)
  505.             goto Start::
  506.         endif
  507.         AttachFolder$=AttachFolder$+"\"
  508.     else
  509.         return -1
  510.     endif
  511. ENDP
  512.  
  513. PROC AttachFilters%:
  514.     LOCAL Filter$(4,32),Separator$(1),Button%,i%,j%
  515.     Separator$=CHR$(13)
  516.     Start::
  517.     if AttachFilter$<>""
  518.         i%=1 :j%=1
  519.         do
  520.             Filter$(i%)=""
  521.             while mid$(AttachFilter$,j%,1)<>Separator$
  522.                 Filter$(i%)=Filter$(i%)+mid$(AttachFilter$,j%,1)
  523.                 j%=j%+1
  524.             endwh
  525.             i%=i%+1
  526.             if len(AttachFilter$)>j% :j%=j%+1 :endif    rem skip separator
  527.         until i%>4
  528.     endif
  529.     dinit AppName$+AppVersion$,16
  530.     dtext "",ReadRsc$:(Ignore_Attachment&)
  531.     dedit Filter$(1),"-",15
  532.     dedit Filter$(2),"-",15
  533.     dedit Filter$(3),"-",15
  534.     dedit Filter$(4),"-",15
  535.     dbuttons ReadRsc$:(Btn_Clear_All&),%A,ReadRsc$:(Btn_Cancel&),27,ReadRsc$:(Btn_Continue&),13
  536.     Button%=dialog
  537.     if Button%=13
  538.         i%=4
  539.         AttachFilter$=""
  540.         do
  541.             AttachFilter$=Filter$(i%)+Separator$+AttachFilter$
  542.             i%=i%-1
  543.         until i%=0
  544.         return -1
  545.     elseif Button%=%a
  546.         i%=1
  547.         do
  548.             Filter$(i%)=""
  549.             i%=i%+1
  550.         until i%>4
  551.         AttachFilter$=""
  552.         goto Start::
  553.     else
  554.         return -1
  555.     endif
  556. ENDP
  557.  
  558. PROC UserDialogProc%:
  559.     LOCAL Button%
  560.     Start::
  561.     dinit AppName$+AppVersion$,16
  562.     dlong TotMsg&,ReadRsc$:(Messages_to_store_1&),1,100
  563.     dtext "",ReadRsc$:(Messages_to_store_2&),$200
  564.     dcheckbox DelMsg%,"- "+ReadRsc$:(Delete_option&)
  565.     dcheckbox CloseTarget%,"- "+ReadRsc$:(Close_option&)
  566.     dcheckbox IgnoreAttach%,"- "+ReadRsc$:(Ignore_option&)
  567.     dbuttons ReadRsc$:(Btn_Help&),%H,ReadRsc$:(Btn_Atch_Folder&),%A,ReadRsc$:(Btn_Cancel&),27,ReadRsc$:(Btn_Continue&),13
  568.     Button%=dialog
  569.     if Button%=%a
  570.         AttachFolder%:(1)
  571.         goto Start::
  572.     elseif Button%=%h
  573.         Help:
  574.         goto Start::
  575.     elseif Button%<>13
  576.         return -1
  577.     endif
  578.     if DelMsg%
  579.         dinit ReadRsc$:(Please_read_a&),16
  580.         dtext "",ReadRsc$:(Please_read_b&)
  581.         dtext "","- "+ReadRsc$:(Please_read_c&)
  582.         dtext "","- "+ReadRsc$:(Please_read_d&)
  583.         dtext "",ReadRsc$:(Please_read_e&)
  584.         dtext "",ReadRsc$:(Please_read_f&),$200
  585.         dtext "",ReadRsc$:(Please_read_g&)
  586.         dbuttons ReadRsc$:(Btn_Disable&),%D,ReadRsc$:(Btn_Abort&),27,ReadRsc$:(Btn_Continue&),13
  587.         Button%=dialog
  588.         if Button%=%d
  589.             DelMsg%=0
  590.             giprint ReadRsc$:(Auto_Delete_disabled&)
  591.             pause 20
  592.         elseif Button%<>13
  593.             return -1
  594.         endif
  595.     endif
  596. ENDP
  597.  
  598. PROC SetFolders:
  599.     if not exist(TempFolder$)
  600.         mkdir TempFolder$
  601.     endif
  602.     if not exist(TempAttachFolder$)
  603.         mkdir TempAttachFolder$
  604.     endif
  605.     if not exist(AttachFolder$)
  606.         trap mkdir AttachFolder$
  607.     endif
  608. ENDP
  609.  
  610. PROC CopyFromEmail:
  611.     LOCAL Dummy$(255)
  612.     FgApp%:(Email$)
  613.     Setthread:
  614.     if NumMsg%=1    rem first message to store
  615.         SendKey:("Right")    rem move to the message frame
  616.     endif
  617.     SendKey:("Enter")    rem open the highlighted message
  618.     pause 5*PauseValue&
  619.     SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  620.     if Copy$:=""    rem message is a fax
  621.         Skip%=-1
  622.         TotSkip%=TotSkip%+1
  623.         pause 20
  624.         SendKey:(ExitSct$)    rem exit fax preview ("Ctrl+e" for UK/USA)
  625.     else
  626.         SendKey:("Up")    rem try to move to the priority field
  627.         Dummy$=Copy$:
  628.         if Dummy$=""    rem priority field available (no FROM field & no REPLY)
  629.             From$="..."
  630.             WrongDate%=-1
  631.             TotWrongDate%=TotWrongDate%+1
  632.             SendKey:("Down")    rem back to TO field
  633.         else    rem message is not a Sent one moved from the Sent folder
  634.             pause 2*PauseValue&
  635.             SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  636.             From$=Left$(Dummy$,250)
  637.             pause 10
  638.             SendKey:("Right,Down")    rem move to TO field
  639.             SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  640.         endif
  641.         Dummy$=Copy$:
  642.         ClipCopy:("To")
  643.         To$=Left$(Dummy$,250)
  644.         SendKey:("Right,Down")    rem move to CC field (if present)
  645.         SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  646.         pause 10
  647.         SendKey:("Right,Down")    rem move to BCC field (if present)
  648.         SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  649.         pause 10
  650.         SendKey:("Right,Down")    rem move to ATTACHMENT field
  651.         SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  652.         pause 10
  653.         SendKey:("Up")    rem move temporary back to BCC field (if multiple attachments)
  654.         SendKey:("Fn+Down")    rem move temporary to BODY field
  655.         pause 10
  656.         SendKey:("Up")    rem move back to SUBJECT field
  657.         SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  658.         pause 10
  659.         SendKey:("Right+Down")    rem move to BODY field
  660.         SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  661.         pause 10
  662.         SendKey:("Up")    rem move back to SUBJECT field
  663.         SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  664.         pause 10
  665.         SendKey:("Up")    rem move back to ATTACHMENT field
  666.         SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  667.         pause 10
  668.         SendKey:("Up")    rem move back to BCC field (if present)
  669.         SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  670.         pause 10
  671.         Dummy$=Copy$:
  672.         ClipCopy:("BCC")
  673.         BCC$=Left$(Dummy$,250)
  674.         if BCC$=To$ or BCC$=From$
  675.             BCC$=""
  676.         else
  677.             SendKey:("Up")    rem move back to CC field (if present)
  678.             SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  679.             pause 10
  680.             Dummy$=Copy$:
  681.             ClipCopy:("CC")
  682.             CC$=Left$(Dummy$,250)
  683.             if CC$=To$ or BCC$=From$
  684.                 CC$=""
  685.             endif
  686.         endif
  687.         SendKey:("Right+Down")    rem skip multiline fields
  688.         SendKey:("Right+Down")    rem skip multiline fields
  689.         SendKey:("Right+Down")    rem skip multiline fields
  690.         pause 10
  691.         SendKey:("Fn+Down")            rem move to BODY field
  692.         SendKey:("Up")    rem move back to SUBJECT field
  693.         SendKey:("Up")    rem move to ATTACHMENT field
  694.         SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  695.         pause 10
  696.         if IgnoreAttach%<>-1
  697.             SaveAttachments:
  698.         endif
  699.         SendKey:("Up")    rem move back to BCC field
  700.         SendKey:("Right+Down")    rem exit the BCC field if multiline
  701.         SendKey:("Fn+Down")    rem move to the LAST attachment if many
  702.         SendKey:("Fn+Down")    rem move back to BODY field
  703.         pause 10
  704.         SendKey:("Up")    rem move to SUBJECT field
  705.         SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  706.         pause 10
  707.         Dummy$=Copy$:
  708.         Subject$=Left$(Dummy$,250)
  709.         SendKey:("Right,Down")    rem move to BODY field
  710.         SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  711.         pause 2*PauseValue&
  712.         Dummy$=Copy$:
  713.         ClipCopy:("Body")
  714.         Body$=Left$(Dummy$,250)
  715.         pause 2*PauseValue&
  716.         if NoReply%<>-1 and WrongDate%<>-1    rem Reply available & selected
  717.             ReplyMessage:
  718.         else
  719.             SendKey:("Esc")    rem close message
  720.         endif
  721.         pause 2*PauseValue&
  722.         if Len(Subject$)=250 or Len(From$)=250 or AttachTooLong%
  723.             LongField%=-1
  724.             TotLongField%=TotLongField%+1
  725.             Dummy$="(*) "+Subject$
  726.             Subject$=Left$(Dummy$,250)
  727.         endif
  728.     endif
  729. ENDP
  730.  
  731. PROC ReplyMessage:
  732.     Setthread:
  733.     SendKey:(ReplySct$)    rem Reply to sender ("Ctrl+r" for UK/USA)
  734.     pause 10*PauseValue&
  735.     SendKey:(FindSct$)    rem open Find dialog box ("Ctrl+f" for UK/USA)
  736.     pause 7*PauseValue&
  737.     Paste:(DateTxt$)    rem look for "Date:"
  738.     SendKey:("Enter")    rem confirm search
  739.     SendKey:("Right")    rem skip the "Date:" caption
  740.     pause 10
  741.     SendKey:("Ctrl+Right")    rem skip the day field
  742.     SendKey:("Ctrl+Right")    rem skip the day field
  743.     pause 10
  744.     SendKeyCode:($1008,$480,4)    rem ┬½Ctrl+Shift+Right┬╗ 4 times
  745.     SendKey:("Shift+Left")    rem skip the space
  746.     Date$=Copy$:
  747.     if len(Date$)=19    rem "d mmm yyyy hh:mm:ss"
  748.         Date$="0"+Date$    rem just to have "dd ..." instead of "d ..."
  749.     elseif len(Date$)<>20    rem problem with the procedure
  750.         WrongDate%=-1
  751.         TotWrongDate%=TotWrongDate%+1
  752.     endif
  753.     SendKey:("Esc")    rem abort Reply
  754.     pause 2*PauseValue&
  755. ENDP
  756.  
  757. PROC SaveAttachments:
  758.     local File$(255),ShortFile$(255),i%,j%
  759.     Setthread:
  760.     Attach$=""
  761.     SendKey:(SaveAttachSct$)    rem "save attachment(s)" ("Ctrl+Shift+s" for UK/USA)
  762.     if Copy$:<>""    rem only one attachment (File name present)
  763.         SendKey:("Down")    rem move to the Folder selector
  764.     endif
  765.     SendKey:("_")    rem choose attachments folder
  766.     SendKey:("Enter")    rem confirm saving
  767.     pause 2*PauseValue&
  768.     File$=dir$(TempAttachFolder$+"*")
  769.     i%=0    rem number of stored attachments
  770.     while File$<>""
  771.         ShortFile$=right$(File$,len(File$)-len(TempAttachFolder$))
  772.         if loc(AttachFilter$,ShortFile$)<>0    rem filter attachment?
  773.             goto NoSave::
  774.         endif
  775.         i%=i%+1
  776.         j%=0    rem number of attachments with same name
  777.         while exist(AttachFolder$+ShortFile$)
  778.             j%=j%+1
  779.             if j%>1 :ShortFile$=left$(ShortFile$,len(ShortFile$)-4) :endif
  780.             ShortFile$=ShortFile$+"("+right$("0"+gen$(j%,2),2)+")"
  781.         endwh
  782.         onerr String_Too_Long:: 
  783.         if AttachNameSeparator%=2    rem optimize for "list view"
  784.             Attach$=Attach$+gen$(i%,2)+")"
  785.         endif
  786.         if AttachNameType%
  787.             Attach$=Attach$+AttachFolder$    rem store full pathname
  788.         endif
  789.         if AttachNameSeparator%=2    rem optimize for "list view"
  790.             Attach$=Attach$+ShortFile$+" - "
  791.         else
  792.             Attach$=Attach$+ShortFile$+Chr$(6)    rem Chr$(6) to get each attachment on new line
  793.         endif
  794.         String_Too_Long::
  795.         if ERR=-112    rem "String too long"
  796.             AttachTooLong%=-1
  797.         endif
  798.         onerr off
  799.         copy File$,AttachFolder$+ShortFile$
  800.         NoSave::
  801.         delete File$
  802.         File$=dir$("")
  803.     endwh
  804. ENDP
  805.  
  806. PROC AdjustDate:
  807.     rem the following code simply changes the DATE
  808.     rem as copied from Email "dd mmm yyyy hh:mm:ss"
  809.     rem to "yyyy/mm/dd hh:mm:ss"
  810.     rem to have messages properly sorted by date
  811.     LOCAL En_Month$(12,3)    rem stores the month names in English
  812.     LOCAL D$(2),M$(3),Y$(4),i%
  813.     if Skip% :return :endif
  814.     if NoReply% or WrongDate%    rem "Reply to" routine disabled or unable to get Date$
  815.         Date$=gen$(year,4)+"/"+right$("0"+gen$(month,2),2)+"/"+right$("0"+gen$(day,2),2)
  816.         Date$=Date$+" "+right$("0"+gen$(hour,2),2)+":"+right$("0"+gen$(minute,2),2)+" (*)"
  817.     else    rem correct Date$ from "Reply to" routine
  818.         En_Month$(1)="Jan" :En_Month$(2)="Feb"
  819.         En_Month$(3)="Mar" :En_Month$(4)="Apr"
  820.         En_Month$(5)="May" :En_Month$(6)="Jun"
  821.         En_Month$(7)="Jul" :En_Month$(8)="Aug"
  822.         En_Month$(9)="Sep" :En_Month$(10)="Oct"
  823.         En_Month$(11)="Nov" :En_Month$(12)="Dec"
  824.         D$=Left$(Date$,2)
  825.         M$=Mid$(Date$,4,3)
  826.         Y$=Mid$(Date$,8,4)
  827.         do :i%=i%+1
  828.         until upper$(M$)=upper$(Month$(i%)) or upper$(M$)=upper$(En_Month$(i%))
  829.         M$=right$("0"+gen$(i%,2),2)
  830.         Date$=Right$(Date$,Len(Date$)-11)
  831.         Date$=Y$+"/"+M$+"/"+D$+Date$
  832.     endif
  833. ENDP
  834.  
  835. PROC PasteToData:
  836.     if (FgApp%:(Data$))=1
  837.         pause 4*PauseValue&
  838.     endif
  839.     Setthread:
  840.     pause 4*PauseValue&
  841.     if NumMsg%=1    rem first message (or single message) to store
  842.         SendKey:(NewSct$)    rem new entry ("Ctrl+Shift+n" for UK/USA)
  843.     endif
  844.     pause 2*PauseValue&
  845.     if Skip%<>-1
  846.         if Subject$<>""
  847.             Paste:(Subject$)
  848.             pause 20
  849.         endif
  850.         SendKey:("Tab")    rem move to DATE field
  851.         Paste:(Date$)
  852.         pause 20
  853.         SendKey:("Tab")    rem move to FROM field
  854.         Paste:(From$)
  855.         pause 20
  856.         SendKey:("Tab")    rem move to TO field
  857.         if To$<>""
  858.             ClipPaste:("To")
  859.             pause 20
  860.         endif
  861.         SendKey:("Tab")    rem move to CC/BCC field
  862.         if CC$<>""
  863.             ClipPaste:("CC")
  864.             pause 20
  865.             if BCC$<>""
  866.                 SendKey:("Enter")
  867.             endif
  868.         endif
  869.         if BCC$<>""
  870.             ClipPaste:("BCC")
  871.             pause 20
  872.         endif
  873.         SendKey:("Tab")    rem move to Attachment(s) field
  874.         if Attach$<>""
  875.             Paste:(Attach$)
  876.             pause 20
  877.         endif
  878.         SendKey:("Tab")    rem move to BODY field
  879.         if Body$<>""
  880.             ClipPaste:("Body")
  881.             pause 2*PauseValue&
  882.         endif
  883.         SendKey:(SaveSct$)    rem save message ("Ctrl+s" for UK/USA)
  884.     endif
  885.     pause 2*PauseValue&
  886.     if NumMsg%=TotMsg&    rem last message (or single message) stored
  887.         SendKey:("Esc")    rem exit from "new entry mode"
  888.         if CloseTarget%
  889.             SendKey:(ExitSct$)    rem close target file ("Ctrl+e" for UK/USA)
  890.             pause 2*PauseValue&
  891.         endif
  892.     endif
  893. ENDP
  894.  
  895. PROC PasteToWord:
  896.     if Skip% :return :endif
  897.     FgDoc%:(Data$)
  898.     Setthread:
  899.     pause 4*PauseValue&
  900.     SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  901.     SendKey:("Left")
  902.     pause 2*PauseValue&
  903.     if Subject$<>""
  904.         SendKey:("Enter")
  905.         Paste:("* "+ReadRsc$:(Subject&)+": "+Subject$)
  906.         pause 20
  907.     endif
  908.     SendKey:("Enter")
  909.     Paste:("* "+ReadRsc$:(Date&)+": "+Date$)
  910.     pause 20
  911.     if From$<>""
  912.         SendKey:("Enter")
  913.         Paste:("* "+ReadRsc$:(From&)+": "+From$)
  914.         pause 20
  915.     endif
  916.     if To$<>""
  917.         SendKey:("Enter")
  918.         Paste:("* "+ReadRsc$:(To&)+": ")
  919.         ClipPaste:("To")
  920.         pause 20
  921.     endif
  922.     if CC$<>""
  923.         SendKey:("Enter")
  924.         Paste:("* CC: ")
  925.         ClipPaste:("CC")
  926.         pause 20
  927.     endif
  928.     if BCC$<>""
  929.         SendKey:("Enter")
  930.         Paste:("* BCC: ")
  931.         ClipPaste:("BCC")
  932.         pause 20
  933.     endif
  934.     if Attach$<>""
  935.         SendKey:("Enter")
  936.         Paste:("* "+ReadRsc$:(Attachments&)+":"+Chr$(6)+Attach$)
  937.         pause 20
  938.     endif
  939.     if Body$<>""
  940.         SendKey:("Enter")
  941.         Paste:("* "+ReadRsc$:(Body&)+":")
  942.         SendKey:("Enter")
  943.         ClipPaste:("Body")
  944.         pause 2*PauseValue&
  945.     endif
  946.     SendKey:("Enter")
  947.     Paste:("************ "+ReadRsc$:(End_of_message&)+" ************")
  948.     SendKey:("Enter")
  949.     pause 20
  950.     SendKey:(AllSct$)    rem "select all" ("Ctrl+a" for UK/USA)
  951.     pause 20
  952.     SendKey:("Left")    rem put the cursor at the beginning of the document
  953.     if CloseTarget%
  954.         SendKey:(ExitSct$)    rem close target file ("Ctrl+e" for UK/USA)
  955.         pause 20
  956.     endif
  957. ENDP
  958.  
  959. PROC Report:
  960.     LOCAL Message$(80),Button%
  961.     GetFocus:
  962.     Setthread:
  963.     if NoReply%
  964.         WrongDate%=0    rem no "Wrong date" alert if Reply disabled
  965.     endif
  966.     if Skip%    rem message is a fax
  967.         giprint ReadRsc$:(Message_not_stored&)
  968.     elseif WrongDate%    rem message with wrong date
  969.         giprint ReadRsc$:(Message&)+" "+gen$(NumMsg%,3)+" "+ReadRsc$:(Stored_wrong_date&)
  970.     elseif LongField%    rem message with truncated field
  971.         giprint ReadRsc$:(Message&)+" "+gen$(NumMsg%,3)+" "+ReadRsc$:(Stored_truncated_field&)
  972.     else
  973.         giprint ReadRsc$:(Message&)+" "+gen$(NumMsg%,3)+" "+ReadRsc$:(Of&)+" "+gen$(TotMsg&,3)+" "+ReadRsc$:(Stored&)
  974.     endif
  975.     pause 4*PauseValue&
  976.     FgApp%:(Email$)
  977.     Setthread:
  978.     pause 4*PauseValue&
  979.     if DelMsg% and not (Skip% or WrongDate% or LongField%)
  980.         Sendkey:("Del")    rem delete current message
  981.         pause 4*PauseValue&
  982.         SendKey:(YesSct$)    rem confirm deletion with "Yes" button
  983.         pause 4*PauseValue&
  984.     else
  985.         SendKey:("Down")    rem move down to the next message
  986.     endif
  987.     pause 4*PauseValue&
  988.     GetFocus:
  989.     Start::
  990.     if NumMsg%=TotMsg& and (TotMsg&>1 or TotSkip%>0 or DelMsg% or WrongDate% or LongField%)    rem last message or problem
  991.         dinit AppName$+AppVersion$,16
  992.         if TotSkip%>0
  993.             Message$=ReadRsc$:(Unable_to_store&)+" "+gen$(TotSkip%,3)+" "+ReadRsc$:(Messages&)
  994.             if DelMsg%
  995.                 Message$=Message$+" - "+ReadRsc$:(Not_deleted&)
  996.             endif
  997.             dtext "",Message$,$200
  998.         endif
  999.         dtext "",gen$(TotMsg&-TotSkip%,3)+" "+ReadRsc$:(Message_stored&)
  1000.         dtext "",Data$,$200
  1001.         if TotWrongDate%>0 and NoReply%<>-1
  1002.             Message$=ReadRsc$:(Wrong_date_field&)+" "+gen$(TotWrongDate%,3)+" "+ReadRsc$:(Messages&)
  1003.             if DelMsg%
  1004.                 Message$=Message$+" - "+ReadRsc$:(Not_deleted&)
  1005.             endif
  1006.             dtext "",Message$
  1007.         endif
  1008.         if TotLongField%>0
  1009.             dtext "",ReadRsc$:(Truncated_fields&)+" "+gen$(TotLongField%,3)+" "+ReadRsc$:(Messages&)
  1010.             Message$=ReadRsc$:(Subject_field_marked&)
  1011.             if DelMsg%
  1012.                 Message$=Message$+" - "+ReadRsc$:(Message_not_deleted&)
  1013.             endif
  1014.             dtext "",Message$
  1015.         endif
  1016.         dbuttons ReadRsc$:(Btn_Help&),%H,ReadRsc$:(Btn_Continue&),13
  1017.         Button%=dialog
  1018.         if Button%=%h
  1019.             Help:
  1020.             goto Start::
  1021.         endif
  1022.     endif
  1023.     FgApp%:(Email$)
  1024.     Skip%=0
  1025.     WrongDate%=0
  1026.     LongField%=0
  1027.     AttachTooLong%=0
  1028.     NumMsg%=NumMsg%+1
  1029. ENDP
  1030.  
  1031. PROC Help:
  1032.     IF Device:(Path$+HelpFile$)
  1033.         FgApp%:(Dev$+Path$+HelpFile$)
  1034.     ELSE
  1035.         giPRINT ReadRsc$:(Help_not_found&)
  1036.     ENDIF
  1037. ENDP
  1038.  
  1039. PROC CloseHelp:(Type%)
  1040.     IF Device:(Path$+HelpFile$)
  1041.         CloseApp%:(Dev$+Path$+HelpFile$)
  1042.     ENDIF
  1043.     IF Type%=1    rem return to Email after closing the Help file
  1044.         FgApp%:(Email$)
  1045.         FgApp%:(Email$) rem only one FgApp doesn't work...
  1046.     ENDIF
  1047. ENDP
  1048.  
  1049. PROC Device:(File$)
  1050.     rem search for File$ (path+file name) and return Drive letter
  1051.     Dev$="C:"
  1052.     IF EXIST (Dev$+File$)
  1053.         RETURN -1
  1054.     ELSE
  1055.         Dev$="D:"
  1056.         IF EXIST (Dev$+File$)
  1057.             RETURN -1
  1058.         ELSE
  1059.             Dev$="E:"
  1060.             IF EXIST (Dev$+File$)
  1061.                 RETURN -1
  1062.             ELSE
  1063.                 RETURN 0
  1064.             ENDIF
  1065.         ENDIF
  1066.     ENDIF
  1067. ENDP
  1068.  
  1069. PROC ClipCopy:(File$)
  1070.     Sendkey:("Ctrl+c")
  1071.     PAUSE PauseValue&
  1072.     IF EXIST (ClipBoard$)
  1073.         COPY ClipBoard$,TempFolder$+File$+ClipExt$
  1074.     ENDIF
  1075. ENDP
  1076.  
  1077. PROC ClipPaste:(File$)
  1078.     DELETE ClipBoard$
  1079.     COPY TempFolder$+File$+ClipExt$,ClipBoard$
  1080.     PAUSE PauseValue&
  1081.     Sendkey:("Ctrl+v")
  1082. ENDP
  1083.  
  1084. PROC CleanUp:
  1085.     LOCAL d$(255)
  1086.     TRAP RMDIR TempAttachFolder$
  1087.     ClipClear:
  1088.     IF EXIST(TempFolder$)
  1089.         d$=DIR$(TempFolder$+"*"+ClipExt$)
  1090.         WHILE d$<>""
  1091.             TRAP DELETE d$
  1092.             d$=DIR$("")
  1093.         ENDWH
  1094.     ENDIF
  1095. ENDP
  1096.  
  1097.  
  1098.