home *** CD-ROM | disk | FTP | other *** search
- 'T:ENS.EBS for CompuServe
- ' VA 4.52 release
-
- Global Const IM_DELETE = 2048
-
- Declare Function UniqueFileName$
- Declare Function QueueFile(service As String, sfilename As String, queueflags As Long) As Boolean
- Declare Sub ReportSuccess(id As String)
- Declare Function StartCapture(pseudo As String)
- Declare Function GoForum(ByVal forum As String) As Boolean
- Declare Sub SendCR(t As Tracker)
- Declare Function ParseString(args As String, delim As String) As String
-
- 'T:LongName (subroutine) (CompuServe)
- ' Converts short source name to long name
- Function LongName(s As String) As String
- Select Case Trim$(UCase$(s))
- Case "APN"
- LongName = "AP_US_&_World"
- Case "APS"
- LongName = "AP_Sports"
- Case "APF"
- LongName = "AP_Financial"
- Case "RTW"
- LongName = "Reuters_World_Report"
- Case "RTNA"
- LongName = "Reuters_North_America"
- Case "RTS"
- LongName = "Reuters_Sports_Report"
- Case "RTF"
- LongName = "Reuters_Financial_Report"
- Case "RTVE"
- LongName = "Reuters_Variety_Entertainment"
- Case "RTCE"
- LongName = "Reuters_Euro_Community_Report"
- Case "RTEC"
- LongName = "Reuters_Euro_Community_Report"
- Case "DPA"
- LongName = "Deutsche_Presse-Agentur"
- Case "UPN"
- LongName = "UPI_US_&_World"
- Case "UPS"
- LongName = "UPI_Sports"
- Case "UPF"
- LongName = "UPI_Financial"
- Case "UPSE"
- LongName = "UPI_Southeast_US"
- Case "UPNE"
- LongName = "UPI_Northeast_US"
- Case "UPCE"
- LongName = "UPI_Central_US"
- Case "UPSW"
- LongName = "UPI_Southwest_US"
- Case "UPMA"
- LongName = "UPI_Mid-Atlantic_US"
- Case "UPWE"
- LongName = "UPI_Western_US"
- Case "OTC"
- LongName = "OTC_NewsAlert"
- Case "WP"
- LongName = "Washington_Post"
- Case "DJ"
- LongName = "Dow_Jones_News"
- Case "PR"
- LongName = "PR_News"
- Case "PA"
- LongName = "PA_News"
- Case "AAP"
- LongName = "Australian_Associated_Press"
- Case "APO"
- LongName = "AP_Online_News"
- Case "FAP"
- LongName = "AP_France_News"
- Case "BW"
- LongName = "Business_Wire_News"
- Case "CN"
- LongName = "COMTEX_Newswire_News"
- Case "RTOS"
- LongName = "Reuters_Online_Service_News"
- Case "RTBR"
- LongName = "Reuters_Business_Report_News"
- Case Else
- LongName = "*Unknown*"
- End Select
- End Function
-
- 'T:Send2 (subroutine) (global)
- 'Sends a "2" to the service
- Sub Send2(t As Tracker)
- Comms.Send "2\r"
- t.reset
- End Sub
-
- 'T:StripCapture (subroutine) (global)
- 'Removes from capture file
- Sub StripCapture(t As Tracker)
- CaptureRewind Len(t.match)
- t.reset
- End Sub
-
- 'T:StripCapture1 (subroutine) (global)
- 'Removes the last single character from capture file
- Sub StripCapture1(t As Tracker)
- CaptureRewind 1
- t.reset
- End Sub
-
- 'T:ProcessENSFile (subroutine) (global)
- Sub ProcessENSFile(filename As String)
- Dim inpline As String, src As String, tmpfile As String
-
- On Error Goto File_error
- Open filename For Input Access Read Shared As #1
- tmpfile = UniqueFilename$()
- Open tmpfile For Output Access Write Shared As #5
- Print #5, "Processed ENS report file"
- Do Until Eof(1)
- Line Input #1, inpline
- If Mid$(inpline, 1, 11)="!start ens/" Then
- Print #5, inpline;
- Do Until Eof(1)
- Line Input #1, inpline
- If InStr(inpline, "/") Then
- src = Mid$(inpline, 1, InStr(inpline, "/")-3)
- Print #5, " "+LongName$(src)
- inpline = Mid$(inpline, InStr(inpline, "/"))
- If InStr(inpline, " ") Then
- inpline = LCase$(Trim$(Mid$(inpline, InStr(inpline, " ")+2)))
- Mid$(inpline, 1, 1) = UCase$(Mid$(inpline, 1, 1))
- Print #5, inpline
- End If
- Exit Do
- End If
- Loop
- Else
- Print #5, inpline
- End If
- Loop
- File_nofile:
- On Error Goto 0
- Close #1
- Close #5
- DeleteFile filename
- On Error Resume Next
- Name tmpfile As filename
- On Error Goto 0
- Exit Sub
- File_error:
- Resume File_nofile
- End Sub
-
-
- 'T:GetENSFolder (subroutine) (CompuServe)
- Sub GetENSFolder(id As String, folder As String)
- Dim t As Tracker, err1 As Tracker, err2 As Tracker, strip1 As Tracker
- Dim filename As String
- Dim story As Integer
- Dim MoreStories As Boolean, NoStories As Boolean
- Dim ok As Boolean
-
- NoStories = False
- Do
- ' Go to main page
- If Not GoForum("cis:ens") Then
- LogResult "Failed trying to GO ENS"
- Exit Sub
- End If
- ResetForum
- Comms.Send "set lines 0\r"
- WaitForPrompt "Prompt"
-
- ' Only get the first 70 for the late news - don't cycle forever
- If folder="Late" Then
- MoreStories = False
- Else
- MoreStories = True
- End If
-
- ' Start capturing
- filename = UniqueFilename$()
- Capture CAPTURE_ON, filename
- Set err1 = CreateTracker("PromptMainNoFolder1", "\n? Unknown command '", "", True)
- Set err2 = CreateTracker("PromptMainNoFolder2", "\n% No stories selected", "", True)
- Set strip1 = CreateTracker("Strip1", "\nExecutive News Svc.($)", "StripCapture", True)
- Terminal.CaptureStatus CAPTURE_ON
-
- ' Get all messages
- Comms.Send "scan "+Mid$(folder,1,10)+"\r"
- WaitForPrompt "PromptMain"
- err1.delete
- err2.delete
- If PromptMatches("PromptMainNoFolder") Then
- CaptureText Basic.Eoln$+"!start ens/"+folder+" CompuServe"+Basic.Eoln$
- If PromptMatches("PromptMainNoFolder1") Then
- CaptureText "No such folder."+Basic.Eoln$
- CaptureText "Perhaps you mistyped it or the folder has expired."+Basic.Eoln$
- Else
- CaptureText "Folder contains no stories."+Basic.Eoln$
- End If
- CaptureText "!end"+Basic.Eoln$
- MoreStories = False
- NoStories = True
- Else
- Terminal.Enabled=False
- For story = 1 To 70
- Set err1 = CreateTracker("PromptMainNoMore1", "\n"+Str$(story)+" is an invalid choice!")
- Set err2 = CreateTracker("PromptMainNoMore2", "\n "+LTrim$(Str$(story))+" is an invalid choice!")
- Comms.Send Str$(story)+"\r"
- WaitFor "\r"
- CaptureText Basic.Eoln$+"!start ens/"+folder+Basic.Eoln$
- WaitForPrompt "PromptMain"
- CaptureRewind 1
- err1.delete
- err2.delete
- CaptureText Basic.Eoln$+"!end"+Basic.Eoln$
- If PromptMatches("PromptMainNoMore") Then
- CaptureRewind 21+Len(Str$(story))
- MoreStories = False
- Exit For
- End If
- Terminal.CaptureStatus story, "Received Story"
- Next
- Terminal.Enabled=True
- End If
- Terminal.CaptureStatus CAPTURE_OFF
-
- ' Clean up
- strip1.delete
- Capture CAPTURE_OFF
-
- ' Process file
- If Not NoStories Then ProcessENSFile filename
-
- ' Add to import queue
- If QueueFile(Session.Service, filename, IM_DELETE) Then
- ok = True
- End If
-
- ' Delete any read stories
- Set t = CreateTracker("PromptStories", "Enter <CR> to retain stories !", "Send2")
- GoTop
- t.delete
- Loop While MoreStories=True
- If ok Then
- ReportSuccess id & " : Get ENS Folder " & folder
- End If
- End Sub
-
-
- 'T:DeleteENSFolder (subroutine) (CompuServe)
- Sub DeleteENSFolder(id As String, folder As String)
- Dim t As Tracker
-
- ' Go to main page
- If Not GoForum("cis:ens") Then
- LogResult "Failed trying to GO ENS"
- Exit Sub
- End If
- Comms.Send "set lines 0\r"
- WaitForPrompt "Prompt"
-
- ' Delete
- Terminal.status "Deleting Folder: " +folder
- Set t = CreateTracker("PromptError", "\n\?* is not a folder", "", False, True)
- Comms.Send "delete "+Mid$(folder,1,10)+"\r"
- WaitForPrompt "Prompt"
- If PromptMatches("PromptError") Then
- WaitFor "!"
- LogResult "Unable to delete ENS folder "+folder
- Else
- WriteENSFolder folder, True
- LogResult folder+ " deleted."
- End If
-
- ' Clean up
- t.delete
- GoTop
- ReportSuccess id & " : Delete ENS Folder " & folder
- End Sub
-
- 'T:CreateENSFolder (subroutine) (CompuServe)
- Sub CreateENSFolder(id As String, folder As String, expires As String, _
- retain As String, keyphrase As String, AP As String, _
- UPI As String, Reuters As String, AllOthers As String)
-
- Dim t As Tracker, t2 As Tracker, t3 As Tracker, t4 As Tracker, t5 As Tracker
- Dim APYes As String, UPIYes As String, ReutersYes As String
- Dim AllOthersYes As String
- Dim PressCR as Tracker
- Dim i As Integer, key(1 To 7) As String
- Dim tDate As Tracker, tRetain As Tracker, tWires As Tracker
-
- ' Go to main page
- If Not GoForum("cis:ens") Then
- LogResult "Failed trying to GO ENS"
- Exit Sub
- End If
- Comms.Send "set lines 0\r"
- WaitForPrompt "Prompt"
-
- ' just to be sure we're at the main page
- Set PressCR = CreateTracker("GoPressCR2", "\nPress <CR> to continue :", "SendCR") ' temp fix to get round washington post problem
- Comms.Send "go cis:ens\r"
- WaitForPrompt "Prompt"
- PressCR.Delete
-
- Terminal.Enabled=False
- Terminal.Status "Creating ENS Folder: "+folder+" ..."
-
- 'If folder has a <space>, just use the first word, cuz' CIS will
- If (InStr(folder, Chr$(32))) Then
- folder = Left$(folder, InStr(folder, Chr$(32)))
- End If
-
- Set t = CreateTracker("PromptError", "\n\?* is already a folder", "", False, True)
- Set t2 = CreateTracker("PromptError2", "\n\% No more Clipping Folders may be created")
- Set t3 = CreateTracker("PromptDate", "Expiration Date (MM/DD/YY) :")
- Set t4 = CreateTracker("PromptInput", "\n* :", "", False, True)
- Set t5 = CreateTracker("PromptInput2", "\n:")
- Set tWires = CreateTracker("PromptWires", "Enter choice or <CR> for more wires !")
-
- APYes = "1,2,3,4,5,"
- AllOthersYes = "6,7,8,9,10,11,12,"
- ReutersYes = "13,14,15,16,17,18,19,"
- UPIYes = "20,21,22,23,24,25,26,27,28,"
-
- 'Let's do it
- Comms.Send "create "+Mid$(folder,1,10)+ "\r"
-
- WaitForPrompt "Prompt"
-
- If PromptMatches("PromptError") Then
- WaitFor "!"
- LogResult "Unable to Create ENS folder "+folder
- Goto Cleanup
- End If
-
- ' Check date, set default if invalid and tell user
- ' moved this Tracker down here because I had to reduce it to a '?' to
- ' catch the error and I didn't want it catching anything else
- Set tDate = CreateTracker("BadDate", "\?")
- Terminal.Status "Setting expiration date..."
- Comms.Send expires + "\r"
- WaitForPrompt "Prompt"
- If tDate.found Then
- Comms.Send "\r"
- LogResult "Invalid date. Default date used."
- WaitForPrompt "Prompt"
- End If
- tDate.delete
-
- ' Check #, set default if invalid and tell user
- ' Can't get tRetain to work with anything!
- Set tRetain = CreateTracker("BadDays", "%")
- Terminal.Status "Setting story retain days..."
- Comms.Send retain + "\r"
- WaitForPrompt "Prompt"
- If tRetain.found Then
- Comms.Send "\r"
- WaitForPrompt "Prompt"
- LogResult "Invalid retain days. Default days used."
- End If
- tRetain.delete
-
- 'Which wires do we want
- Terminal.Status "Setting Newswires to scan..."
- If Not PromptMatches("PromptWires") Then
- LogResult "Bail out, something went wrong with the dates or days."
- Exit Sub
- End If
-
- CountWires% = 0
-
- If AP = "y" Then
- Comms.Send APYes
- CountWires = CountWires + 1
- End If
-
- If AllOthers = "y" Then
- Comms.Send AllOthersYes
- CountWires = CountWires + 1
- End If
-
- If Reuters = "y" Then
- Comms.Send ReutersYes
- CountWires = CountWires + 1
- End If
-
- If UPI = "y" Then
- Comms.Send UPIYes
- CountWires = CountWires + 1
- End If
-
- If CountWires = 0 Then
- Comms.Send "All"
- LogResult "No Newswires were specified for " +folder+ ". Defaulted to All Newswires"
- End If
-
- Comms.Send "\r"
- WaitFor "Enter choice or <CR> for more wires !"
- Comms.Send "\r"
- WaitFor "Enter choice or <CR> to continue !"
-
- ' check for semi-colons and parse into separate keyphrases
- If InStr(keyphrase, Chr$(59)) Then
- i=1
- Do While InStr(keyphrase, Chr$(59))
- key(i) = ParseString(keyphrase, ";")
- key(i) = LTrim$(key(i))
- If i=7 Then
- Exit Do
- End If
- i=i+1
- Loop
- Else
- i=1
- key(1) = keyphrase
- End If
-
- ' if any keyphrase is longer than 80 chars
- ' truncate *before* a wildcard and tell user
- ' use Like(operator)
- ' +, - , | , *
-
- For b%=1 To i
- If (Len(key(b)) > 80) Then
- If (key(b) Like "[|*+-]") Then
- For pos%= 80 To 1 Step -1
- ch = Mid$(key(b), pos, 1)
- If ch="+" Or ch="-" Or ch="|" Or ch="*" Then
- key(b) = Left$(key(b), Len(key(b)) - ((Len(key(b))-pos)-1))
- End If
- Next
- Else
- LogResult "Keyphrase #" +Str$(b)+ " in " +folder+ " is too long."
- Exit Sub
- End If
- End If
- Next
-
- ' send the keyphrases
- Terminal.Status "Setting Keyphrases..."
- Comms.Send "\r"
- WaitFor "Enter up to 7 Keyphrases"
-
- b%=1
- For b=1 To i
- WaitForPrompt "PromptInput"
- If key(b) <> "" Then
- Comms.Send key(b) + "\r"
- Else
- Comms.Send "\r"
- Exit For
- End If
- Next
-
- WaitForPrompt "Prompt"
- If PromptMatches("PromptInput") Then
- Comms.Send "\r"
- WaitForPrompt "Prompt"
- End If
-
- Terminal.Enabled=true
-
- ListENSFolder folder
-
- LogResult folder + " created"
-
- 'RAB
- WriteENSFolder folder,False
-
- ReportSuccess id & " : Create ENS Folder " & folder
-
- Cleanup:
- t.delete
- t2.delete
- t3.delete
- t4.delete
- t5.delete
- tWires.delete
- GoTop ' workaround ENS bug
- End Sub
-
-
-
- 'T:ListENSFolder (subroutine) (CompuServe)
- Sub ListENSFolder(folder As String)
- Dim filename As String
- Dim strip1 As Tracker
-
- Terminal.Enabled=False
- Terminal.Status "Verifying "+folder+" Folder information..."
-
- ' Go to main page - probably already there but you never know...
- If Not GoForum("cis:ens") Then
- LogResult "Failed trying to GO ENS"
- Exit Sub
- End If
- Comms.Send "set lines 0\r"
- WaitForPrompt "Prompt"
-
- filename = UniqueFileName$()
- Capture CAPTURE_ON, filename
- CaptureText Basic.Eoln$+"!start ens/folders CompuServe"+Basic.Eoln$
- CaptureText "Folder: " +folder+Basic.Eoln$
- Set strip1 = CreateTracker("Strip1", "\r\n\r", "StripCapture1", False, False)
-
- Capture CAPTURE_OFF, filename
- Comms.Send "list " + folder + "\r"
- WaitFor "\n"
- WaitFor "\n"
- Capture CAPTURE_ON, filename
-
- WaitFor "Press <CR> !"
- CaptureRewind 13
-
- CaptureText Basic.Eoln$+"!end"+Basic.Eoln$
- Capture CAPTURE_OFF, filename
- strip1.delete
-
- Comms.Send "\r"
- WaitforPrompt "Prompt"
-
- ' Cleanup
- b = QueueFile(Session.Service, filename, IM_DELETE)
- Terminal.Enabled=True
- End Sub
-
-
-
- 'T:WriteENSFolder (subroutine) (CompuServe)
- 'write the Foldernames to UserList.ini so they can be used
- ' for %z combo boxes
- ' because you can only have three folders, must have DeleteENSFolder use this Sub too
- Sub WriteENSFolder(folder As String, delete As Boolean)
-
- ListIni$ = Session.ServicePath+"userlist.ini"
-
- 'if called by Create then check for available item in UserList.ini first
- If Not delete Then
- For itm% = 1 to 3
- If ReadIni$("Folder Name:", itm, ListIni) = "" Then
- WriteIni "Folder Name:", itm, folder, ListIni
- Exit For
- End If
- Next
- 'if called by Delete then delete item
- ' re-sort the list so it doesn't mess up the combo box
- Else
- For itm% = 1 to 3 Step 1
- If ReadIni$("Folder Name:", Str$(itm), ListIni) = folder Then
- WriteIni "Folder Name:", Str$(itm), " ", ListIni
- num$ = Str$(itm)
- Exit For
- End If
- Next
-
- folder1$ = ReadIni$("Folder Name:", "1", ListIni)
- folder2$ = ReadIni$("Folder Name:", "2", ListIni)
- folder3$ = ReadIni$("Folder Name:", "3", ListIni)
-
- If folder1 = "" Then
- If folder3 <> "" Then
- WriteIni "Folder Name:", "1", folder3, ListIni
- WriteIni "Folder Name:", "3", " ", ListIni
- ElseIf folder2 <> "" Then
- WriteIni "Folder Name:", "1", folder2, ListIni
- WriteIni "Folder Name:", "2", " ", ListIni
- End If
- ElseIf folder2 = "" Then
- If folder3 <> "" Then
- WriteIni "Folder Name:", "2", folder3, ListIni
- WriteIni "Folder Name:", "3", " ", ListIni
- End If
- End If
-
- End If
- End Sub
-
- 'added by RAB
- 'T:RefreshENS (subroutine) (CompuServe)
- 'get all personal ENS Folder names, search settings, sync USERLIST.INI with CIS settings
- Sub RefreshENS(id As String)
- Dim t As Tracker, PressCR as Tracker
-
- ' Go to main page - this is just a test before we waste our users userlist.ini...
- If Not GoForum("cis:ens") Then
- LogResult "Failed trying to GO ENS"
- Exit Sub
- End If
- Comms.Send "set lines 0\r"
- WaitForPrompt "Prompt"
-
- Terminal.Enabled=True
-
- ' create a blank INI section
- ListIni$ = Session.ServicePath+"userlist.ini"
- WriteIni "Folder Name:", "1", " ", ListIni
- WriteIni "Folder Name:", "2", " ", ListIni
- WriteIni "Folder Name:", "3", " ", ListIni
-
-
- ' This writes the CIS Folder names to USERLIST.INI
- ' \n* before the digit does not work
- Set t = CreateTracker("PromptFolder", "[0-9]* Review folder *\r","FixINI", False, True)
-
- 'this is the real deal so we can Tracker the main page
- Terminal.Status "Refreshing your local ENS Folders..."
- Set PressCR = CreateTracker("GoPressCR2", "\nPress <CR> to continue :", "SendCR") ' temp fix to get round washington post problem
- Comms.Send "go cis:ens\r"
- WaitforPrompt "Prompt"
- PressCR.Delete
-
- 'take out Tracker here cuz' the rest of this messes it up
- t.delete
-
- ' get the CIS Folder definitions
- For itm% = 1 to 3
- fName = ReadIni$("Folder Name:", Str$(itm), ListIni)
- If fName <> "" Then
- ListENSFolder(fName)
- Else
- Exit For
- End If
- Next
-
- ' cleanup
- ReportSuccess id & " : ENS Folder information collected"
- Terminal.Enabled=True
- GoTop
- End Sub
-
- 'added by RAB
- 'T:FixINI (subroutine) (CompuServe)
- 'Tracker routine for CollectAll that syncs UserList.ini with CIS
- Sub FixINI(t As Tracker)
- Dim fName As String
-
- 'parse the Folder NAME
- a% = InStr(t.match, "folder")+7
- z% = InStr(t.match, Chr$(40))
- fName = Trim$(Mid$(t.match, a, z-a))
-
- 'write UserList.ini
- ListIni$ = Session.ServicePath+"userlist.ini"
- If ReadIni$("Folder Name:", "1", ListIni) = "" Then
- WriteIni "Folder Name:", "1", fName, ListIni
- ElseIf ReadIni$("Folder Name:", "2", ListIni) = "" Then
- WriteIni "Folder Name:", "2", fName, ListIni
- Else
- WriteIni "Folder Name:", "3", fName, ListIni
- End If
-
- t.reset
- End Sub
-
- 'T:CollectAllStories (subroutine) (CompuServe)
- Sub CollectAllStories(id As String)
-
- ListIni$ = Session.ServicePath+"userlist.ini"
-
- For itm% = 1 to 3 Step 1
- folder$ = ReadIni$("Folder Name:", Str$(itm), ListIni)
- If folder <> "" Then
- GetENSFolder "", folder
- Else
- ReportSuccess id & " : ENS All stories collected"
- Exit Sub
- End If
- Next
- ReportSuccess id & " : ENS All stories collected"
- End Sub
-
-
-