Author Topic: The shots erray is locked temporarly  (Read 7450 times)

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
The shots erray is locked temporarly
« on: June 16, 2005, 12:02:51 PM »
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
  ...

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"
« Last Edit: June 16, 2005, 03:22:16 PM by Botsareus »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
The shots erray is locked temporarly
« Reply #1 on: June 16, 2005, 12:04:50 PM »
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.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
The shots erray is locked temporarly
« Reply #2 on: June 16, 2005, 12:17:02 PM »
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.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
The shots erray is locked temporarly
« Reply #3 on: June 16, 2005, 12:21:15 PM »
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.
« Last Edit: June 16, 2005, 12:22:44 PM by Numsgil »

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
The shots erray is locked temporarly
« Reply #4 on: June 16, 2005, 12:32:01 PM »
Quote
Now how the ##$#%%^hell is that happening? I did not mess with any of this code.

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.

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
The shots erray is locked temporarly
« Reply #5 on: June 16, 2005, 12:36:36 PM »
Then I have no idea.  Maybe it's a Mandelbug.  A nasty bug type that is characteristically inexplicable and apparently random.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
The shots erray is locked temporarly
« Reply #6 on: June 16, 2005, 12:39:35 PM »
I am beginning to think my cpu over heated or something. It is summer out there.

But I put on error go to kill in there just as a safty mesure, I still think it was caused by the DNA robot with way too mutch Junk dna.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
The shots erray is locked temporarly
« Reply #7 on: June 16, 2005, 03:19:16 PM »
I FOUND THE PROBLEM.

IN MY FIRST POST I DID NOT POST THE CORRECT CODE BC THE TWO CODES ARE REALLY SIMILAR; The right code is called "createshot" (NOT "newshot").

And the cause of the error is right here:
Quote
createshot Shots(t).x, Shots(t).Y, -.vx, -.vy, -5, h, .nrg / 2, Shots(t).range, vbYellow

etc.

you cant pass shots(anything).anything to a sub or function that redims the shots inside!


O yea , mutated virsions of this: robot cause the error (don't know how usefull it will be)
« Last Edit: June 16, 2005, 03:23:04 PM by Botsareus »

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
The shots erray is locked temporarly
« Reply #8 on: June 16, 2005, 03:34:58 PM »
Alright I fixed it in my code.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
The shots erray is locked temporarly
« Reply #9 on: June 16, 2005, 03:42:12 PM »
woohooo!  :D

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
The shots erray is locked temporarly
« Reply #10 on: June 16, 2005, 03:44:38 PM »
There is more then one like that , did you get all of them?

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
The shots erray is locked temporarly
« Reply #11 on: June 16, 2005, 03:45:23 PM »
I changed the createshot function to use byval, which fixes all the calls to it

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
The shots erray is locked temporarly
« Reply #12 on: June 16, 2005, 03:50:38 PM »
Brilliant



In the mean while I am evolving robots as we speack, nothing to watch on tv so I set it to high priority and "chillin'" on this forum.

Offline Botsareus

  • Society makes it all backwards - there is a good reason for that
  • Bot God
  • *****
  • Posts: 4483
    • View Profile
The shots erray is locked temporarly
« Reply #13 on: June 16, 2005, 06:31:18 PM »
Num , this does not fix all of the problem , the following also causes it:

"' calculates next shots position
Public Sub updateshots()"

uses  "With Shots(t)" in the code

when a -5 shot gets checked it calls on "takepoison"

here is what happens in takepoison if the robot is dead: "KillRobot n"

after that it goes to "makepoff" , thats were another problem is, because we are still working "with .shots(t)" it is still keeping the array locked, that basterd. :D



If I find more I'll let you know

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
The shots erray is locked temporarly
« Reply #14 on: June 16, 2005, 06:57:04 PM »
No, that should be okay, since it's not rediming the shots array inside the function.

If I understand it right, that is.  If you actually catch another such problem, we can fix it.