...

View Full Version : vbscript Function inside another function



Squall Leonhart
12-04-2003, 10:56 PM
Hi, guys.
I just want to ask you in vbscript if the function can be inside other functions.
Please take a look.



Function third

accessdb="tech_re"
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from tblFAQ"
rs.Open sql, cn
rs.MoveFirst
With Response
.Buffer = true
.Expires = 0
.Clear
End With

'these functions come from http://codelib.aspemporium.com/
Function GetFreeFile(byval dir, byval dotextension)
Dim filename, f

filename = PathCombinePath(dir, GetRndFileName(dotextension))
set f = createobject("scripting.filesystemobject")
do while f.fileexists(filename)
filename = PathCombinePath(dir, GetRndFileName(dotextension))
loop
set f = nothing

GetFreeFile = filename
End Function

function GetRndFileName(byval dotextension)
randomize
GetRndFileName = "Pricelist" & clng(todaysDate) & clng(timer) & dotextension
end function
......
...
end function

When I call Function third, it seems script recognize it as same as other functions so it crashes.

I want to make function structure like below.
Function third
Function GetFreeFile
End Function
Function GetRndFileName
End Function
End Function

Roy Sinclair
12-04-2003, 11:17 PM
Functions should have parameters, your function has none. That's probably why you're getting errors.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum