Re: Guestbook with slight scripting problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Viatcheslav V. Vassiliev (msnewsgroup_at_www-sharp.com)
Date: 06/29/04


Date: Tue, 29 Jun 2004 15:28:39 +0400

You could check end of stream every time before reading next line:

 gbname = gbfile.readline
 if gbfile.AtEndOfStream then exit do
 gbtime = gbfile.readline 'This is line 32 - see error msg above
 if gbfile.AtEndOfStream then exit do
 gbentry = gbfile.readline

This way you will skip last one or two lines.

Or may be you could store all data in one line, for example, tab-separated,
read one line and use Split function.

//------------------------------------
Regards,
Vassiliev V. V.
http://www-sharp.com -
Scripting/HTA/.Net Framework IDE

"Bill White" <news@helpplease.com> сообщил/сообщила в новостях следующее:
news:JrbEc.7195$mN3.7006@lakeread06...
> Yes, Vassiliev, you're right. When a user hits the Enter key, to create a
> new line, it essentially turns my 3 lines into 4. But, what I don't know
is
> what code I can use to remove that Enter character when I'm reading the
text
> file. Can you help with that? Thanks so much for the quick response!
>
>
>
> "Viatcheslav V. Vassiliev" <msnewsgroup@www-sharp.com> wrote in message
> news:ukwJsGcXEHA.3716@TK2MSFTNGP11.phx.gbl...
> > You read 3 lines at a time:
> >
> > > gbname = gbfile.readline
> > > gbtime = gbfile.readline 'This is line 32 - see error msg above
> > > gbentry = gbfile.readline
> >
> > It seems that gblist.txt lines count is not multiple of 3. For example,
> this
> > will happen if your .txt file has 4 lines.
> >
> > //------------------------------------
> > Regards,
> > Vassiliev V. V.
> > http://www-sharp.com -
> > Scripting/HTA/.Net Framework IDE
> >
> > "Bill White" <news@helpplease.com> сообщил/сообщила в новостях
следующее:
> > news:JqaEc.7177$mN3.1922@lakeread06...
> > > I've created a guest book that works fine as long as the user doesn't
> use
> > > the Enter Key to do a hard return while typing. The error I get is:
> > >
> > > ----------------------------------------------------
> > > Error Type:
> > > Microsoft VBScript runtime (0x800A003E)
> > > Input past end of file
> > > /guestbook/gblist.asp, line 32
> > > -----------------------------------------------------
> > >
> > > I would appreciate it if someone can tell how to fix this. Here's the
> > code.
> > > Thanks!
> > >
> > >
> > > <%
> > > dim filesys, gbfile, gbname, gbentry, gbtime
> > > set filesys = createobject("Scripting.FileSystemObject")
> > > set gbfile = filesys.OpenTextFile("C:\web\GuestBook\gblist.txt",1)
> > > Do While Not gbfile.AtEndOfStream
> > > gbname = gbfile.readline
> > > gbtime = gbfile.readline 'This is line 32 - see error msg above
> > > gbentry = gbfile.readline
> > > response.write gbname
> > > %>
> > > &nbsp;entered this comment on:&nbsp;
> > > <%
> > > response.write gbtime & "<br>"
> > > response.write gbentry & "<br>"
> > > %>
> > > <hr>
> > > <%
> > > loop
> > > gbfile.close
> > > Set filesys = nothing
> > > %>
> > >
> > >
> > > In case you want to know how the text file was written to, here's that
> > code
> > > from the previous ASP page:
> > >
> > > <%=request.form("Name")%><br>
> > > <br>
> > > <%=request.form("Guest_Book_Entry")%>
> > > <%
> > > dim filesys, gbfile
> > > set filesys = CreateObject("Scripting.FileSystemObject")
> > > set gbfile =
filesys.OpenTextFile("C:\web\GuestBook\gblist.txt",8,true)
> > > gbfile.writeline request.form("Name")
> > > gbfile.writeline (Date)
> > > gbfile.writeline request.form("Guest_Book_Entry")
> > > gbfile.close
> > > Set filesys = nothing
> > > %>
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: Guestbook with slight scripting problem
    ... Thanks Vassiliev. ... I came up with a solution (see the later posts). ... > if gbfile.AtEndOfStream then exit do ... >> what code I can use to remove that Enter character when I'm reading the ...
    (microsoft.public.scripting.vbscript)
  • Re: So lost... Need help
    ... I think I'm going to go in a different direction w/ this perl script so ... Thanks for reading. ... Name" is a header): ...
    (perl.beginners)
  • Re: Full Screen Mode
    ... Word 2007's reading view - though frankly I much prefer the Print ... I don't want any menus or scroll bars; ... I don't want to see the button to press to exit full screen mode. ... thing possible in any word processor? ...
    (microsoft.public.word.docmanagement)
  • Re: IEFU83, IEFU84 and IEFU85
    ... If an exit is defined, you can assign a routine to it dynamically. ... Where / what exactly are you reading and where? ... send email to listserv@xxxxxxxxxxx with the message: GET IBM-MAIN INFO ... Search the archives at http://bama.ua.edu/archives/ibm-main.html ...
    (bit.listserv.ibm-main)
  • Re: IEFU83, IEFU84 and IEFU85
    ... If an exit is defined, you can assign a routine to it dynamically. ... via SMFPRMxx update and a SET SMF=xx command. ... Where / what exactly are you reading and where? ...
    (bit.listserv.ibm-main)