home *** CD-ROM | disk | FTP | other *** search
/ .net 1999 December / netCD65.iso / pc / Software / VirtualA / 32bit / vasetup.exe / %MYDIR% / Hmibase.ebs < prev    next >
Encoding:
Text File  |  1999-10-06  |  39.6 KB  |  1,262 lines

  1. 'T:HMIBASE.EBS for CompuServe
  2. ' VA 4.52 release
  3.  
  4. Declare Function ParseString(args As String, delim As String) As String
  5. Declare Function FileName$(fullpath As String)
  6. Declare Function FileUrl(fn As String) As String
  7. Declare Function MakeDateString(s As HMITIMESTAMP) As String
  8. Declare Sub AddToMsgFile(SourceFileName as String)
  9. Declare Function QueueFile(service As String, sfilename As String, queueflags As Long) As Boolean
  10. Declare Sub LoadAddonLibraries
  11. Declare Function MyDate$
  12. Declare Function StartMessageDownload(id As String, forum As String, sections As String) As Integer
  13. Declare Sub SearchMessages(searchtype As Integer, searchstring As String, bodies As Boolean, rootsonly As Boolean)
  14. Declare Sub ReportSuccess(msg As String)
  15. Declare Function ForumName(ByVal forum As String) As String
  16. Declare Function FullErrorMessage() As String
  17. Declare Sub FetchMail(id As String)
  18. Declare Sub SetupOptions(id As String)
  19. Declare Sub RecordBulletins(forum As String, getnews As Boolean, _
  20.                             getothers As Boolean, getuserlog As Boolean)
  21. Declare Function HMIGotoForum(ByVal forum As String) As Boolean
  22. Declare Sub RecordSectionInformation(forum As String)
  23. Declare Sub HMIGetWhatsNew(id As String, forum As String)
  24.  
  25. 'T:iFlags for CompuServe (constant)
  26. Const IM_SPECIAL = 128        ' My special msg format
  27. Const IM_DELETE = 2048        ' Delete scratchpad file afterwards?
  28.  
  29. Const fRECEIPT = 1            'CIS mail receipt
  30. Const fPRIVATE = 2            'CIS private forum message
  31. Const fNOFORMAT = 4            'CIS unformatted message
  32.  
  33. Const DAP_DC_HAVE_MAIL% = &H0001          ' mail waiting
  34. Const DAP_DC_ACCOUNT_ATTENTION% = &H0004  ' account needs attention
  35.  
  36. Const DAP_AL_VOLATILE = &H02
  37.  
  38. Const DAP_AP_SESSION_ONLY = &H01
  39. Const DAP_AP_VOLATILE = &H02
  40. Const DAP_AP_HAVE_HEADER% = &H04
  41. Const DAP_AP_HAVE_TRAILER% = &H08
  42. Const DAP_AP_HAVE_NEXT% = &H10
  43. Const DAP_AP_EX_HAVE_TITLE% = &H0100
  44.  
  45. Const HMI_DATA_SIZE% = 1024
  46.  
  47. Const FAP_DELETABLE% = &H1
  48. Const FAP_OWNER% = &H2
  49. Const FAP_MSG_IS_PRIVATE% = &H4
  50. Const FAP_READ_BY_RECIPIENT% = &H8
  51. Const FAP_MSG_HELD% = &H10
  52. Const FAP_MSG_FORWARDED% = &H20
  53. Const FAP_HAS_BEEN_DELETED% = &H80
  54.  
  55. Const FAP_FILE_DELETABLE% = &H1
  56. Const FAP_FILE_NON_PUBLIC% = &H2
  57. Const FAP_FILE_MARKED_FOR_DELETION% = &H4
  58. Const FAP_FILE_HAS_FEE% = &H8
  59.  
  60. Const FAP_NOT_A_MEMBER% = &H8
  61.  
  62. Const HMI_STATE_FIRST% = 0
  63. Const HMI_STATE_NEXT% = HMI_STATE_FIRST + 1
  64.  
  65. ' enum EMPCONTENTTYPES:
  66. Const EMP_TEXT% = 0                                  ' Ascii Text Object
  67. Const EMP_BINARY% = EMP_TEXT + 1                  ' 8-bit data
  68. Const EMP_GIF% = EMP_BINARY + 1                      ' Graphic Interchange Format
  69. Const EMP_BINARY_FILE% = EMP_GIF + 1              ' Contents_Name contains filename
  70. Const EMP_TEXT_FILE% = EMP_BINARY_FILE + 1          ' Text file
  71. Const EMP_TEXT_OBJECT% = EMP_TEXT_FILE + 1        ' TextObject message
  72. Const EMP_JPEG% = EMP_TEXT_OBJECT + 1
  73.  
  74. Const DAP_MP_HAVE_HEADER%  = 1
  75. Const DAP_MP_HAVE_TRAILER% = 2
  76. Const DAP_MP_HAVE_NEXT%    = 4
  77. Const DAP_MP_BLOB_MENU%    = 8
  78. Const DAP_MP_SESSION_ONLY% = 16
  79. Const DAP_MP_VOLATILE%     = 32
  80. Const DAP_MP_ATTRIBUTES%   = 64
  81. Const DAP_MP_EXTENSION%    = 128
  82.  
  83. Public DownloadDir As String    'where downloads go
  84. Public WorkingPath As String    'added to speed up Fetch stuff online
  85. Public WhereAmI As String        'name of last forum/page etc
  86. Public Sysop As Boolean            'are we a sysop?
  87. Public InAscii As Boolean
  88.  
  89. Public FAPconfig As FAPCONFIG
  90.  
  91. Public currentCAP As Integer
  92. Public SectionMsgIds(32) As Integer, SectionLibIds(32) As Integer
  93. Public szMsgSection() As FAPSECTIONENTRY, szLibSection() As FAPSECTIONENTRY
  94. Public nummessages As Integer
  95. Public CurrentForum As String
  96. Public MailName As String      'My name for mail purposes
  97. Public PersonalAddress As String      'My PA
  98.  
  99. Dim LastDownMessages As String
  100. Dim capturefilename As String
  101. Dim messagefilename As String
  102. Dim sectionvector As Long
  103. Dim sct As FAPSECTIONS
  104. Dim DAPconfig As DAPCONFIG
  105.  
  106. Const Months$ = "JanFebMarAprMayJunJulAugSepOctNovDec"
  107.  
  108. Dim captureStack As Integer
  109. Dim captureForum As String
  110.  
  111. Function rj(i As Integer) As String
  112.     rj = Right$(Str$(i + 100), 2)
  113. End Function
  114.  
  115. Function MakeDateString(s As HMITIMESTAMP) As String
  116.     On Error Resume Next
  117.     If s.cMonth > 0 Then
  118.         MakeDateString = rj(s.cDay) + "-" + Mid$(Months$,3 * (s.cMonth-1) + 1, 3) _
  119.                          + "-" + LTrim$(Str$(1970 + s.cYear)) + " " + _
  120.                          rj(s.cHour) + ":" + rj(s.cMinutes) + ":" + _
  121.                          rj(s.cSeconds)
  122.     Else
  123.         MakeDateString = ""
  124.     End If
  125. End Function
  126.  
  127. Function TimeZone(s As EMPTIMEZONE) As String
  128.     TimeZone = ""
  129.  
  130.     ' CIS Doesn't seem to fill in the variable
  131.     'Dim pm As String
  132.     '
  133.     'On Error Resume Next
  134.     'If s.cDirection=0 Then pm = "+" Else pm = "-"
  135.     'TimeZone = " " & pm & rj(s.cHours) & rj(s.cMinutes)
  136. End Function
  137.  
  138. Function GetFileType(i As Integer) As String
  139.     Select Case i
  140.         Case 0
  141.             GetFileType = "Unknown"
  142.         Case 1
  143.             GetFileType = "Text"
  144.         Case 2
  145.             GetFileType = "Binary"
  146.         Case 3
  147.             GetFileType = "Image"
  148.         Case 4
  149.             GetFileType = "RLE"
  150.         Case 5
  151.             GetFileType = "NAPLPS"
  152.         Case 6
  153.             GetFileType = "GIF"
  154.         Case 7
  155.             GetFileType = "JPEG"
  156.         Case 8
  157.             GetFileType = "ETO"
  158.         Case 9
  159.             GetFileType = "HTML"
  160.         Case 10
  161.             GetFileType = "PNG"
  162.     End Select
  163. End Function
  164.  
  165. Function CompareTimes(d1 As HMITIMESTAMP, d2 As HMITIMESTAMP) As Integer
  166.     If d1.cYear < d2.cYear Then
  167.         CompareTimes = -1
  168.         Exit Function
  169.     End If
  170.     If d1.cYear > d2.cYear Then
  171.         CompareTimes = 1
  172.         Exit Function
  173.     End If
  174.     If d1.cMonth < d2.cMonth Then
  175.         CompareTimes = -1
  176.         Exit Function
  177.     End If
  178.     If d1.cMonth > d2.cMonth Then
  179.         CompareTimes = 1
  180.         Exit Function
  181.     End If
  182.     If d1.cDay < d2.cDay Then
  183.         CompareTimes = -1
  184.         Exit Function
  185.     End If
  186.     If d1.cDay > d2.cDay Then
  187.         CompareTimes = 1
  188.         Exit Function
  189.     End If
  190.     If d1.cHour < d2.cHour Then
  191.         CompareTimes = -1
  192.         Exit Function
  193.     End If
  194.     If d1.cHour > d2.cHour Then
  195.         CompareTimes = 1
  196.         Exit Function
  197.     End If
  198.     If d1.cMinutes < d2.cMinutes Then
  199.         CompareTimes = -1
  200.         Exit Function
  201.     End If
  202.     If d1.cMinutes > d2.cMinutes Then
  203.         CompareTimes = 1
  204.         Exit Function
  205.     End If
  206.     If d1.cSeconds < d2.cSeconds Then
  207.         CompareTimes = -1
  208.         Exit Function
  209.     End If
  210.     If d1.cSeconds > d2.cSeconds Then
  211.         CompareTimes = 1
  212.         Exit Function
  213.     End If
  214.     CompareTimes = 0
  215. End Function
  216.  
  217. Function CompareDates(d1 As HMIDATE, d2 As HMIDATE) As Integer
  218.     If d1.cYear < d2.cYear Then
  219.         CompareDates = -1
  220.         Exit Function
  221.     End If
  222.     If d1.cYear > d2.cYear Then
  223.         CompareDates = 1
  224.         Exit Function
  225.     End If
  226.     If d1.cMonth < d2.cMonth Then
  227.         CompareDates = -1
  228.         Exit Function
  229.     End If
  230.     If d1.cMonth > d2.cMonth Then
  231.         CompareDates = 1
  232.         Exit Function
  233.     End If
  234.     If d1.cDay < d2.cDay Then
  235.         CompareDates = -1
  236.         Exit Function
  237.     End If
  238.     If d1.cDay > d2.cDay Then
  239.         CompareDates = 1
  240.         Exit Function
  241.     End If
  242.     CompareDates = 0
  243. End Function
  244.  
  245. Sub CaptureLine(textline As String)
  246.     CaptureText textline + Basic.Eoln$
  247. End Sub
  248.  
  249. Sub CaptureLines(textline As String)
  250.     Dim p As Integer, q As Integer, e As Integer
  251.  
  252.     p = 1
  253.     Do
  254.         q = Instr(p, textline, Chr$(10))
  255.         If q = 0 Then
  256.             e = Len(textline) + 1
  257.             CaptureText Mid$(textline, p, e - p)
  258.         Else
  259.             e = q
  260.             If q > p Then
  261.                 If Mid$(textline, q - 1, 1) = Chr$(13) Then
  262.                     e = e - 1
  263.                 End If
  264.             End If
  265.             CaptureLine Mid$(textline, p, e - p)
  266.         End If
  267.         p = q + 1
  268.     Loop While q > 0
  269. End Sub
  270.  
  271. Sub StartCapturing(pseudoforum As String, title As String, formatted As Boolean)
  272.     captureStack = captureStack + 1
  273.     If captureStack <= 1 Then
  274.         captureStack = 1
  275.         capturefilename = UniqueFilename$()
  276.         Capture CAPTURE_ON, capturefilename
  277.         captureForum = pseudoforum
  278.     Else
  279.         CaptureText Basic.Eoln$ + "!end" + Basic.Eoln$
  280.     End If
  281.     If formatted Then
  282.         CaptureText Basic.Eoln$+"#pragma ciscontrol=yes;deleteexisting=no"+Basic.Eoln$
  283.     Else
  284.         CaptureText Basic.Eoln$+"#pragma ciscontrol=no;deleteexisting=no"+Basic.Eoln$
  285.     End If
  286.     CaptureText Basic.Eoln$ + "!start " + captureForum + " " + title + Basic.Eoln$
  287. End Sub
  288.  
  289. Sub FinishCapturing
  290.     Dim i As Integer
  291.  
  292.     captureStack = captureStack - 1
  293.     CaptureText Basic.Eoln$+"!end"+Basic.Eoln$
  294.     If captureStack <= 0 Then
  295.         captureStack = 0
  296.         Capture CAPTURE_OFF
  297.         ' Add to import queue
  298.         i = QueueFile(Session.Service, capturefilename, IM_SPECIAL Or IM_DELETE)
  299.     End If
  300. End Sub
  301.  
  302. Function CheckCache(pagetype As String, npage As String, pversion As Long) _
  303.         As String
  304.     Dim newpage As String
  305.     Dim tmp As String
  306.  
  307.     tmp = ReadIni$(pagetype, npage, Session.ServicePath+"cache.ini")
  308.     newpage = ParseString(tmp, " Version# ")
  309.     If newpage > "" And pversion = Val(tmp) Then
  310.         CheckCache = newpage
  311.     Else
  312.         CheckCache = ""
  313.     End If
  314. End Function
  315.  
  316. Sub UpdateCache(pagetype As String, npage As String, pversion As Long, _
  317.         newpage As String)
  318.     WriteIni pagetype, npage, newpage & " Version# " & pversion, _
  319.             Session.ServicePath+"cache.ini"
  320. End Sub
  321.  
  322. Sub RecordTerminalOutput()
  323.     On Error Goto RecordTerminal_error
  324.  
  325.     HMIResume
  326.  
  327.     Exit Sub
  328.  
  329. RecordTerminal_error:
  330.     CaptureLine "Error:" & FullErrorMessage
  331. End Sub
  332.  
  333. Sub CaptureTerminalOutput(page As String)
  334.     StartCapturing "Actions/Information", "Terminal output when going to " + page, False
  335.     page = ""
  336.     RecordTerminalOutput
  337.     FinishCapturing
  338. End Sub
  339.  
  340. Sub CaptureMenuOptions(page As String)
  341.     Dim menupage As DAPMENUPAGE
  342.     Dim selections() As DAPSELECTION
  343.     Dim p As Integer
  344.  
  345.     On Error Resume Next
  346.     StartCapturing "Actions/Information CompuServe", Basic.Eoln$+"Menu found when going to " + page, False
  347.     page = ""
  348.     HMIGetMenu menupage, selections
  349.     page = menupage.lpName
  350.  
  351.     If menupage.cOptions And DAP_MP_BLOB_MENU Then
  352.         CaptureLines selections(0).lpItem
  353.     Else
  354.         For p = 0 To Ubound(selections)
  355.             CaptureLine selections(p).lpItem + " " + Str(selections(p).nSvcClass)
  356.         Next
  357.     End If
  358.     FinishCapturing
  359. End Sub
  360.  
  361. Function DoHMIGotoPage(ByVal forum As String, ByVal menuoption As Integer, ByVal expectedCAP As Integer, Quiet As Boolean)
  362.     Dim reqforum As String
  363.  
  364.     reqforum = forum
  365.     SetHighMessageNumber
  366.     ResetForum
  367.     InAscii = False
  368.  
  369.     While forum > ""
  370.         currentCAP = HMIGoToPage(forum, menuoption)
  371.         If currentCAP = expectedCAP Then
  372.             DoHMIGotoPage = True
  373.             Exit Function
  374.         End If
  375.         If Quiet then
  376.             DoHMIGotoPage = False
  377.             Exit Function
  378.         End If
  379.         Select Case currentCAP
  380.             Case DAP_ERROR
  381.                 LogResult "Go:"+forum+":HMI error"
  382.                 forum = ""
  383.             Case DAP_TERMINAL
  384.                 CaptureTerminalOutput forum
  385.                 forum = ""
  386.             Case DAP_MENU
  387.                 CaptureMenuOptions forum
  388.                 forum = ""
  389.             Case DAP_ARTICLE
  390.                 CaptureArticleText "Actions/Articles"
  391.                 forum = ""
  392.             Case DAP_ALERT
  393.                 CaptureAlert reqforum, forum
  394.             Case DAP_FILE
  395.                 LogResult "Go:"+forum+":this page is a file for download"
  396.                 forum = ""
  397.             Case CAP_EMAIL
  398.                 LogResult "Go:"+forum+":this page is an Electronic Mail page"
  399.                 forum = ""
  400.             Case CAP_FORUM
  401.                 LogResult "Go:"+forum+":this page is a Forum"
  402.                 forum = ""
  403.             Case CAP_ENS
  404.                 LogResult "Go:"+forum+":this page is an Electronic News page"
  405.                 forum = ""
  406.             Case Else
  407.                 LogResult "Go:"+forum+":this page is an unexpected type (" + Trim$(Str$(currentCAP)) + ")"
  408.                 forum = ""
  409.         End Select
  410.     Wend
  411.     DoHMIGotoPage = False
  412. End Function
  413.  
  414. Function DoHMIFollowMenus(ByVal forum As String, optionlist As String, ByVal expectedDAP As Integer)
  415.     Dim p As Integer
  416.     Dim i As Integer
  417.     Dim newDAP As Integer
  418.     Dim menupage As DAPMENUPAGE
  419.     Dim selections() As DAPSELECTION
  420.  
  421.     DoHMIFollowMenus = False
  422.     newDAP = DAP_MENU
  423.     While optionlist > ""
  424.         i = Val(ParseString(optionlist, ";"))
  425.         If i <= 0 Then i = -1
  426.         If optionlist = "" Then newDAP = expectedDAP
  427.         If Not DoHMIGotoPage(forum, i, newDAP, False) Then Exit Function
  428.         If currentCAP = DAP_MENU Then
  429.             HMIGetMenu menupage, selections
  430.             forum = menupage.lpName
  431.         End If
  432.     Wend
  433.     DoHMIFollowMenus = True
  434. End Function
  435.  
  436.  
  437. 'T:Main - CIS (subroutine) (CompuServe) (CompuServe)
  438. 'Entry point. Does a complete blink
  439. Sub HMIMain
  440.     Dim redials As Integer, ok As Integer, i As Boolean
  441.  
  442.     Comms.AutoDownload = PROT_QUICKB
  443.  
  444.     MailName = ReadIni$("Service "+Session.Service, "Mail Name", Session.IniFilename)
  445.     PersonalAddress = ReadIni$("Service "+Session.Service, "Personal Address", Session.IniFilename)
  446.     If MailName = "" Then MailName = "Not known"
  447.  
  448.     ' Dial
  449.     If Comms.Dial("")=0 Then
  450.         LogResult "Error whilst attempting to dial modem"
  451.         Exit Sub
  452.     End If
  453.  
  454.     ' Display connection info
  455.     HMIGetDAPConfig DAPconfig
  456.     Terminal.Print "Connected to node: "+DAPconfig.lpNodeID+Basic.Eoln$
  457.     LogResult "Connected to node: "+DAPconfig.lpNodeID
  458.  
  459.     ' Check account attention flag
  460.     If (DAPconfig.wAlerts And DAP_DC_ACCOUNT_ATTENTION%)<>0 Then
  461.         Terminal.Print Basic.Eoln$+"Your account needs attention.  Please contact CompuServe"+Basic.Eoln$
  462.         LogResult "Your account needs attention.  Please contact CompuServe"
  463.         Comms.Bitmask = True ' CIS messes up if we don't do this
  464.         On Error Resume Next
  465.         i = DoHMIGoToPage("admhmi", -1, CAP_DISPLAY, False)
  466.         On Error Goto 0
  467.     End If
  468.  
  469.     ' Check to see if we need to set options
  470.     If ReadIni$("Service "+Session.Service, "Set Options", Session.IniFilename)<>"YES" Then
  471.         SetupOptions ""
  472.         Script
  473.         SetHighMessageNumber
  474.         Comms.HangUp
  475.         Exit Sub
  476.     End If
  477.  
  478.     If Instr(Command$, "manual") Then
  479.         On Error Resume Next
  480.         ManualTerminal
  481.     Else
  482.         Terminal.Status "Logged in successfully"
  483.  
  484.         ' Do the REPLY.EBS script
  485.         Script
  486.  
  487.         ' Added this to process fetch file at end
  488.         QueFetches
  489.  
  490.         ' Set hmn on exit
  491.         SetHighMessageNumber
  492.         If Session.StayOnline Then
  493.             Comms.Send "go cis:top\r"
  494.             On Error Resume Next
  495.             ManualTerminal
  496.         End If
  497.     End If
  498.  
  499.     Comms.Hangup
  500. End Sub
  501.  
  502. Function ReverseInStr(search As String, find As String) As Integer
  503.     Dim i As Integer, lasti As Integer
  504.  
  505.     i = 0
  506.     Do
  507.         lasti = i
  508.         i = InStr(lasti+1, search, find)
  509.         If i>0 Then tmp = Mid$(search, i+1)
  510.     Loop Until i=0
  511.  
  512.     ReverseInStr = lasti
  513. End Function
  514.  
  515. ' Is it a special gateway address that allows space?
  516. Function GatewayAddress(pto As String) As Boolean
  517.     Dim i As Integer, j As Integer
  518.  
  519.     i = InStr(pto, ":")
  520.     j = InStr(pto, " ")
  521.     If i=0 Or j=0 Then
  522.         GatewayAddress = False
  523.     ElseIf i<j Then
  524.         GatewayAddress = True
  525.     Else
  526.         GatewayAddress = False
  527.     End If
  528. End Function
  529.  
  530. ' Parse the To: line and extract the realname and the email address
  531. Sub AnalyseName(pto As String, realname As String, email As String)
  532.     Dim buf As String, p As Integer
  533.  
  534.     ' NOTE: Must be able to split the following types of addresses.
  535.     ' "Peter Clapham 100142,2244"
  536.     ' "Peter Clapham [100142,2244]"
  537.     ' "Peter Clapham [petec]"
  538.     ' "Peter Clapham [ASHMOUNT] 100142,2244"
  539.     ' "Peter Clapham [ASHMOUNT] [petec]"
  540.     ' "Peter Clapham [ASHMOUNT] [100142,2244]"
  541.     ' "[100142,2244]"
  542.     ' "100142,2244"
  543.     ' "petec"
  544.     ' "Matthias Daum [CCMAIL:Wibble Wibble]"
  545.     ' "CCMAIL:Wibble Wibble"
  546.  
  547.     ' Init vars
  548.     buf = Trim$(pto)
  549.     realname = ""
  550.     email = ""
  551.  
  552.     ' If last char is a ']' then the start of the email address is the
  553.     ' preceeding '['
  554.     If Right$(buf,1)="]" Then
  555.         p = ReverseInStr(buf, "[")
  556.     Else
  557.         If Right$(buf,1)=">" Then
  558.             p = ReverseInStr(buf, "<")
  559.         Else
  560.             If GatewayAddress(buf) Then
  561.                 p = 1
  562.             Else
  563.                 p = ReverseInStr(buf, " ")
  564.             End If
  565.         End If
  566.     End If
  567.     If p>0 Then
  568.         email = Mid$(buf, p+1)
  569.         If p>0 Then
  570.             realname = Left$(buf, p-1)
  571.         Else
  572.             realname = ""
  573.         End If
  574.     Else
  575.         email = buf
  576.     End If
  577.     ReplaceAllInString email, "[", ""
  578.     ReplaceAllInString email, "]", ""
  579.     ReplaceAllInString email, ">", ""
  580.     ReplaceAllInString email, "<", ""
  581.  
  582.     ' Trim off whitespace and quotes on the realname
  583.     realname = Trim$(realname)
  584.     If Left$(realname,1)=Chr$(34) Then realname = Mid$(realname, 2, Len(realname)-2)
  585.     email = Trim$(email)
  586.  
  587.     ' Remove any 'internet:' or 'mime:' prefix
  588.     If UCase$(Left$(email, 9))="INTERNET:" Then email = Mid$(email, 10)
  589.     If UCase$(Left$(email, 5))="MIME:" Then email = Mid$(email, 6)
  590.  
  591.     ' Trim off unneeded '@compuserve.com' and convert . -> ,
  592.     p = InStr(email, "@compuserve.com", 1)
  593.     If p>0 Then
  594.         email = Left$(email, p-1)
  595.         ReplaceAllInString email, ".", ","
  596.     End If
  597.  
  598.     ' @web.compuserve.com -> CSINET:
  599.     If InStr(email, "@web.compuserve.com", 1)>0 And _
  600.        UCase$(Left$(email, 7))<>"CSINET:" Then
  601.         email = "CSINET:"+email
  602.     End If
  603.  
  604.     ' Check to see if it's a gateway, if it isn't and contains a '@' then
  605.     ' then it must be an internet address
  606.     If InStr(email, ":")=0 And InStr(email, " ")=0 And _
  607.        InStr(email, "@")<>0 Then
  608.         email = "internet:"+email
  609.     End If
  610. End Sub
  611.  
  612. 'Read an entire message from a file into a string
  613. 'If noformat = 0, add @b where appropriate
  614. 'If noformat = 1, add @l to say "send as shown" instead
  615. 'If noformat = 2, don't change the data at all
  616. Function ReadMessageFile(filename As String, noformat As Integer) As String
  617.     Dim inpline As String, body As String, badded As Boolean
  618.     Dim quoted As Boolean
  619.  
  620.     ' Collect message text ready to send to CIS
  621.     On Error Goto ReadMessageFile_error
  622.     Open filename For Input Access Read Shared As #1
  623.     If noformat = 1 Then body = "@l" + Chr$(10)
  624.     While Not Eof(1)
  625.         Line Input #1, inpline
  626.         If noformat < 2 Then ReplaceAllInString inpline, "@", "@@"
  627.         If noformat = 0 Then
  628.             inpline = RTrim$(inpline)
  629.             If Left$(inpline,1)=">" Then
  630.                 If body<>"" Then body = body + "@b" + Chr$(10)
  631.                 quoted = True
  632.             ElseIf quoted Then
  633.                 body = body + "@b" + Chr$(10)
  634.                 quoted = False
  635.             ElseIf inpline="" Or inpline<=" ~" Then
  636.                 If Not badded Then
  637.                     body = body + "@b" + Chr$(10)
  638.                     badded = True
  639.                 End If
  640.             Else
  641.                 If Right$(body, 1)>" " Then
  642.                     body = body + " "
  643.                 End If
  644.             End If
  645.             If inpline > "" Then badded = False
  646.         End If
  647.         If body="" Or body="@l"+Chr$(10) Then
  648.             body = body + inpline
  649.         Else
  650.             If noformat = 0 And inpline<>"" Then
  651.                 body = body + inpline
  652.             Else
  653.                 body = body + Chr$(10) + inpline
  654.             End If
  655.         End If
  656.     Wend
  657. ReadMessageFile_error:
  658.     On Error Goto 0
  659.     Close #1
  660.     ReadMessageFile = body + Chr$(10)
  661. End Function
  662.  
  663. 'T:GetForumList (subroutine) (CompuServe)
  664. Sub GetForumList(id As String, filename As String)
  665.     Dim s As String, page As String, i As Integer, count As Long
  666.     Dim filepage As DAPFILEPAGE
  667.  
  668.     If Not DoHMIFollowMenus("cis:index", "2", DAP_FILE) Then
  669.         LogResult "Unable to refresh forum list."
  670.         Exit Sub
  671.     End If
  672.  
  673.     Terminal.Print "Collecting forum list.  Please wait..." + Basic.Eoln$
  674.     page = "CIS:IND-41"
  675.  
  676.     HMIGetFile filepage
  677.  
  678.     ' Open forum list file to write to
  679.     On Error Goto GetForumList_error
  680.     DeleteFile filename
  681.     Open filename For Binary Access Write Shared As #1
  682.  
  683.     count = 0
  684.     Terminal.TransferStatus False, "Forum list", count, filepage.dwSize
  685.     s = DAPReceiveFile(HMI_STATE_FIRST%, page, i)
  686.     Do While i>0 And s<>""
  687.         Put #1, , s
  688.         count = count + i
  689.         Terminal.TransferStatus False, "Forum list", count, filepage.dwSize
  690.         s = DAPReceiveFile(HMI_STATE_NEXT%, page, i)
  691.     Loop
  692.     Close #1
  693.     Terminal.TransferStatus
  694.  
  695.     ReportSuccess id & " : Collected new forum list"
  696.     Exit Sub
  697.  
  698. GetForumList_error:
  699.     Close #1
  700.     Terminal.TransferStatus
  701.     LogResult "Error : " + FullErrorMessage()
  702.     LogResult id & " : Failed to collect forum list"
  703.     Exit Sub
  704. End Sub
  705.  
  706. 'T:Announcements (subroutine) (CompuServe)
  707. Sub Announcements(id As String, forum As String)
  708.     If Not HMIGotoForum(forum) Then
  709.         LogResult id + " : Failed : Unable to collect announcements from "+forum
  710.         Exit Sub
  711.     End If
  712.  
  713.     Terminal.Print "Collecting forum Announcements"+Basic.Eoln$
  714.     RecordBulletins forum, False, True, False
  715.     RecordSectionInformation forum
  716.  
  717.     If id<>"" Then ReportSuccess id & " : Announcements collected from " & forum & " "
  718. End Sub
  719.  
  720. 'T:Newsflash (subroutine) (CompuServe)
  721. Sub Newsflash(id As String, forum As String)
  722.     If Not HMIGotoForum(forum) Then
  723.         LogResult id + " : Failed : Unable to collect newsflash from "+forum
  724.         Exit Sub
  725.     End If
  726.  
  727.     Terminal.Print "Collecting forum Newsflash"+Basic.Eoln$
  728.     RecordBulletins forum, True, False, False
  729.     If id<>"" Then ReportSuccess id & " : Newsflash collected from " & forum & " "
  730. End Sub
  731.  
  732. Function ParseSectionList(ByVal sect As String, ByVal validsects As Long, _
  733.                           ByRef count As Integer) As Long
  734.     Dim s As String, l As Integer, h As Integer, sl As Long, xsl As Long
  735.  
  736.     count = 0
  737.     sect = LTrim(sect)
  738.     ReplaceAllInString sect, ",", " "    ' handle comma as separator
  739.     If sect = "*" Or StrComp(sect, "ALL", 1)=0 Then
  740.         ParseSectionList = validsects
  741.         For l = 0 To 24
  742.             sl = 2^l
  743.             If (validsects And sl)=sl Then count = count + 1
  744.         Next
  745.         Exit Function
  746.     End If
  747.     s = ParseString(sect, " ")      'Numbers are separated by spaces
  748.     While s > ""
  749.         l = Instr(s, "-")           'Allowed to use range - e.g. 3-6
  750.         If l > 0 Then               'We have a range
  751.             h = Val(Mid$(s, l + 1)) 'High value of range
  752.             For l = Val(s) To h     'From low to high value
  753.                 sl = sl Or (2 ^ l)  'Set appropriate bits
  754.             Next
  755.         Else
  756.             If UCase$(s)<>"Y" Then
  757.                 l = Val(s)              'Value
  758.                 sl = sl Or (2 ^ l)      'Set appropriate bit
  759.             End If
  760.         End If
  761.         s = ParseString(sect, " ")  'Numbers are separated by spaces
  762.     Wend
  763.     xsl = sl And validsects
  764.     ParseSectionList = xsl
  765.     For l = 0 To 24
  766.         If (xsl And 2^l)=2^l Then count = count + 1
  767.     Next
  768. End Function
  769.  
  770. Function ParseSectionList1(ByVal sect As String, ByVal validsects As Long, _
  771.                           ByRef count As Integer, ByRef mask as Long) As Long
  772.     Dim s As String, l As Integer, h As Integer, sl As Long, xsl As Long
  773.     Dim removeflag As Integer
  774.  
  775.     count = 0
  776.     sect = LTrim(sect)
  777.     ReplaceAllInString sect, ",", " "    ' handle comma as separator
  778.     If sect = "*" Or StrComp(sect, "ALL", 1)=0 Then
  779.         ParseSectionList1 = validsects
  780.         For l = 0 To 24
  781.             sl = 2^l
  782.             If (validsects And sl)=sl Then count = count + 1
  783.         Next
  784.     mask=0
  785.         Exit Function
  786.     End If
  787.     If sect = "-*" Or StrComp(sect, "-ALL", 1)=0 Then
  788.         ParseSectionList1 = 0
  789.     mask = validsects
  790.         Exit Function
  791.     End If
  792.     s = ParseString(sect, " ")      'Numbers are separated by spaces
  793.     While s > ""
  794.     removeflag = 0
  795.     if left(s,1) = "-" then
  796.         removeflag = 1
  797.         s = Right$(s,len(s)-1)
  798.     End If
  799.         l = Instr(s, "-")           'Allowed to use range - e.g. 3-6
  800.         If l > 0 Then               'We have a range
  801.             h = Val(Mid$(s, l + 1)) 'High value of range
  802.             For l = Val(s) To h     'From low to high value
  803.         if removeflag then
  804.             mask = mask or (2 ^ l)
  805.         else
  806.                      sl = sl Or (2 ^ l)  'Set appropriate bits
  807.         End If
  808.             Next
  809.         ElseIf UCase$(s)<>"Y" Then
  810.                 l = Val(s)              'Value
  811.         If removeflag then
  812.             mask = mask Or (2 ^ l)
  813.         else
  814.                     sl = sl Or (2 ^ l)      'Set appropriate bit
  815.         End If
  816.         End If
  817.         s = ParseString(sect, " ")  'Numbers are separated by spaces
  818.     Wend
  819.     xsl = sl And validsects
  820.     ParseSectionList1 = xsl
  821.     For l = 0 To 24
  822.         If (xsl And 2^l)=2^l Then count = count + 1
  823.     Next
  824. End Function
  825.  
  826.  
  827.  
  828. Sub SaveMessage(hdr As FAPMSGHEADER, body As String)
  829.     Dim section As String, n As String, l As Integer, tail As String
  830.     Dim f As String, FromLine As String, ToLine As String
  831.  
  832.     ' Valid message?
  833.     If hdr.lpOriginatorId="" And hdr.lpRecipientName="" Then Exit Sub
  834.  
  835.     ' Check to see if it's a fake reply
  836.     If Mid$(hdr.lpSubject, 1, 1)="#" And hdr.dwParentMsg=0 Then
  837.         tail = ""
  838.         For l = 1 To Len(hdr.lpSubject)
  839.             If InStr("1234567890", Mid$(hdr.lpSubject, l, 1)) Then
  840.                 tail = tail + Mid$(hdr.lpSubject, l, 1)
  841.             End If
  842.             If Mid$(hdr.lpSubject, l, 1)="-"  And tail<>"" Then
  843.                 hdr.dwParentMsg = Val(tail)
  844.                 hdr.lpSubject = Mid$(hdr.lpSubject, l+1, Len(hdr.lpSubject)-l)
  845.                 l = Len(hdr.lpSubject)
  846.             End If
  847.         Next
  848.         tail = ""
  849.     End If
  850.  
  851.     ' Flags
  852.     f = ""
  853.     If (hdr.cFlags And FAP_READ_BY_RECIPIENT%)<>0 Then
  854.         f = f + "Read-By-Recipient: Yes" & Chr$(10)
  855.     Else
  856.         f = f + "Read-By-Recipient: No" & Chr$(10)
  857.     End If
  858.     If hdr.dwThreadId <> 0 Then
  859.         f = f + "Thread-Id: " & LTrim$(Str$(hdr.dwThreadId)) & Chr$(10)
  860.     End If
  861.     If (hdr.cFlags And FAP_MSG_IS_PRIVATE%)<>0 Then
  862.         f = f + "-- PRIVATE MESSAGE --" & Chr$(10)
  863.     End If
  864.     If (hdr.cFlags And FAP_MSG_HELD%)<>0 Then
  865.         f = f + "-- HOLD MESSAGE --" & Chr$(10)
  866.     End If
  867.     If hdr.lpOriginatorId<>"" Then
  868.         FromLine = hdr.lpOriginatorName & " [" & hdr.lpOriginatorId & "]"
  869.     Else
  870.         FromLine = hdr.lpOriginatorName
  871.     End If
  872.     If hdr.lpRecipientId<>"" Then
  873.         ToLine = hdr.lpRecipientName & " [" & hdr.lpRecipientId & "]"
  874.     Else
  875.         ToLine = hdr.lpRecipientName
  876.     End If
  877.  
  878.     l = Len(hdr.lpSubject)+Len(f)+Len(FromLine)+Len(ToLine)+Len(body)+24
  879.     If hdr.wNumReplies > 0 Then
  880.         If hdr.wNumReplies > 1 Then
  881.             tail = "There are " & hdr.wNumReplies & " Replies" & Chr$(10)
  882.         Else
  883.             tail = "There is 1 Reply" & Chr$(10)
  884.         End If
  885.     End If
  886.     l = l - ItemCount(body, Chr$(13)) ' Don't count both CR+LF
  887.     If tail > "" Then
  888.         l = l + Len(tail)
  889.     End If
  890.     CaptureLine ""
  891.     If SectionMsgIds(hdr.cSectionId) >= 0 Then
  892.         section = szMsgSection(SectionMsgIds(hdr.cSectionId)).lpTitle
  893.     Else
  894.         section = "Unknown"
  895.     End If
  896.     If body="*** Header Only ***" & Chr$(10) Then
  897.         n = "*header*"
  898.         body = body + Chr$(10) + "[Double-click here to mark the message for collection]"
  899.         l = l + 55
  900.     Else
  901.         n = hdr.lpOriginatorName
  902.         ReplaceAllInString n, " ", "_"
  903.     End If
  904.     ReplaceAllInString hdr.lpOriginatorName, ";", " "
  905.     ReplaceAllInString hdr.lpRecipientName, ";", " "
  906.     nummessages = nummessages + 1
  907.     Terminal.CaptureStatus nummessages
  908.     CaptureLine "=========="
  909.     CaptureText CurrentForum & "/S" & hdr.cSectionId & "_" & section & " #"
  910.     CaptureText hdr.dwMsgNo & ", from " & n & ", " & l & " chars, "
  911.     CaptureLine MakeDateString(hdr.tsDate)
  912.     If hdr.dwParentMsg Then CaptureLine "Comment to " & hdr.dwParentMsg & "."
  913.     CaptureLine "----------"
  914.     CaptureLine "Subject: " & hdr.lpSubject
  915.     CaptureLine "From: " & FromLine
  916.     CaptureLine "To: " & ToLine
  917.     If f<>"" Then CaptureText f
  918.     CaptureLine ""
  919.     CaptureText body
  920.     CaptureLine ""
  921.     If tail > "" Then 
  922.         CaptureLine tail
  923.     End If
  924.     CaptureLine ""
  925. End Sub
  926.  
  927. Sub WriteLibraryMessage(forum As String, filedesc As FAPFILEDESCRIPTION, downloaded As String)
  928.     Dim l As Long, sectname As String, from As String, hdr As String
  929.     Dim d0 As String, d1 As String, d2 As String, flags As String
  930.     Dim fn As String, sectno As Integer
  931.  
  932.     from = filedesc.lpUserName
  933.     fn = filedesc.lpFilename
  934.     ReplaceAllInString from, " ", "_"
  935.     ReplaceAllInString fn, " ", "_"
  936.     d0 = MakeDateString(filedesc.tsSubmitted)
  937.     d1 = MakeDateString(filedesc.tsLastAccess)
  938.     d2 = MakeDateString(filedesc.tsReleaseDate)
  939.     If d0="" Then d0 = MyDate$
  940.  
  941.     ' RFC 822 type header
  942.     hdr = "Subject: " & filedesc.lpTitle & Chr$(10) & _
  943.           "From: " & filedesc.lpUserName & " [" & filedesc.lpUserID & "]" & Chr$(10) & _
  944.           "Date-Submitted: " & d0 & Chr$(10)
  945.     If d1<>"" Then hdr = hdr & "Date-Last-Access: " & d1 & Chr$(10)
  946.     If d2<>"" Then hdr = hdr & "Date-Released: " & d2 & Chr$(10)
  947.     hdr = hdr & "Filename: " & filedesc.lpFilename & Chr$(10) & _
  948.           "File-Type: " & GetFileType(filedesc.nFileType) & Chr$(10) & _
  949.           "File-Size: " & filedesc.dwFileSize & Chr$(10) & _
  950.           "Access-Count: " & filedesc.dwAccessCount & Chr$(10) & _
  951.           "Catalog-No: " & filedesc.dwCatalogNo & Chr$(10) & _
  952.           "Keywords: " & filedesc.lpKeys & Chr$(10)
  953.     If filedesc.lpSysOpComment <> "" Then
  954.         hdr = hdr & "SysOp-Comment: " & filedesc.lpSysOpComment & Chr$(10)
  955.     End If
  956.  
  957.     sectno = filedesc.cLibSectionNo
  958.     If SectionLibIds(sectno) >= 0 Then
  959.         sectname = szLibSection(SectionLibIds(sectno)).lpTitle
  960.     Else
  961.         sectname = "Unknown"
  962.     End If
  963.  
  964.     ' For new uploads
  965.     If filedesc.cOptions And FAP_FILE_DELETABLE Then flags = flags + ",Deletable"
  966.     If filedesc.cOptions And FAP_FILE_NON_PUBLIC Then flags = flags + ",Not public"
  967.     If filedesc.cOptions And FAP_FILE_MARKED_FOR_DELETION Then flags = flags + ",Marked for deletion"
  968.     If filedesc.cOptions And FAP_FILE_HAS_FEE Then flags = flags + ",Chargeable"
  969.     If flags > "" Then hdr = hdr & "Flags: " & Mid$(flags, 2) & Chr$(10)
  970.     If filedesc.cOptions And FAP_FILE_MARKED_FOR_DELETION Then
  971.         hdr = hdr & Chr$(10) & "*New Erase*" & Chr$(10)
  972.         sectname = sectname + "_[Sysop]"
  973.     ElseIf filedesc.cOptions And FAP_FILE_NON_PUBLIC Then
  974.         hdr = hdr & Chr$(10) & "*New Upload*" & Chr$(10)
  975.         sectname = sectname + "_[Sysop]"
  976.     End If
  977.  
  978.     l = 2+Len(hdr+filedesc.lpAbstract)-ItemCount(filedesc.lpAbstract, Chr$(13))
  979.  
  980.     ' Downloaded to...
  981.     If downloaded<>"" Then
  982.         l = l+Len("[]Downloaded to "+FileUrl(downloaded))+1
  983.     End If
  984.  
  985.     ' CIX header
  986.     CaptureLine "=========="
  987.     CaptureText forum & "/L" & sectno & "_" & sectname
  988.     CaptureText " #" & LTrim(Str(filedesc.dwCatalogNo))
  989.     CaptureLine ", from " & fn & ", " & l & " chars, " & d0
  990.     CaptureLine "----------"
  991.     CaptureLines hdr
  992.     CaptureLines Chr$(10)+filedesc.lpAbstract+Chr$(10)+Chr$(10)
  993.     If downloaded<>"" Then
  994.         CaptureLine "[Downloaded to "+FileUrl(downloaded)+"]"+Chr$(10)
  995.     End If
  996. End Sub
  997.  
  998. Sub RecordAlert(alert As DAPALERTPAGE)
  999.     Dim nextpage As String
  1000.     
  1001.     On Error Resume Next
  1002.     CaptureLine alert.lpHeader
  1003.     CaptureLines alert.lpBody
  1004.     CaptureLine alert.lpTrailer
  1005. End Sub
  1006.  
  1007. Sub CaptureAlert(forum As String, page As String)
  1008.     Dim alert As DAPALERTPAGE
  1009.     Dim nextpage As String
  1010.     
  1011.     On Error Resume Next
  1012.     HMIGetAlert alert
  1013.     If (alert.cOptions And DAP_AL_VOLATILE) = 0 Then
  1014.         nextpage = CheckCache("Alerts", nextpage, 0)
  1015.         If nextpage > "" Then 
  1016.             page = nextpage
  1017.             Exit Sub
  1018.         End If
  1019.         UpdateCache "Alerts", page, 0, alert.lpNextPage
  1020.     End If
  1021.     page = alert.lpNextPage
  1022.     If StrComp(Mid$(forum, 1, 4), "CIS:", 1)=0 Then
  1023.         StartCapturing Mid$(forum, 5)+"/Alerts", "Alert recieved going to " + page, False
  1024.     Else
  1025.         StartCapturing forum+"/Alerts", "Alert recieved going to " + page, False
  1026.     End If
  1027.     RecordAlert alert
  1028.     FinishCapturing
  1029. End Sub
  1030.  
  1031. Sub RecordArticleText(article As DAPARTICLEPAGE)
  1032.     Dim textbuf As String
  1033.     Dim state As Integer
  1034.     Dim i As Integer
  1035.  
  1036.     'On Error Resume Next
  1037.     'If article.wExtendedOptions And DAP_AP_EX_HAVE_TITLE Then CaptureLine article.lpTitle
  1038.     'If article.cOptions And DAP_AP_HAVE_HEADER Then CaptureLine article.lpHeader
  1039.     i = 1
  1040.     state = HMI_STATE_FIRST%
  1041.     Do While DAPArticleRead(state, article.lpName, i, HMI_DATA_SIZE, textbuf)
  1042.         i = i + Len(textbuf)
  1043.         CaptureLines textbuf
  1044.         If textbuf = "" Then Exit Do
  1045.         state = HMI_STATE_NEXT%
  1046.     Loop
  1047.     If article.cOptions And DAP_AP_HAVE_TRAILER Then CaptureLine article.lpTrailer
  1048. End Sub
  1049.  
  1050. Sub CaptureArticleText(folder As String)
  1051.     Dim article As DAPARTICLEPAGE
  1052.     Dim nextpage As String
  1053.  
  1054.     'On Error Resume Next
  1055.     HMIGetArticle article
  1056.     If (article.cOptions And (DAP_AP_SESSION_ONLY Or DAP_AP_VOLATILE)) = 0 Then
  1057.         nextpage = CheckCache("Articles", article.lpName, article.pvVersion)
  1058.         If nextpage > "" Then Exit Sub
  1059.         UpdateCache "Articles", article.lpName, article.pvVersion, article.lpNextPage
  1060.     End If
  1061.     StartCapturing folder, "CompuServe", False
  1062.     RecordArticleText article
  1063.     FinishCapturing
  1064. End Sub
  1065.  
  1066. Sub RecordBulletins(forum As String, getnews As Boolean, _
  1067.                     getothers As Boolean, getuserlog As Boolean)
  1068.     Dim bulletins As FAPBULLETINCONFIG
  1069.     Dim entry() as FAPBULLETINENTRY
  1070.     Dim i As Integer
  1071.     Dim textbuf As String
  1072.  
  1073.     ' We must be a member
  1074.     If FAPconfig.wAlerts And FAP_NOT_A_MEMBER% Then
  1075.         Exit Sub
  1076.     End If
  1077.  
  1078.     FAPGetBulletinConfig bulletins, entry()
  1079.     For i = 0 To UBound(entry)
  1080.         ' Are we interested in this one ?
  1081.         If ((getnews And (entry(i).lpTitle="Newsflash" Or _
  1082.                           entry(i).lpTitle="News Flash" Or _
  1083.                           entry(i).lpTitle="Aktuelles")) Or _
  1084.             (getuserlog And entry(i).lpTitle="User Log") Or _
  1085.             (getothers And entry(i).lpTitle<>"News Flash" And _
  1086.                            entry(i).lpTitle<>"Newsflash" And _
  1087.                            entry(i).lpTitle<>"Aktuelles" And _
  1088.                            entry(i).lpTitle<>"User Log")) Then
  1089.             If entry(i).lpTitle="Newsflash" Or _
  1090.                entry(i).lpTitle="News Flash" Or _
  1091.                entry(i).lpTitle="Aktuelles" Then
  1092.                 StartCapturing forum+"/Newsflash", "CompuServe", True
  1093.             Else
  1094.                 If entry(i).lpTitle="User Log" Then
  1095.                     StartCapturing forum+"/Sysop_Logs", "User_Log", True
  1096.                 Else
  1097.                     StartCapturing forum+"/Announcements", "CompuServe", True
  1098.                 End If
  1099.             End If
  1100.             CaptureLine entry(i).lpTitle
  1101.             textbuf = FAPBulletinRead(HMI_STATE_FIRST%, entry(i).nId, 1, HMI_DATA_SIZE)
  1102.             While textbuf > ""
  1103.                 CaptureLines textbuf
  1104.                 textbuf = FAPBulletinRead(HMI_STATE_NEXT%, entry(i).nId, 1, HMI_DATA_SIZE)
  1105.             Wend
  1106.             FinishCapturing
  1107.         End If
  1108.     Next
  1109. End Sub
  1110.  
  1111. 'T:DeleteMessage (subroutine) (CompuServe)
  1112. Sub DeleteMessage(id As String, forum As String, dummy As String, number As String)
  1113.     If Not HMIGotoForum(forum) Then
  1114.         LogResult id + " : Failed : Unable to delete messages in " + forum
  1115.         Exit Sub
  1116.     End If
  1117.  
  1118.     Terminal.Print "Deleting message #" + number + Basic.Eoln$
  1119.  
  1120.     ' Delete the message
  1121.     On Error Goto DeleteMessage_error
  1122.     If FAPDeleteMsg_(number)<>0 Then
  1123.         ReportSuccess id & " : Deleted message #" & number & " from " & forum
  1124.     End If
  1125.     Exit Sub
  1126. DeleteMessage_error:
  1127.     ReportSuccess id & " : Unable to delete message #" & number & " from " & forum
  1128. End Sub
  1129.  
  1130. 'T:GetMailType (function) (CompuServe)
  1131. Function GetMailType(i As Integer) As String
  1132.     Select Case i
  1133.         Case EMP_TEXT%
  1134.             GetMailType = "Ascii"
  1135.         Case EMP_BINARY%
  1136.             GetMailType = "Binary"
  1137.         Case EMP_GIF%
  1138.             GetMailType = "GIF"
  1139.         Case EMP_BINARY_FILE%
  1140.             GetMailType = "Binary file"
  1141.         Case EMP_TEXT_FILE%
  1142.             GetMailType = "Text file"
  1143.         Case EMP_TEXT_OBJECT%
  1144.             GetMailType = "Text object"
  1145.         Case EMP_JPEG%
  1146.             GetMailType = "JPEG"
  1147.         Case Else
  1148.             GetMailType = "Unknown type - " & Str(i)
  1149.     End Select
  1150. End Function
  1151.  
  1152. Function Plural(l As Long) As String
  1153.     If l = 1 Then Plural = "" Else Plural = "s"
  1154. End Function
  1155.  
  1156. 'T:WhichWhatsNew (subroutine) (CompuServe)
  1157. Sub WhichWhatsNew(id As String, which As String)
  1158.     Dim menupage As DAPMENUPAGE, blobmenu As String, pageno As Integer
  1159.     Dim selections() As DAPSELECTION, page As String, ListIni As String
  1160.     Dim menuline As String, tmp As String, menunum As Integer, folder As String
  1161.  
  1162.     ListIni = Session.ServicePath+"userlist.ini"
  1163.  
  1164.     ' Go to the What's New main menu (lists UK, French, German etc)
  1165.     If Not DoHMIGoToPage("EWN-5", -1, DAP_MENU, False) Then Exit Sub
  1166.  
  1167.     ' Pickup the current page name
  1168.     HMIGetMenu menupage, selections
  1169.     page = menupage.lpName
  1170.  
  1171.     ' Display blob menu in the terminal
  1172.     menunum = 0
  1173.     pageno = 0
  1174.     folder = "Whats_New/Unknown_News"
  1175.     blobmenu = selections(0).lpItem
  1176.     Do While blobmenu > ""
  1177.         menunum = menunum + 1
  1178.         menuline = ParseString(blobmenu, Chr(10))
  1179.         ReplaceAllInString menuline, " What's New", ""
  1180.         ReplaceAllInString menuline, " Whats New", ""
  1181.         menuline = menuline + " What's New"
  1182.         If InStr(menuline, which, 1)>0 Then
  1183.             pageno = menunum
  1184.             folder = Mid$(menuline, 4) + "_News"
  1185.             ReplaceAllInString folder, " What's New", ""
  1186.             ReplaceAllInString folder, " Whats New", ""
  1187.             ReplaceAllInString folder, " ", "_"
  1188.             ReplaceAllInString folder, "/", "_"
  1189.             folder = "Whats_New/" + folder
  1190.         End If
  1191.  
  1192.         ' Update userlist.ini with latest list
  1193.         WriteIni "Which Whats New:", menunum, Mid$(menuline, 4), ListIni
  1194.     Loop
  1195.     WriteIni "Which Whats New:", menunum+1, "All What's New", ListIni
  1196.     WriteIni "Which Whats New:", menunum+2, "", ListIni
  1197.  
  1198.     ' Recurse to collect them all?
  1199.     If which="All What's New" Then
  1200.         blobmenu = selections(0).lpItem
  1201.         Do While blobmenu > ""
  1202.             menuline = ParseString(blobmenu, Chr(10))
  1203.             WhichWhatsNew "", menuline
  1204.         Loop
  1205.  
  1206.         ReportSuccess id & " : " & which & " collected"
  1207.         Exit Sub
  1208.     End If
  1209.  
  1210.     ' Invalid choice!
  1211.     If pageno=0 Then
  1212.         ReportSuccess id & " : " & which & " not collected - no such What's New"
  1213.         Exit Sub
  1214.     End If
  1215.  
  1216.     ' Go to the specific What's New
  1217.     If Not DoHMIGotoPage(page, pageno, DAP_MENU, False) Then Exit Sub
  1218.     Terminal.Print "Collecting " & which & "..." & Basic.Eoln$ & Basic.Eoln$
  1219.  
  1220.     ' Pickup list of specific What's New menu articles
  1221.     HMIGetMenu menupage, selections
  1222.     page = menupage.lpName
  1223.  
  1224.     Do
  1225.         ' Display blob menu in the terminal
  1226.         blobmenu = selections(0).lpItem
  1227.         Do While blobmenu > ""
  1228.             menuline = LTrim$(ParseString(blobmenu, Chr(10)))
  1229.             Terminal.Print menuline & Basic.Eoln$
  1230.  
  1231.             tmp = menuline
  1232.             menunum = Val(ParseString(tmp, " "))
  1233.             If menunum>0 Then
  1234.                 ' Get the article
  1235.                 If DoHMIGotoPage(page, menunum, DAP_ARTICLE, True) Then
  1236.                     CaptureArticleText folder
  1237.                 End If
  1238.             End If
  1239.         Loop
  1240.  
  1241.         ' Next menu?
  1242.         If menupage.cOptions And DAP_MP_HAVE_NEXT% Then
  1243.             ' Go to the specific What's New
  1244.             page = menupage.lpNextPage
  1245.             If Not DoHMIGotoPage(page, -1, DAP_MENU, False) Then Exit Sub
  1246.  
  1247.             ' Pickup list of specific What's New menu articles
  1248.             HMIGetMenu menupage, selections
  1249.             page = menupage.lpName
  1250.         End If
  1251.     Loop While menupage.cOptions And DAP_MP_HAVE_NEXT%
  1252.     Terminal.Print Basic.Eoln$
  1253.  
  1254.     ' It worked!
  1255.     If id<>"" Then
  1256.         ReportSuccess id & " : " & which & " collected"
  1257.         SetLastUpdated which
  1258.     End If
  1259. End Sub
  1260.  
  1261.  
  1262.