sub and for next loop

A

AndrewM

Hello,

I have a SUB which has input variables. If I run it once its okay, but I
need to include it in a for....next loop.

Can this be done ?

for i=0 to 100
call mySub(arr(0,i))
next

sub mySub(var)
.....code
end sub

Thanks,
Andrew.
 
A

AndrewM

Hello,

I'm getting a line error as follows

Error Type:
Microsoft VBScript runtime (0x800A0034)
Bad file name or number
/xc/staticScript/untitled0.asp, line 38


I have marked line 38 with -------------->>>>>>

If I replace
"call
createStaticPage(avarGeneral(0,i),avarGeneral(1,i),avarGeneral(2,i),avarGene
ral(3,i))"
with
"call
createStaticPage(avarGeneral(0,0),avarGeneral(1,0),avarGeneral(2,0),avarGene
ral(3,0))"
in order to maintain the loop but only call one set of input values all
works okay.

Thanks
Andrew.

****************************************************
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../../Connections/XcapeSQL.asp" -->
<%
set metainfo = Server.CreateObject("ADODB.Recordset")
metainfo.ActiveConnection = MM_XcapeSQL_STRING
metainfo.Source = "{call dbo.metaInfo}"
metainfo.CursorType = 0
metainfo.CursorLocation = 2
metainfo.LockType = 3
metainfo_Open()
metainfo_numRows = 0
if not metainfo.BOF OR NOT metainfo.EOF then
avarGeneral = metainfo.GetRows(10)
metainfo.close
set metainfo = nothing
end if
%>
<%
rows = UBound(avarGeneral, 2)
for i=0 to rows
call
createStaticPage(avarGeneral(0,i),avarGeneral(1,i),avarGeneral(2,i),avarGene
ral(3,i))
next
%>
<%
sub createStaticPage(propID, propName, resort, area)
strPropName = propName
strPropName = Replace(strPropName, " ", "_")
strResName = resort
strResName = Replace(strResName, " ", "_")
strAreaName = area
strAreaName = Replace(strAreaName, " ", "_")
Dim fs, file, path
Set fs = CreateObject("Scripting.FileSystemObject")
path = Server.MapPath("/xc/")&"\xc"&strResName&""
IF (fs.FolderExists(path)<>true)THEN
fs.CreateFolder(path)
END IF
-------------->>>>>>Set file = fs.CreateTextFile(path & "/" & strPropName
&".asp", true)
file.WriteLine("<"&"%")
file.WriteLine("intPropID = """&propID&"""")
file.WriteLine("%"&">")
file.WriteLine("<!--#include file=""../../Connections/XcapeSQL.asp"" -->")
file.WriteLine("<!--#include
file=""../../include/code/incStaticPageScript.asp""-->")
file.WriteLine("<!--#include file=""../../include/code/Recordsets.asp""-->")
file.WriteLine("<html>")
file.WriteLine("<head>")
file.WriteLine(" <!--#include file=""../../xc/include/head.asp""-->")
file.WriteLine("</html>")
file.Close
'Set file = Nothing
'Set fs = Nothing
'**************************************
'Dim 2fs, folder, files, fileName, 2path
Set fs = CreateObject("Scripting.FileSystemObject")
path = Server.MapPath("/xc/")&"\xc"&strResName&""
path2 = Server.MapPath("/xc/")&"\xc"&strAreaName&""
IF (fs.FolderExists(path2)<>true)THEN
fs.CreateFolder(path2)
END IF
If (fs.FolderExists(path)=true) Then
Set file = fs.CreateTextFile(path2&"/"&strResName&".asp", true)
Set folder = fs.GetFolder(path)
Set files = folder.files
For each fileName in files
strLinkName = Left(fs.GetFileName(fileName),
Len(fs.GetFileName(fileName))-4)
file.WriteLine("<a
href=""../xc"&strResName&"/"&fs.GetFileName(fileName)&""">"&strLinkName&"</a
Next
End If
file.Close
Set file = Nothing
Set files = nothing
Set folder = nothing
Set fs = nothing
'**************************************
END sub
response.redirect "StaticPage.asp"'?propID="&intPropID&""
%>
****************************************************************
 
A

AndrewM

Okay, I've found the problem. Some names in the database had the character
"|" in them as a separator. Someone obviously thought this was a cool way of
writing the name.

Thanks,
Andrew.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,371
Latest member
Brkaa

Latest Threads

Top