01-27-2010, 12:10 PM
Code:
dim i as uByte
FUNCTION CONTRAST (colour as uByte) as uByte
IF colour <=3 then return 7: END IF
return 0
END FUNCTION
FOR i = 0 to 7
PRINT "SENT ";i;" GOT ";CONTRAST(i)
NEXT i
This comes back with:
Code:
Sent 0 Got 0 Should be Sent 0 got 7
Sent 1 Got 0 Should be Sent 1 got 7
Sent 2 Got 0 Should be Sent 2 got 7
Sent 3 Got 7 Should be Sent 3 got 7
Sent 4 Got 7 Should be Sent 4 got 0
Sent 5 Got 7 Should be Sent 5 got 0
Sent 6 Got 7 Should be Sent 6 got 0
Sent 7 Got 7 Should be Sent 7 got 0
Okay... with "<=3" at least 3 should be the same as 2...yes? And why do 0,1,2 get a return of 0 when they should get a return of 7?
Things get weirder:
Assuming that it was some weird return issue, I decided to return a variable instead:
Code:
dim i as uByte
FUNCTION CONTRAST (colour as uByte) as uByte
DIM rt as uByte
IF colour <=3 then rt=7: END IF
IF colour >=4 then rt=0: END IF
return rt
END FUNCTION
FOR i = 0 to 7
PRINT "SENT ";i;" GOT ";CONTRAST(i)
NEXT i
This gave me:
This comes back with:
Code:
Sent 0 Got 0
Sent 1 Got 0
Sent 2 Got 0
Sent 3 Got 7
Sent 4 Got 0
Sent 5 Got 0
Sent 6 Got 0
Sent 7 Got 0
I mean. SRSLY? My opinion of what that code does is clearly disagreeing with zxb's version..
Perhaps it's because we didn't initialise rt?
Code:
dim i as uByte
FUNCTION CONTRAST (colour as uByte) as uByte
DIM rt as uByte
rt=9
IF colour <=3 then rt=7: END IF
IF colour >=4 then rt=0: END IF
return rt
END FUNCTION
FOR i = 0 to 7
PRINT "SENT ";i;" GOT ";CONTRAST(i)
NEXT i
Gives us a little bit of a clearer picture:
Code:
Sent 0 Got 9
Sent 1 Got 9
Sent 2 Got 9
Sent 3 Got 7
Sent 4 Got 0
Sent 5 Got 0
Sent 6 Got 0
Sent 7 Got 0
So. We seem to have a complete logic failure.
0 <= 3 is FALSE and under certain circumstances 7<=3 is TRUE.
I am so going to bed. I've programmed myself into something psychedelic.
Incidentally:
Code:
FUNCTION CONTRAST (colour as uByte) as uByte
DIM rt as uByte
IF colour <4 then LET rt = 7: END IF
IF colour >3 then let rt = 0: END IF
return rt
END FUNCTION
Seems to be working.
I suppose just asking for PAPER 9 and INK 9 to work is out of the question?