PDA

View Full Version : Using SDEC with DEBUG



basicstampede
01-19-2007, 07:48 PM
' {$STAMP BS2}
' {$PBASIC 2.5}

number VAR Byte(10)
number(9) = 0
i VAR Word
FOR i=0 TO 8
DEBUG "Enter a number", CR
DEBUGIN SDEC number(i)
NEXT
FOR i=0 TO 8
DEBUG "number(", DEC i, ") is ", SDEC number(i), " in SDEC format", CR
NEXT

END

For the numbers, I entered -1, -2, -3, ...-9.
I was expecting to see the same negative numbers shown with last debug statement.
However, it gave instead 255, 254, 253,...248.

I want to see the negative number I typed.

What is my mistake in coding?

Thanks.

Newzed
01-19-2007, 09:14 PM
Change

DEBUG "number(", DEC i, ") is ", SDEC number(i), " in SDEC format", CR

to

DEBUG "number(", DEC i, ") is ", SDEC number(i)-256, " in SDEC format", CR

and see what happens. Also. change the SDEC in debugin to DEC.

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?

Newzed@aol.com (mailto:Module?Newzed@aol.com)

Newzed
01-19-2007, 09:17 PM
Correction: Leave the SDEC in DEBUGIN.

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Don't have VGA?

Newzed@aol.com (mailto:Module?Newzed@aol.com)