-
Jun 13th, 2020, 06:52 AM
#1
Thread Starter
New Member
Old VB Script Syntax Puzzle
Hi, I'm struggling with a really simple problem in the code below.
The first loop reads a list in a .txt file line-by-line, looking for a keyword from the Request.Querystring which is then defined as 'categoryinlist' , below that in the txt file list is the number of lines to read below defined as 'rows'. The next loop puts the following lines into the row of an html table.
The value of 'rows' is 11. If I type '11' in the line 'DO UNTIL Line = 11' it works fine, however if I type 'DO UNTIL Line = rows' the page doesn't work.
I'm doing this all in Notepad and don't have a syntax checker!
category=Request.Querystring("category")
set textfile = Server.CreateObject("scripting.FileSystemObject").GetFile(Server.MapPath("/specifications/testpricecat.txt")).OpenAsTextStream(1, false)
Do Until categoryinlist = category
categoryinlist = textfile.Readline
Loop
rows = textfile.Readline
Line = 0 %>
<table border="2" cellspacing="2" cellpadding="2">
<tr>
<% DO UNTIL Line = 11
Line = Line + 1
linetext = textfile.ReadLine %>
<td><% =linetext%></td><%
LOOP
%>
</tr>
</table>
<% textfile.close %>
-
Jun 13th, 2020, 07:01 AM
#2
Thread Starter
New Member
Syntax in Do Until loop - VBScript for old ASP
Hi,
I have a problem with code below. The loops read a list in a text file looking for the keyword from the querystring. When it finds the word it looks at the number in the next line of text which tells it how many times to build a new cell in an html table using each line of the following text.
I can define that number as 'rows' just fine but when I try and use the variable in the next Do Until Loop, it fails.
'DO UNTIL Line = 11' works fine but 'DO UNTIL Line = Rows' fails.
I'm doing this in notepad so don't have a syntax checker!
category=Request.Querystring("category")
set textfile = Server.CreateObject("scripting.FileSystemObject").GetFile(Server.MapPath("/specifications/testpricecat.txt")).OpenAsTextStream(1, false)
Do Until categoryinlist = category
categoryinlist = textfile.Readline
Loop
rows = textfile.Readline
Line = 0 %>
<table border="2" cellspacing="2" cellpadding="2">
<tr>
<% DO UNTIL Line = Rows
Line = Line + 1
linetext = textfile.ReadLine %>
<td><% =linetext%></td><%
LOOP
%>
</tr>
</table>
<% textfile.close %>
-
Jun 13th, 2020, 08:41 AM
#3
Re: Old VB Script Syntax Puzzle
Well for one thing rows is a string and line is a number. While VB will allow you to compare the two it is not a good idea.
That said my guess would be that there is something in rows that you are not considering, perhaps a space for example.
Normally when reading a file you read until the end of the file
-
Jun 13th, 2020, 09:18 AM
#4
Thread Starter
New Member
Re: Old VB Script Syntax Puzzle
You are correct - I used Cint to convert the String to an Integer and I'm away
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|