Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Slice and Dice of Text-Based files(HTML/ASP)

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
US
I have an application thats going to need to modify a couple files, well only two at the moment, prior to this, using an contants.inc (like an include file for ASP), all constants were followed by a = and their value, just rewriting that line when it came back to spitting back out the results, storing every line into a collection, marking some as non data rows, and others as datarows, however this situation is different, in the logon.asp I have to change, <br><FONT FACE=monospace><br>...<br>&lt;TD&gt;&lt;% = gEntryPageFont %&gt;<br> &lt;select name=&quot;ODBCName&quot;&gt;<br> &lt;option value=&quot;almis_prod3&quot; &lt;%= op1 %&gt;&gt;NC SQL - lmi12 prod3&lt;/option&gt;<br> &lt;option value=&quot;nc_tstate&quot; &lt;% = op3 %&gt;&gt;NC Oracle - tstate &lt;/option&gt;<br> &lt;option value=&quot;ct_tstate&quot; &lt;% = op9 %&gt;&gt;CT Oracle - tstate&lt;/Option&gt;<br> <br>&lt;!-- &lt;option value=&quot;almis_dev2&quot;&nbsp;&nbsp;&lt;%= op2 %&gt;&gt;NC SQL - lmi03 dev2&lt;/option&gt;<br> &lt;option value=&quot;cstate&quot; &lt;% = op3 %&gt;&gt;CT Oracle cstate &lt;/option&gt;<br> <br> &lt;option value=&quot;ws_saras2&quot; &lt;% = op4 %&gt;&gt;NC Oracle - saras2 &lt;/option&gt;<br> &lt;option value=&quot;ct_saras2&quot; &lt;% = op5 %&gt;&gt;CT Oracle - saras2&lt;/option&gt;<br> &lt;option value=&quot;lmi07_almis_prod3&quot; &lt;% = op6 %&gt;&gt;NC SQL - lmi07_almis_prod3&lt;/option&gt;<br>&nbsp;&nbsp;&nbsp; &lt;option value =&quot;almis_ne&quot; &lt;%= op6 %&gt;&gt; NE SQL Almis_NE&lt;/option&gt;<br> &lt;option value=&quot;lmi07_almis_prod3_test&quot; &lt;% = op7 %&gt;&gt;NC SQL - lmi07_almis_prod3_test (WI testing)&lt;/option&gt;<br> &lt;option value=&quot;web_sc_32&quot; &lt;% = op8 %&gt;&gt;SC SQL - web_sc_32&lt;/Option&gt;<br>--&gt;&lt;/select&gt;<br>&lt;/TD&gt;<br>...<br></font><br><br>I need to clear out the section between the &lt;Select name=&quot;ODBCName&quot;&gt; and &lt;/Select&gt;<br>and write in the User's selection, inside of those sections, the file is filled with comments, tags, &lt;% %&gt; etc, like any normal ASP, benefit seems that this particular tab has a name=<br><br>the second file is a index.asp, shorter modification is needed.<br><br><FONT FACE=monospace><br>...<br>&lt;body bgcolor=&quot;#ffffff&quot;&gt; &lt;%<br>DBChoice = Request(&quot;DBChoice&quot;)<br>if DBChoice = &quot;&quot; then<br> DBChoice = &quot;almis_prod3&quot;<br>end if %&gt;<br>...<br></font><br><br>I need to change the &quot;almis_prod3&quot; after the =, my question as a whole, is how would I go about programatically, locating these sections, fill them in and write back the rest of the file as it were before, with my modifications. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
this is a function that I have created so far, to serve the purpose of modifying the section of the Logon.asp, I havent tested it yet.<br><br><FONT FACE=monospace><br>Private Function ModifyLogon() As Boolean<br>Dim fs As New FileSystemObject<br>Dim Logon As TextStream<br>Dim MLog As New SettingFile<br>Dim row As New rows<br>Dim TextBuffer As String<br>Dim SelectLocation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>Dim rownum As Integer<br>Dim StartFound As Boolean<br>Dim EndFound As Boolean<br><br>StartFound = False<br>EndFound = False<br>rownum = 1<br>If fs.FileExists(WebServer & SarasRoot & &quot;\logon.asp&quot;) Then<br>&nbsp;&nbsp;&nbsp;'''''''''''''''''''''''''''''''''''''''<br>&nbsp;&nbsp;&nbsp;'Loading File into temporary collection<br>&nbsp;&nbsp;&nbsp;Logon = fs.OpenTextFile(WebServer & SarasRoot & &quot;\logon.asp&quot;)<br>&nbsp;&nbsp;&nbsp;Do While Not Logon.AtEndOfStream<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TextBuffer = Logon.ReadLine<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If StartFound Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If EndFound Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SelectLocation = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SelectLocation = InStr(1, UCase(TextBuffer), &quot;&lt;/SELECT&gt;&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SelectLocation = InStr(1, UCase(TextBuffer), &quot;&lt;SELECT NAME=&quot;&quot;ODBCNAME&quot;&quot;&gt;&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row.RowNumber = rownum<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If SelectLocation &gt; 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row.NoData = False<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row.NoDataStr = TextBuffer<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If StartFound = False Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row.Value = &quot;start&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StartFound = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row.Value = &quot;end&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EndFound = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If Not (StartFound And EndFound = False) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row.NoData = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row.NoDataStr = TextBuffer<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row.Variable = rownum<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If Not (StartFound And EndFound = False) Or row.Value = &quot;start&quot; Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If row.NoData = True Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MLog.rows.Add row<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MLog.rows.Add row, row.Value<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Set row = New rows<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;Loop<br>&nbsp;&nbsp;&nbsp;Logon.Close<br>&nbsp;&nbsp;&nbsp;'''''''''''''''''''''''''''''''''''''''<br>&nbsp;&nbsp;&nbsp;'Saving of collection, with new adjustment<br>&nbsp;&nbsp;&nbsp;Logon = fs.OpenTextFile(WebServer & SarasRoot & &quot;\logon.asp&quot;, ForWriting)<br>&nbsp;&nbsp;&nbsp;For Each row In MLog.rows<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If row.NoData Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Logon.WriteLine row.NoDataStr<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If row.Value = &quot;start&quot; Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Logon.WriteLine row.NoDataStr<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Logon.WriteLine &quot;&lt;option value=&quot;&quot;&quot; & grabvalue(&quot;DSN&quot;) & &quot;&quot;&quot;&gt;&quot; & InputBox(&quot;Type in name to be shown on logon page for the database&quot;, &quot;Database Description&quot;, grabvalue(&quot;DSN&quot;)) & &quot;&lt;/option&gt;&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Logon.WriteLine row.NoDataStr<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;Next<br>&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;Logon.Close<br>&nbsp;&nbsp;&nbsp;While MLog.rows.Count &gt; 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MLog.rows.Remove (1)<br>&nbsp;&nbsp;&nbsp;Wend<br>&nbsp;&nbsp;&nbsp;ModifyLogon = True<br>Else<br>&nbsp;&nbsp;&nbsp;ModifyLogon = False<br>End If<br><br>End Function<br></font> <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top