Do you get the access violation the first time through the for loop, last time, or every iteration through the loop?
I would set a breakpoint at the line you get the AV on, and compare the actual name of the TPanel with 'Panel'+P to see if they match. Not finding the component itself won't give you an AV, but using the result (as you are doing with WriteInteger) will produce an AV if findcomponent returned nil.
I would set a breakpoint at the line you get the AV on, and compare the actual name of the TPanel with 'Panel'+P to see if they match. Not finding the component itself won't give you an AV, but using the result (as you are doing with WriteInteger) will produce an AV if findcomponent returned nil.