Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This array is fixed or temporarily locked 1

Status
Not open for further replies.

theocraticmind

Programmer
Apr 19, 2002
318
CA
i get this error:

This array is fixed or temporarily locked

whne i atempt to reDim an array. i can't figure out why it would be the case. i do almost (differant array names, and the other is 2d) the exact same thing in a differant place, but it works.
 
seeing as i've gotten no response, and the problem is driving my nuts, i'm going to post all my code in hopes that someone will be able to answer..

<%response.buffer=true

Function BRFilter(strTextArea)
Dim intLoop
Dim strChar, strTemp

For intLoop = 1 to Len(strTextArea)
strChar = Mid(strTextArea, intLoop, 1)

If strChar = Chr(10) Then
strTemp = strTemp & &quot;<BR>&quot; & vbCrLf
Else
strTemp = strTemp & strChar
End If

Next

BRFilter = strTemp
End Function


if session(&quot;name&quot;) = &quot;&quot; or session(&quot;name&quot;) = null then
response.redirect &quot;signin.asp&quot;
else
%>
<!--#INCLUDE FILE=&quot;top.asp&quot;-->
<%if request.form(&quot;topic&quot;) = null or request.form(&quot;topic&quot;) = &quot;&quot; then %>
<form action=&quot;new_topic.asp&quot; method=&quot;post&quot;>
<table>
<tr><td class=&quot;row1&quot;>User Name:</td><td class=&quot;row2&quot;><%=session(&quot;name&quot;)%></td></tr>
<tr><td class=&quot;row1&quot;>Topic:</td><td class=&quot;row2&quot;><input type=&quot;text&quot; name=&quot;topic&quot;></td></tr>
<tr><td class=&quot;row1&quot; valign=&quot;top&quot;>Post:</td><td class=&quot;row2&quot;><textarea name=&quot;post&quot; rows=&quot;15&quot; cols=&quot;50&quot;></textarea></td></tr>
<input type=&quot;submit&quot; value=&quot;Submit New Thread&quot;>
</form>
</table>
<% else
dim topic
dim post

topic = BRFilter(request.form(&quot;topic&quot;))
post = BRFilter(request.form(&quot;post&quot;))

Dim objFSO 'FileSystemObject Variable
' Create an instance of the FileSystemObject
Set objFSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)

Dim objFile 'File Object Variable
' Open the TextFile (FileName, ForAppending, AllowCreation)
Set objFile = objFSO.OpenTextFile(Server.MapPath(&quot;topics.txt&quot;), 8, True)

objFile.WriteLine &quot;<%if request.querystring(&quot;&quot;topic&quot;&quot;) = &quot;&quot;&quot; & topic & &quot;&quot;&quot; then&quot; & &quot;%&quot; & &quot;>&quot;
objFile.WriteLine &quot;<table>&quot;
objFile.WriteLine &quot;<tr valign='top'>&quot;
objFile.WriteLine &quot;<td>&quot;
objFile.WriteLine &quot;<a href='genral.asp'>General</a>&quot;
objFile.WriteLine &quot;<hr color='#000000' width='100%'>&quot;
objFile.WriteLine topic + &quot;<hr color='#000000' width='100%'>&quot;
objFile.WriteLine post
objFile.WriteLine &quot;</td>&quot;
objFile.WriteLine &quot;</tr>&quot;
objFile.WriteLine &quot;</table>&quot;
objFile.WriteLine &quot;<%end if&quot; & &quot;%&quot; & &quot;>&quot;

' Close the file and dispose of our objects
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing



dim filename 'location of txt file
filename = Server.MapPath(&quot;genral_topics.asp&quot;)

'Dim objFSO 'FileSystemObject Variable ' not doing this, alwready delared
' Create an instance of the FileSystemObject
Set objFSO = Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)


'Dim objFile 'File Object Variable ' not doing this, alwready delared
' Open the TextFile (FileName, ForAppending-8 ForReading-1 ForWriting-2, AllowCreation)
Set objFile = objFSO.OpenTextFile(filename, 1, True)

dim rest_file(2)
dim i
i = 0

do while objFile.AtEndOfStream = false
rest_file(i) = objFile.readline
i = i + 1
reDim rest_file(i)
loop

'Dim objFile 'File Object Variable ' not doing this, alwready delared
' Open the TextFile (FileName, ForAppending-8 ForReading-1 ForWriting-2, AllowCreation)
Set objFile = objFSO.OpenTextFile(filename, 2, True)

objFile.WriteLine &quot;<tr valign='top'>&quot;
objFile.WriteLine &quot;<td>&quot;
objFile.WriteLine &quot;<hr color='#000000'>&quot;
objFile.WriteLine &quot;<a href='topic.asp?topic=&quot; & topic & &quot;'>&quot; & topic & &quot;</a><br>&quot;
objFile.WriteLine &quot;</td>&quot;
objFile.WriteLine &quot;</tr>&quot;
for x = 0 to i
objFile.WriteLine rest_file(x)
next

' Close the file and dispose of our objects
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
response.redirect &quot;topic.asp?topic=&quot; & topic & &quot;&quot;
end if
%>
<!--#INCLUDE FILE=&quot;bottom.txt&quot;-->
<% end if %>
 
are you using the array in anyway in a Global.asa. If so you may be locking it. provide tools to let people become their best.
 
should you be reDIMing the array outside the loop?

do while objFile.AtEndOfStream = false
rest_file(i) = objFile.readline
i = i + 1
loop
reDim rest_file(i)

provide tools to let people become their best.
 
i'm not using the global.asa file at all. and the reson why i'm reDiming the array inside the loop is that i have no idea how big i need that array to be, so, because every time the loop loops there is one more thing added to the array, every time the loop loops i ad 1 more space to the array.
 
I notice that you start with an array of 3 elements and reduce the size to two elements in the first pass of your loop. Could that cause a problem?
 
thast what i though at first. but i tryed it with 1, 2 and even 0, all yield the same error...
 
what about declaring it as a dynamic array without a count
dim rest_file() provide tools to let people become their best.
 
thank you emensly. after atempting that i got &quot;subscript out of range&quot; but it was easily fixed liek this:

dim rest_file()
dim i
i = 0
reDim rest_file(i)

do while objFile.AtEndOfStream = false
rest_file(i) = objFile.readline
i = i + 1
reDim rest_file(i)
loop
 
thanks for the star and glad I helped out provide tools to let people become their best.
 
If you are loading the array as you increase the size, you need to use the preserve keyword. Also, hear is some alternative code

Dim rest_file(0)
i = 0
do while objFile.AtEndOfStream = false
rest_file(i) = objFile.readline
i = i + 1
ReDim Preserve rest_file(UBound(rest_file) + 1)
loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top