A question on port methods

That's true but if you change the port bits one at a time then it takes much more code and flash memory.

I used the instructions in the link and it worked. I tested it with this sketch and got no errors on compiling:

int val = 128;

void setup() {
DDRD = 255; //make portd an output
}

void loop() {
PORTD = val;
}