News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Setting a bit in a word variable

Started by Ecoli-557, Jan 16, 2025, 04:34 PM

Previous topic - Next topic

Ecoli-557

OK, I continue to make gains using this compiler which I very much like, however, some old habits from PBP3 keep creeping in.
I want to set a single bit in a word:

PBP:
PortNum                 var Byte
TempOutputState         var Word
TempOutputState.0[PortNum] = 1  'Sets the selected bit to a '1'

Proton:
Dim PortNum             As Byte
Dim TempOutputState     As Word
TempOutputState.PortNum = 1  'Sets the selected bit to a '1'

I get a compiler error of "Invalid Cast for this type of variable!
What am I doing wrong, still learning and I did not find how to do this in manual......

John Lawton

Look up Loadbit and Setbit for starters.

John

Ecoli-557

OK John will do, never got the jest of those so this may be great thing.