Line Input # and print # on text file

Here we are, working on migrating all of our enterprise applications from 5.0.8 to 6.0.1 before we upgrade the servers and clients. As you can imagine, the problems we are running into during the migration process is no little task.

Has anyone run into this particular migration bug?

Read a file and write a file using line input #x and print #x? When I run the following piece of code, it writes the file fine in 5.0.8, however when I run the same block of code, it writes the file out with extra carriage returns in the output.

Has anyone experienced these problems? By the way, the file is a WebTrend’s file called “title.wdb”, I am getting titles from our website to fill in the missing gaps that WebTrend cannot complete.

David Trinh

trinhd@region.waterloo.on.ca

Output of R5 is fine:

http://www.region.waterloo.on.ca/web/transit.nsf/c56e308f49bfeb7885256abc0071ec9a/f0bd881589b2609585256c1e0047d8e1?OpenDocument

Kitchener and Waterloo Service Area Winter Schedules

1051973283

http://www.region.waterloo.on.ca/web/transit.nsf/0/f0bd881589b2609585256c1e0047d8e1?OpenDocument

Kitchener and Waterloo Service Area Winter Schedules

1051973283

http://www.region.waterloo.on.ca/web/transit.nsf/0/fa0d262396e8bfb685256c1e0049d878?OpenDocument

Cambridge Service Area Winter Schedules

1051973283

http://www.region.waterloo.on.ca/web/transit.nsf/8f9c046037662cd985256af000711418/41c78b86ab7fe07885256b210066a16a?OpenDocument

Safe Haven Program

1051973284

Output of R6 has extra carriage returns:

http://www.region.waterloo.on.ca/web/transit.nsf/c56e308f49bfeb7885256abc0071ec9a/f0bd881589b2609585256c1e0047d8e1?OpenDocument

Kitchener and Waterloo Service Area Winter Schedules

1051973283

http://www.region.waterloo.on.ca/web/transit.nsf/0/f0bd881589b2609585256c1e0047d8e1?OpenDocument

Kitchener and Waterloo Service Area Winter Schedules

1051973283

http://www.region.waterloo.on.ca/web/transit.nsf/0/fa0d262396e8bfb685256c1e0049d878?OpenDocument

Cambridge Service Area Winter Schedules

1051973283

http://www.region.waterloo.on.ca/web/transit.nsf/8f9c046037662cd985256af000711418/41c78b86ab7fe07885256b210066a16a?OpenDocument

Safe Haven Program

1051973284

Code Block:

Skeleton version:

Do Until Eof(1)

	'assert Line1 is the URL

	'assert Line2 is the Title of the URL

	'assert Line3 is the EPOCH for expiry date in WebTrend

	

	Line Input #1, strLine1

	Line Input #1, strLine2

	Line Input #1, strLine3

	

	Print #2, strLine1

	Print #2, strLine2

	Print #2, strLine3

Loop

Full blown code block:

'this takes the title.wdb and finds the respective title from the notesdocument

On Error Goto ProcessErrorHandler



Dim session As New NotesSession

Dim ws As New NotesUIWorkspace

Dim varFile As Variant

Dim strSource As String

Dim strDestination As String



Let varFile = ws.OpenFileDialog(False, "File List", "", "c:\temp")

Let strSource = Cstr(varFile(0))

Let strDestination = "C:\Temp\title.translated.txt"



Open strSource For Input As #1

Open strDestination For Output As #2



Dim strLine1 As String

Dim strLine2 As String

Dim strLine3 As String



Dim strHTMLheader As String



Dim intX As Integer

Dim strTemp As String



Dim dbTemp As NotesDatabase

Dim doTemp As NotesDocument



Dim oclString As New RowString



Dim lngCounter As Long



Set dbTemp = session.CurrentDatabase



Do Until Eof(1)

	

	'assert Line1 is the URL

	'assert Line2 is the Title of the URL

	'assert Line3 is the internal reference number in WebTrend

	

	Line Input #1, strLine1

	Line Input #1, strLine2

	Line Input #1, strLine3

	

	If (Instr(1,Lcase(strLine1), "http://") > 0 And Trim(strLine2) = Chr$(13)) Or (Instr(1,Lcase(strLine2), "- page unavailable") > 0) Then 

		'assert that a title is missing from the referring URL

		'checks to see if the page unavailable string is present, if so, checks again for page availability

		

		'convert www.region.waterloo.on.ca to regweb

		'variable = RowString.ReplaceString(OriginalString,SearchString,ReplaceString)

		

		If Instr(1, strLine1, Lcase("www.region.waterloo.on.ca")) > 0 Then strTemp = oclString.ReplaceString(strLine1, "www.region.waterloo.on.ca", "regweb")

		If Instr(1, strLine1, Lcase("www.grt.ca"))> 0 Then strTemp = oclString.ReplaceString(strLine1, "www.grt.ca", "regweb")

		'Let strTemp = strLine1

		

		If Mid$(Lcase(strTemp), 1, 5) <> "view:" Then 

			

			'March 24, 2003, it seems that .css files hangs the agent, the get documentbyURL method doesn't resond.  We are going to ignore .css files

			If Instr(1, Lcase(strLine1), ".css") = 0 Then 

				Set doTemp = dbTemp.GetDocumentByURL(Trim(strTemp), True)

				If doTemp.HTTPStatus(0) = "200" Then

					Let strLine2 = Trim(doTemp.Title(0))

					

					Print lngCounter & ". Writing Title - " & strLine2				

				Else

					Let strLine2 = doTemp.HTTPStatus(0) & " - Page Unavailable"

				End If

			End If

		End If	

	End If

	Let lngCounter = lngCounter + 1

	Print #2, strLine1

	Print #2, strLine2

	Print #2, strLine3

	

	Print lngCounter & ". - " & strLine2 & " #: " & strLine3

	

Loop



Close #1

Close #2



Goto SingleExit

SingleExit:

Exit Sub

ProcessErrorHandler:

Call ProcessError("", "Title Lookup for URL (Agent):Initialize", Getthreadinfo(1), Nothing)

Call ProcessUIError(True)

Resume SingleExit

End Sub

Subject: Line Input # and print # on text file

After upgrading to 6.0.2 CF1, the code ran perfectly and the output did not add an extra carriage return. I can only conclude from this trial that version 6.0.1 had a problem with reading and writing text files in this manner.

Thanks for taking the time to read this posting.

David Trinh