Menu

Bit variable used as subroutine parameter fails to compile.

mkstevo
2019-09-19
2021-10-10
  • mkstevo

    mkstevo - 2019-09-19

    The following code fails to compile, giving me the following errors:
    Error: GCASM: Symbol MFWD has not been defined
    Error: GCASM: Symbol MREV has not been defined

    Sub MotorMove(In Mfwd As Bit, In Mrev As Bit)
      If Mfwd = 1 and Mrev = 0 Then
        PrintFwd
      End If
    
      If Mfwd = 0 and Mrev = 1 Then
        PrintRev
      End If
    
      Let MotorEnable = 1
      Let MotorA = Mfwd
      Let MotorB = Mrev
    
      Repeat 1000000
        If SwitchValue <> 1 Then
          Exit Repeat
        End If
        CheckSwitchSub
      End Repeat
    
    End Sub
    

    If I change the Subroutine declaration to:

     Sub MotorMove(In Mfwd As Byte, In Mrev As Byte)
    

    With no other changes, this compiles without any errors.

    If I comment out the 'If...Then End If comparison lines:

     Sub MotorMove(In Mfwd As Bit, In Mrev As Bit)
      'If Mfwd = 1 and Mrev = 0 Then
          PrintFwd
      'End If
    
      'If Mfwd = 0 and Mrev = 1 Then
          PrintRev
      'End If
    
      Let MotorEnable = 1
      Let MotorA = Mfwd
      Let MotorB = Mrev
    
      Repeat 1000000
        If SwitchValue <> 1 Then
          Exit Repeat
        End If
        CheckSwitchSub
      End Repeat
    
    End Sub
    

    The program compiles without errors.

    I don't use bits very often but here I'm using them (as might be deduced from the code) set the direction of a motor controller which is connected to the output pins 'MotorA' and 'MotorB' so thought I'd eliminate the possibility of them being anything other than 1 or 0.

     
  • Anobium

    Anobium - 2019-09-19

    Your post is great. Thank you for reporting.

    Use bytes until I have an detailed answer for you.

     
    • Anobium

      Anobium - 2021-10-10

      This is fixed in the latest release. The code compiles correctly.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.