Darwinbots Forum
Code center => Bugs and fixes => Solved Bugs => Topic started by: Testlund on October 27, 2005, 12:36:07 PM
-
While running a simulation I clicked on the icon for 'Starting new simulation' to enter the GUI. I just remembered it's a bug I've reported about before. I think the crash is caused if I have changed the mutation to anything higher than 1/1 on the mutations tab.
The code (located in the Optionsform window at line 764:
MutLab.Caption = (TmpOpts.MutCurrMult) + " X"
Hovering info:
Mutlab.Caption = "32X" (yeah, it was set at 32X now, but it doesn't matter if it is set at 2X or 8X for example)
Tmp.Opts.MutCurrMult = 32
This is where I should post this, right?
-
Yep right place :D
Surely you want the concat operator to form the string for the caption? Isn't it
&
and not
+
?
-
Umm... You mean I should change the + to & instead?
-
I s'pose you could try it. I'm nowhere near as good as [Num] [PY] or [Bots] though so you might want to take advice from them not me :P
-
I guess you are right! No crashing anymore! :boing: Let's just hope it doesn't affect how the mutation function work or anything. :)
-
In VB it is quite acceptable to directly add strings together using the + operator
It is in fact about two orders of magnitude faster than using &
-
OK I just deliberately reproduced this bug in a running sim.
Anyone can do this by the following method.
- Go into the GUI in a running sim and moving the mutations slider off center (any value)
- click change to return to the simulation. Should run happily
- Go back to the GUI options menu and the program will crash with a "type mismatch" error
- Click Debug and it will take you to "DispSettings" in the "Optionsform" module. The highlighted line of code reads
MutLab.Caption = (TmpOpts.MutCurrMult) + " X"
- The reason for this error is that Mutlab.Caption has to be a text value, TmpOpts.MutCurrMult is a numerical value and " X" is text. You can't just add them
- Ulc's answer of substituting "&" for "+" seems to work to fix this
- My prefered fix is to turn the numerical value into a text then add them together like this.
MutLab.Caption = CStr(TmpOpts.MutCurrMult) + " X"
- Once fixed you can hit the "play" button on the VB toolbar and the program will continue from where it left off.
This used to work fine so my belief is that the Cstr function was accidentally deleted at some point. This is reinforced by the fact that there are already brackets around the offending numerical value.
-
That worked too. :)