Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts

    Problem with classes.

    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
    Code:
    <%
    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
    Code:
    <%@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!
    Last edited by BarrMan; 02-23-2007 at 04:25 PM.

  • #2
    Senior Coder BarrMan's Avatar
    Join Date
    Feb 2005
    Location
    Israel.
    Posts
    1,644
    Thanks
    69
    Thanked 83 Times in 82 Posts
    Solved.
    How silly, I did not write Response.Write.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •