Try adding this:
http://www.picbasic.co.uk/forum/showthread.php?t=18529

Then check the warnings during compile. It will tell you how to make all pins digital.

You set port D to digital but I...