...

View Full Version : Problem with classes.



BarrMan
02-23-2007, 05:18 PM
Hey, I'm trying to make an iniReader using classes but I can't seem to get my functions to return values.
Basically, I need the Request function to return me values but it doesn't for some reason.
iniReader.asp

<%
Class iniReader
Public sFileName
Private sPath
Public Function FileName(Name)
Dim Offset
Offset = InStrRev(Name,"/")
If Offset = 0 Then
Offset = InStrRev(Name,"\")
End If
If Offset = 0 Then
sPath = Server.MapPath(".")
sFileName = Name
Else
sPath = Server.MapPath(Mid(Name,1,Offset))
sFileName = Mid(Name,Offset,Len(Name)-Offset)
End If
End Function

Public Function Request(Param)
Dim Fso : Set Fso = Server.CreateObject("Scripting.FileSystemObject")
Dim iniFile : Set iniFile = Fso.OpenTextFile(sPath & "/" & sFileName)
Dim Line
Dim Offset
While Not iniFile.AtEndOfStream
Line = iniFile.ReadLine
If InStr(Line,Param) Then
Offset = InStr(Line,"=")
Request = Mid(Line,Offset,Len(Line))
End If
Wend
Request = "asd" 'For testing
End Function
End Class
%>
testreader.asp

<%@Language=VBScript%>
<!--#include file="inireader.asp"-->
<html>
<head>
</head>
<body>
<%
Dim Reader
Set Reader = New iniReader
Reader.FileName("config.ini")
Reader.Request("asd")
%>
</body>
</html>

Can anyone help me with this?

Thanks!

BarrMan
02-24-2007, 12:37 PM
Solved.
How silly, I did not write Response.Write.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum