Reading a text file

Results 1 to 3 of 3

Thread: Reading a text file

  1. #1
    Join Date
    Dec 1969
    Posts
    447

    Default Reading a text file

    I have a text file on the server. I am using FSO to open the file. I am then splitting each line of the file out and testing if it contains an (=) sign. If it does, everything befor the = sign is the label and everything after is the text. I am then building a form with the info. All of this is working.... except.... Some of the field values are more then one line in the text field. I cannot figure out how to check for this. Once I know that a fields value is more then one line long I need to place the value in a textarea insted of a text box like I have done so far. <BR><BR>Below is my page code so far: <BR><BR>&#060;% <BR>set fso = server.createobject("scripting.filesystemobject") <BR>set fo = fso.getfile(Server.MapPath("files/OSB.txt")) <BR>set tso = fo.openastextstream <BR>&#039;dumps entire text file into a variable <BR>ts = tso.readall <BR>&#039;splits each line of the file <BR>fil = split(ts, vbcrlf) <BR>%&#062; <BR>&#060;% <BR>for x = 0 to ubound(fil) <BR>TheLabel = Instr(fil(x), "=")-1 <BR>TheText = Instr(fil(x), "=")+2 <BR>s = mid(fil(x),1,TheLabel) <BR>t = mid(fil(x),TheText) <BR>response.write "&#060;table width=&#039;100%&#039; border=&#039;1&#039;&#062;" <BR>if TheLine &#062;= 0 then <BR>response.write "&#060;tr&#062;&#060;td width=&#039;25%&#039;&#062;" & s & "&#060;/td&#062;&#060;td width=&#039;75%&#039;&#062;&#060;input name=" & s & " type=&#039;text&#039; size=&#039;75&#039; value=&#039;" & t & "&#039;&#062;&#060;/td&#062;&#060;/tr&#062;" <BR>else <BR>response.write "&#060;tr&#062;&#060;td width=&#039;25%&#039;&#062; &#060;/td&#062;&#060;td width=&#039;75%&#039;&#062;&#060;input name=" & s & " type=&#039;text&#039; size=&#039;75&#039; value=&#039;" & t & "&#039;&#062;&#060;/td&#062;&#060;/tr&#062;" <BR>end if <BR>next <BR>%&#062; <BR>&#060;/table&#062; <BR><BR>Below is the OSB text file that I am reading. In this example, the NOTES field should be in a text area.: <BR><BR>TX10NAME = Stacy <BR>TX10T = Hedlund Mortgage Company <BR>TX10A1D = 320 Comanche Street <BR>TX10A2D = Kiowa CO 80117 <BR>TX10PH = 888-906-4040 <BR>CK15STAT = Required <BR>END1 = <BR>CK07STAT = Required <BR>END3 = <BR>CK08STAT = <BR>END31 = <BR>CK14STAT = <BR>END4 = <BR>CK09STAT = Required <BR>END81 = X <BR>OPX = <BR>END9 = <BR>LPX = X <BR>LPCOVR = 570000 <BR>OPCOVR = <BR>OTX = <BR>OTCOVR = <BR>PURCREFI = Refinance <BR>BYR1NAM1 = Parick S. Glue <BR>BYR1NAM2 = <BR>BYR2NAM1 = <BR>BYR2NAM2 = <BR>SLR1NAM1 = <BR>SLR1NAM2 = <BR>SLR2NAM1 = <BR>SLR2NAM2 = <BR>SALEPRIC = <BR>LOANAMT = 570000 <BR>DEPOSIT = <BR>PROPSTRE = 6655 WINSTON LANE <BR>PROPCITY = SOLON <BR>STATELET = OH <BR>PROPZIP = 44139 <BR>COUNTY = <BR>LORU = <BR>LOTUNIT = <BR>SUBDIVN = <BR>PLATRWDO = <BR>PLATRWBK = <BR>PLATRWPG = <BR>AG701FRM = <BR>AG701NAM = <BR>AG701PH = <BR>COMPCT = % <BR>AG702FRM = <BR>AG702NAM = <BR>AG702PH = <BR>LENNAM1 = Ohio Savings Bank <BR>LENNAM2 = ISAOA <BR>LENNAM3 = Insurance Center <BR>LENADR1 = P.O. Box 11041 <BR>LENADR2 = Orange, CA 92856-8141 <BR>LENPH = 18883216446 <BR>SETTDATE = <BR>STATCMT = <BR>BILLTOX = MORTBROK <BR>NOTES = Need a closing protection letter to Ohio Savings Bank 1801 East 9th St. Cleveland, OH 44114. <BR>Need Form 100 <BR>Please order payoff from Third Federal Savings and Loan Account Number 1234 <BR><BR>_________________________ <BR><BR>Any help would be greatly appreciated. <BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    201

    Default RE: Reading a text file

    check the lenght of the array element, if larger than x (x maxs at 255)

  3. #3
    Join Date
    Dec 1969
    Posts
    447

    Default RE: Reading a text file

    x represents each line in the file, I think, so the length will not be over 255, the problem comes into play when there are more then 1 line.???<BR><BR>Or am I no getting what you are saying?<BR><BR>Dan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •