Shop OBEX P1 Docs P2 Docs Learn Events
Empty Block Error (Gets In The Way) — Parallax Forums

Empty Block Error (Gets In The Way)

JonnyMacJonnyMac Posts: 8,923
edited 2020-03-08 20:05 in Propeller 2
When building methods from the outside in, I often do things things like this:
pub pwm(pin, freq, duty)

  if (freq <= 0)
    ' clear smart pin
  else
    ' configure smart pin
With Spin2, this code throws an error: Block is Empty -- which does not happen in Spin1. This gets in the way of incremental development. Can we go back to what Spin1 does with this code?

Comments

  • cgraceycgracey Posts: 14,133
    JonnyMac wrote: »
    When building methods from the outside in, I often do things things like this:
    pub pwm(pin, freq, duty)
    
      if (freq <= 0)
        ' clear smart pin
      else
        ' configure smart pin
    
    With Spin2, this code throws an error: Block is Empty -- which does not happen in Spin1. This gets in the way of incremental development. Can we go back to what Spin1 does with this code?

    Okay. I will change it back to the way it was.
  • Thank you.
  • Cluso99Cluso99 Posts: 18,069
    JonnyMac wrote: »
    When building methods from the outside in, I often do things things like this:
    pub pwm(pin, freq, duty)
    
      if (freq <= 0)
        ' clear smart pin
      else
        ' configure smart pin
    
    With Spin2, this code throws an error: Block is Empty -- which does not happen in Spin1. This gets in the way of incremental development. Can we go back to what Spin1 does with this code?

    In python you must include something in each if/elif/else but there is pass which is the equivalent of nothing, just to satisfy the compiler/interpreter that is really what you want.
  • ErNaErNa Posts: 1,742
    i := i sometimes does the job too. Or: p45 := p45. Only does the job when defined. "I" is defined mostly, while p46 may be defined not yet ;-) . CoVid_19 := CoVid_19 may do the job too, as being omnipresent ;-)
Sign In or Register to comment.