PDA

View Full Version : conversion from picbasic to picbasic pro



winjohan
- 31st October 2011, 20:02
Hello,

i was wondering if somone could help me with this code:

OntvangBitAantal: ;Vul het ontvangstbyte met het opgegeven aantal bits in BCD mode
OntvangByte = 0
FOR BD1 = 0 TO BitAantal - 1
GOSUB OntvangEenBit
'IF OntvangBit = 1 THEN SETBIT OntvangByte,BD1
IF OntvangBit = 1 THEN OntvangByte,0(BD1)=1
endif
NEXT
OntvangByte = ((OntvangByte >> 4) * 10) + (OntvangByte & 15) ;BCD (Binary-Coded Decimal) naar byte conversie
RETURN


OntvangEenBit: ;Ontvang een bit en bewaar dit in OntvangBit

WHILE DCF_Signaal = 0
wend
ontvangbit=bitwaarde
dcf_signaal = 0
return



the problem is this line:

'IF OntvangBit = 1 THEN SETBIT OntvangByte,BD1
it is for picbasic and not picbasic pro
what function do i need in picbasic pro
include "bs1defs.bas" i allready done

note this is a routine for putting bits in a byte that are recieved from an antenna, one bit every second

all help is welcome

HenrikOlsson
- 31st October 2011, 21:22
Hi,
If OntvangByte is a byte (or word or long) you access its indivudal bits using the dot notation, like:

OntvangenByte.0 = 1 'Set bit 0
OntvangenByte.7 = 0 'Set bit 7

If Ontvangbit = 1 THEN ' If bit is set
OntvangByte.0 = 1 ' Set lowest significant bit in BYTE
ENDIF

/Henrik.

winjohan
- 1st November 2011, 18:00
Henrik,

many Thanks

Problem solved ! i used the , instead of the .


IF OntvangBit = 1 THEN OntvangByte.0(bd1)=1

thanks again