....
Run the program - no crash. I didn't change anything in the lines.. all I did was just simply move them below another piece of code and it works!
Some people will be saying "Why are you writing on the forum then if your code is working?" ... as I said I hate inexplicable things! How could I troubleshoot this? If it happens here it could happen elsewhere.
Without seeing more code, I don't think anyone can help you.
Is "setlabel()" a procedure you have written? Maybe it accesses a uninitialised variable/object.
Despite not being able to help much, I am definitely not suggesting that you shouldn't seek help when strange things happen. :)Yes, that is why I posted - thought it better to ask than leave it because I am sure I've not seen the last of it :)
Try to change it like this (if gameplay.starting is integer):
setlabel('TitleLine1', 'Team ' + IntToStr(gameplay.starting), 80, 1); setlabel('TitleLine2', 'Choose a Category:', 80, 2);
Maybe there is a bug in the helper.
rwebb, you are quite right to worry. It sounds to me like there is a memory problem somewhere, its possibly just chance where it pops up and tells the world. So, while you have hidden it for now, its still lurking in there, waiting for someone important to be watching ....
I would look for an uncreated object, an array you have not reserved enough space for and so on. And try debugging, line by line through setlable() ....
Problem is it won't even enter the procedure when I try to debug as soon as I hit F8 on the second line it gives me the error.
F7 is to enter.
Have you set all the debug checks (range, object ... checking)? -CRriot -gt (also try -gtt or -gttt)
Turned optimization to zero -O-
Added Heaptrc -gh (additionally search the forum for "keepreleased" option of Heaptrc)
Are you perhaps manipulating strings or dynamic arrays in a "clever" way?
So that is my first question - if a function returns an object as this does and I don't use the return value (don't do: var := setlabel()) is that a problem? Setlabel is specific to this form and will place the label and "show" it
Why do you have "Show;" in line 16 in function SetLabel?
[...] Have you set all the debug checks (range, object ... checking)? -CRriot -gt (also try -gtt or -gttt)
Turned optimization to zero -O-
Added Heaptrc -gh (additionally search the forum for "keepreleased" option of Heaptrc)
I don't see any problem with while loop... probably other error may have influenced there.I'm not sure but I think what was happening based on my line by line debug is that the while loop didn't run the code if the expression was true where the for loop ran regardless so for example if it ended up being:
I'm not sure but I think what was happening based on my line by line debug is that the while loop didn't run the code if the expression was true where the for loop ran regardless so for example if it ended up being:
for I:=0 to 0 do begin
based on count -1 being equal to zero then It would still run the code in the loop at least once.
I'm not sure but I think what was happening based on my line by line debug is that the while loop didn't run the code if the expression was true where the for loop ran regardless so for example if it ended up being:
for I:=0 to 0 do begin
based on count -1 being equal to zero then It would still run the code in the loop at least once.
If "count - 1 = 0" then "count = 1" therefore Item[0] does exist. So the loop can run once.
If "count = 0" then "count - 1 = -1" and the loop would not run.
The only exception would be if count returned a "cardinal" because that can not go negative. But unless you have your own count function, that is not the case.
This is not related with your problem, but for parsimony you can write followings:
myLabel := TLabel.create(nil);
myLabel.Name:=Name;
myLabel.font.color := clWhite;
myLabel.font.name := 'Roboto Black';
created := labels.add(myLabel);
Result := TLabel(labels[created]);
as:
Result := TLabel.create(nil);
labels.add(Result);
Result.Name:=Name;
Result.font.color := clWhite;
Result.font.name := 'Roboto Black';
with the for loop even though it was -1 it still went through the loop at least once.
No it doesn't, and it shouldn't.