How do I properly attach a OpenGL shader to a object?

When I attach a OpenGL shader to a object it keeps looping the shader and creating new values of the ones that exist, so what are the proper steps to do the following?

How to I attach a shader to a bge object, once attached will the shader respond to the mesh?
When I am done with a shader how do I clear it?

LOL , i’m trying to figure that part out too but here is one example or what i managed to figure out so far. This is a toon shader attached as a material onto the object and there is another object that is interpreted or treated as a light source. There are no lamps in this scene. In other words , any object or point in space can become a light source or a camera , it all depends on how things get used/interpreted/processed in the shaders.


ToonShader GLSL Material 0005.blend (243 KB)

Thanks blenderer2012, following this I no longer have duplicate variables.

Now all I need is a way to clear shaders.