The supplied code is NOT working unless i un-rem the Tris statement.
Then un-rem the TRIS statement.

Port pins are inputs at power-up since TRIS regs are all 1's. If you're using HIGH & LOW commands for port pin control, it clears TRIS bits for you. With PORTx = ? it doesn't. You need to clear TRIS bits for whatever pin you want to be an output.