Code center > Darwinbots Program Source Code
The shots erray is locked temporarly
Botsareus:
I am getting an erray is fixed or temporarly locked error over here:
EDIT: BAU June 16, 05 : THE CODE BELOW IS THE WRONG CODE , READ THE OTHER POST TO GET THE CORRECT CODE:
--- Quote ---' creates a shot shooted by robot n, with couple location/value
Public Sub newshot(n As Integer, shottype As Integer, val As Long, rngmultiplier As Single)
Dim a As Integer
Dim vs As Integer
Dim ran As Single
Dim ShAngle As Single
If IsArrayBounded(Shots) = False Then
ReDim Shots(100)
maxshotarray = 100
End If
a = FirstSlot
If a > maxshotarray Then
maxshotarray = maxshotarray + 1
ReDim Preserve Shots(maxshotarray) '<------ Here
End If
Shots(a).Parent = n
Shots(a).FromSpecie = rob(n).fname 'Which species fired the shot
...
--- End quote ---
Now how the ##$#%%^hell is that happening? I did not mess with any of this code.
Here is what I think of vb right now: :plzdie: , but vb is not alive its a program , o well.
Ofcorse the temporary backwords compatible solution for me now is to "On Error GoTo kill" "kill: killrobot n"
Numsgil:
Hmm, I've never gotten that error. Have you tried googling it?
And I'm not sure killing robots is "backwards compatible". How would you like it if you try to eat, the universe has a page fault and now you're dead.
Botsareus:
Its a real error Num. And by backwords compatible I mean: "still works in the broken virsion" and dont worry about the little guys , there files is mutated before the simulation starts, There is no need for survival of the species. although I want it to work otherwise , for now my robots dont even reproduce properly. But I did it this way bc I favored speed over accurasy, just more fun that way. I gess it payed off bc I am getting some really funny errors like:
--- Quote ---This array is fixed or temporarily locked (Error 10)
Not allarrays can be redimensioned. Even arrays specifically declared to be dynamic and arrays within Variantvariables are sometimes locked temporarily. This error has the following causes and solutions:
You tried to use ReDim to change the number of elements of a fixed-size array . For example, in the following code, the fixed array FixedArr is received by SomeArr in the NextOne procedure, and then an attempt is made to resize SomeArr:
Sub FirstOne
Dim FixedArr(25) As Integer ' Create a fixed-size array and
NextOne FixedArr() ' pass it to another procedure.
End Sub
Sub NextOne(SomeArr() As Integer)
ReDim SomeArr(35) ' Error 10 occurs here.
. . .
End Sub
Make the original array dynamic rather than fixed by declaring it with ReDim (if the array is declared within a procedure), or by declaring it without specifying the number of elements (if the array is declared atmodule level).
You tried to redimension a module-level dynamic array, in which one element has been passed as anargument to a procedure. For example, in the following code, ModArray is a dynamic, module-level array whose forty-fifth element is being passedby reference to the Test procedure:
Dim ModArray () As Integer ' Create a module-level dynamic array.
. . .
Sub AliasError()
ReDim ModArray (1 To 73) As Integer
Test ModArray (45) ' Pass an element of the module-level
' array to the Test procedure.
End Sub
Sub Test(SomeInt As Integer)
ReDim ModArray (1 To 40) As Integer ' Error occurs here.
End Sub
There is no need to pass an element of the module-level array in this case, since it's visible within all procedures in the module. However, if an element is passed, the array is locked to prevent a deallocation of memory for the referenceparameter within the procedure, causing unpredictable behavior when the procedure returns.
You attempted to assign a value to a Variant variable containing an array, but the Variant is currently locked. For example, if your code uses a For Each...Next loop to iterate over a variant containing an array, the array is locked on entry into the loop, and then released at the termination of the loop:
SomeArray = Array(9,8,7,6,5,4,3,2,1)
For Each X In SomeArray
SomeArray = 301 ' Causes error since array is locked.
Next X
Use a For...Next rather than a For Each...Next loop to iterate. When an array is the object of a For Each...Next loop, you can read the array, but not write to it.
For additional information, select the item in question and press F1.
--- End quote ---
Numsgil:
Did you perhaps set the shots array as a fixed array? That's the only thing I can think of.
You must have changed something in the code, because I've never seen that error, and I've been messing around with the code quite a bit.
Botsareus:
--- Quote ---Now how the ##$#%%^hell is that happening? I did not mess with any of this code.
--- End quote ---
Look if you ever get it you will get it , otherwise for now you can care less. The quote above is from my first post ;I say clearly that I did not mess with the shots code.
Navigation
[0] Message Index
[#] Next page
Go to full version