hi experts!
I wanna ask what is the problem of following code?
I was going to write a class which load text into array.
but then I can't modify the 2 level array.
Expected output is:
==================================
CHI
23
True
ABC
asp class processing time: 863.2813 sec.
==================================
But Final outcome is:
==================================
CHI
23
True
CHI
asp class processing time: 863.2813 sec.
==================================
Thanks in advance!
==================================
dim Scrolling_Text
set Scrolling_Text = new cGetTxtAsArr
Scrolling_Text.remarkLines = 4
Scrolling_Text.showTime = true
Scrolling_Text.TxtPath = Server.MapPath("FocusOfTheDay.txt")
Scrolling_Text.getFromFile()
' Scrolling_Text.printArr()
Response.write Scrolling_Text.Arr(0)(0) & "<BR>" & VbCrlf
Scrolling_Text.Arr(0)(0) = "ABC"
response.write ubound(Scrolling_Text.Arr(0)) & "<BR>" & VbCrlf
response.write isArray(Scrolling_Text.Arr(0)) & "<BR>" & VbCrlf
Response.write Scrolling_Text.Arr(0)(0) & "<BR>" & VbCrlf
' Response.write "<BR>" & VbCrlf
' Response.write Scrolling_Text.Arr2(0)
' Scrolling_Text.Arr2(0) = "ABC"
' Response.write Scrolling_Text.Arr2(0)
set Scrolling_Text = nothing
Class cGetTxtAsArr
Public TxtPath, remarkLines, showTime, Arr
Private TristateTrue, TristateFalse, ForReading, ForWriting, ForAppending
Private processing_time
Private sub Class_Initialize()
TristateTrue =-1
TristateFalse =0
ForReading =1
ForWriting =2
ForAppending =3
processing_time =timer()
Redim Arr(999)
end sub
Public function getFromFile
dim fso, file, TextStream
set fso=Server.CreateObject("Scripting.FileSystemObject")
if fso.FileExists(TxtPath) then
Set file = fso.GetFile(TxtPath)
Set TextStream = File.OpenAsTextStream(ForReading, TristateTrue)
dim i
for i=1 to remarkLines
TextStream.ReadLine
next
i=0
dim line, tmp_arr
Do While Not TextStream.AtEndofStream
line = TextStream.ReadLine
tmp_arr = Split(line, chr(9))
if lcase(tmp_arr(0)) <> "end" and lcase(tmp_arr(0)) <> "" then
Arr(i) = Split(line, chr(9))
i=i+1
end if
loop
redim preserve Arr(i-1)
else
response.write TxtPath & " does not exist on this server."
response.end
end if
end function
Public function printArr
response.write "<font size=""2"">" & VbCrlf & VbCrlf
dim i, j
for i=0 to ubound(Arr)
for j=0 to ubound(Arr(i))
response.write Arr(i)(j) & chr(9)
next
response.write VbCrlf
next
response.write "</font>" & VbCrlf & VbCrlf
end function
Private sub Class_Terminate()
set TristateTrue =nothing
set TristateFalse =nothing
set ForReading =nothing
set ForWriting =nothing
set ForAppending =nothing
if showTime = true then
response.write "<p><font size=""2"">asp class processing time: " & (timer()-processing_time)*1000 & " sec.</font></p>"
end if
set showTime =nothing
set processing_time =nothing
end sub
end Class
I wanna ask what is the problem of following code?
I was going to write a class which load text into array.
but then I can't modify the 2 level array.
Expected output is:
==================================
CHI
23
True
ABC
asp class processing time: 863.2813 sec.
==================================
But Final outcome is:
==================================
CHI
23
True
CHI
asp class processing time: 863.2813 sec.
==================================
Thanks in advance!
==================================
dim Scrolling_Text
set Scrolling_Text = new cGetTxtAsArr
Scrolling_Text.remarkLines = 4
Scrolling_Text.showTime = true
Scrolling_Text.TxtPath = Server.MapPath("FocusOfTheDay.txt")
Scrolling_Text.getFromFile()
' Scrolling_Text.printArr()
Response.write Scrolling_Text.Arr(0)(0) & "<BR>" & VbCrlf
Scrolling_Text.Arr(0)(0) = "ABC"
response.write ubound(Scrolling_Text.Arr(0)) & "<BR>" & VbCrlf
response.write isArray(Scrolling_Text.Arr(0)) & "<BR>" & VbCrlf
Response.write Scrolling_Text.Arr(0)(0) & "<BR>" & VbCrlf
' Response.write "<BR>" & VbCrlf
' Response.write Scrolling_Text.Arr2(0)
' Scrolling_Text.Arr2(0) = "ABC"
' Response.write Scrolling_Text.Arr2(0)
set Scrolling_Text = nothing
Class cGetTxtAsArr
Public TxtPath, remarkLines, showTime, Arr
Private TristateTrue, TristateFalse, ForReading, ForWriting, ForAppending
Private processing_time
Private sub Class_Initialize()
TristateTrue =-1
TristateFalse =0
ForReading =1
ForWriting =2
ForAppending =3
processing_time =timer()
Redim Arr(999)
end sub
Public function getFromFile
dim fso, file, TextStream
set fso=Server.CreateObject("Scripting.FileSystemObject")
if fso.FileExists(TxtPath) then
Set file = fso.GetFile(TxtPath)
Set TextStream = File.OpenAsTextStream(ForReading, TristateTrue)
dim i
for i=1 to remarkLines
TextStream.ReadLine
next
i=0
dim line, tmp_arr
Do While Not TextStream.AtEndofStream
line = TextStream.ReadLine
tmp_arr = Split(line, chr(9))
if lcase(tmp_arr(0)) <> "end" and lcase(tmp_arr(0)) <> "" then
Arr(i) = Split(line, chr(9))
i=i+1
end if
loop
redim preserve Arr(i-1)
else
response.write TxtPath & " does not exist on this server."
response.end
end if
end function
Public function printArr
response.write "<font size=""2"">" & VbCrlf & VbCrlf
dim i, j
for i=0 to ubound(Arr)
for j=0 to ubound(Arr(i))
response.write Arr(i)(j) & chr(9)
next
response.write VbCrlf
next
response.write "</font>" & VbCrlf & VbCrlf
end function
Private sub Class_Terminate()
set TristateTrue =nothing
set TristateFalse =nothing
set ForReading =nothing
set ForWriting =nothing
set ForAppending =nothing
if showTime = true then
response.write "<p><font size=""2"">asp class processing time: " & (timer()-processing_time)*1000 & " sec.</font></p>"
end if
set showTime =nothing
set processing_time =nothing
end sub
end Class