Menu

Variable bit set error

ToniG
2022-06-26
2022-06-29
  • ToniG

    ToniG - 2022-06-26

    I use bit set with a byte variable for the bit number without issue

    Tmp_1 = DBuf(DigN)
    Tmp_1.Seg_n = SEGon ' ok

    But when I use a var with NOT to toggle the bit I get an error.

    Temp_1.Seg_n = !Temp_1.Seg_n    '< Error: SysTemp1 is not a bit or valid constant
    

    I used a workaround to keep going (If statement) ,
    Issue test code below...

    'Toggle bit Test
    
    #chip 12F683, 8
    #config Osc = Int
    
    Seg_n = 7
    Temp_1 = 255
    'Toggle disp buffer array  bit
        Temp_1.7 = !Temp_1.7            'OK
        Temp_1.Seg_n = !Temp_1.Seg_n    '< Error: SysTemp1 is not a bit or valid constant
        If Temp_1.Seg_n = 1 then Temp_1.Seg_n = 0 Else Temp_1.Seg_n = 1 '< Workaround
    
    End
    

    Great Cow BASIC (0.98.07 2021-07-07 (Windows 64 bit) : Build 995)

    Compiling D:\Data_GCBasic\TEST1_OEM_Lib\BitToggleTst_1.GCB ...

    An error has been found:

    BitToggleTst_1.GCB (12): Error: SysTemp1 is not a bit or valid constant.
    Constant values should be 0 or 1

    The message has been logged to the file Errors.txt.

    Test code attached...

     

    Last edit: ToniG 2022-06-28
  • ToniG

    ToniG - 2022-06-29

    Another workaround is similar to the bit set for an array.

    Dim TmpBit as Bit
    TmpBit = Temp_1.Seg_n : TmpBit = !TmpBit : Temp_1.Seg_n = TmpBit '< Workaround 2

     

Log in to post a comment.