They are trying to solve the problem thinking and coding in C.
So the problem appears to be addressing bits as an array as you would when making a Knightrider LED bar scanner,
except that in application you don’t want to change the state of the bits other than you’re interested in.
To address a bit is easy, just multiply the step value by 2 each time (or shift it once) instead of incrementing it 0-7,
We couldn't begin at zero and begin multiplying, but fortunately address the first bit with a 1 
Code:
index var byte
trisb = 0
index = 1
WHILE index > 0
portb = index
index = index << 1
WEND
Unless I’m mistaken the port bits were cycled real fast with no delays, repeats etc.
But the problem is still that if port.3 happened to be initially set by something, it would now be cleared.
Code:
trisb = 0
index var byte
portbshadow var byte
index = 1
WHILE index > 0
portbshadow = portb
portbshadow = portbshadow^index
portb = portbshadow
index = index << 1
WEND
This should set port bits in sequence, leaving the previous bit set as it runs, and leaving all port bits set at the end,
but that’s because the loop has no conditionals in it. It’s not a bad idea to shadow the port with a RAM byte anyway if you have the time.
AFAIK when the pic sets any single port bit, it does a read of the whole port, then sets the bit in RAM, and writes the whole port byte back anyway.
C isn’t real good for bit manipulation and this sort of thing always has to be done.
Bookmarks