![]() |
|
Internal Types - Printable Version +- Boriel Basic Forum (https://forum.boriel.com) +-- Forum: Compilers and Computer Languages (https://forum.boriel.com/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://forum.boriel.com/forumdisplay.php?fid=11) +---- Forum: Bug Reports (https://forum.boriel.com/forumdisplay.php?fid=15) +---- Thread: Internal Types (/showthread.php?tid=194) |
Internal Types - britlion - 2010-03-31 This issues a warning: "Test.bas:22: warning: Redundant operation ABS for unsigned value" Surely if a Byte is signed, then (Byte-Byte) is signed as well? Is this an internal issue, or is it me doing something wrong, and I should be casting, here? (I know poking the routine with fspDataStart is a bad idea - I needed label to be able to make this compile on its own to demonstrate the query - I'm not really writing horrifically wrong self-modifying code!) Code: fspDataStart:
SUB fspCollisionCheck()
dim sprite as uInteger
dim xCoords(3) as Byte
dim yCoords(3) as Byte
dim i,j as uByte
let sprite=@fspDataStart
for i=0 to 3
if (PEEK sprite) mod 2 =1 then:
let xCoords(i)=PEEK (sprite+2)
let yCoords(i)=PEEK (sprite+2)
poke sprite,1
end if
let sprite=sprite+43
next i
let sprite=@fspDataStart
for i=0 to 2
for j=i+1 to 3
if ABS (xCoords(i)-xCoords(j)) < 2 AND ABS (yCoords(i)<yCoords(j)) <2 THEN poke (sprite+43*i), PEEK (sprite+43*i) + ((1 SHL i) SHL (j-i)) : END IF
next j
next i
END SUBRe: Internal Types - boriel - 2010-04-01 britlion Wrote:This issues a warning: "Test.bas:22: warning: Redundant operation ABS for unsigned value"The compiler is right. At line 22, you have: Code: ... ABS (yCoords(i) < yCoords(j)) <2 THENRe: Internal Types - britlion - 2010-04-01 Sheesh. And I swear I tried it without the second argument. Weird when you can't see what you typed sometimes. I stared at that for about an hour. I blame coding after midnight and my old failing eyesight. Have you changed some of the error messages? They seem to be getting more helpful... Re: Internal Types - boriel - 2010-04-01 britlion Wrote:Sheesh.Nope, just divided the line into two lines, using the line continuation "_" character: Code: if ABS (xCoords(i)-xCoords(j)) < 2 AND _
ABS (yCoords(i)<yCoords(j)) <2 THEN
poke (sprite+43*i), PEEK (sprite+43*i) + ((1 SHL i) SHL (j-i))
END IFThis way you can make your code more readable and the warning/error is reported more accurately. BASIC is line-oriented => you can't break the line in the middle of a single sentence, but the _ terminator (written AT THE VERY END of the line) allows line wrapping. |