Miscellaneous

About Miscellaneous things

It is possible to combine multiple instructions on a single line, by separating them with a colon. For example, this code:

    Set PORTB.0 On
    Set PORTB.1 On
    Wait 1 sec
    Set PORTB.0 Off
    Set PORTB.1 Off

could also be written as:

    Set PORTB.0 On: Set PORTB.1 On          ' <<< two instructions combined on one line with a colon
    Wait 1 sec
    Set PORTB.0 Off: Set PORTB.1 Off

Key line: Set PORTB.0 On: Set PORTB.1 On — a colon lets two otherwise-separate statements share a single line; the compiler treats this exactly the same as writing them on two lines.

In most cases, it will make no difference whether commands share a line or not. However, special care should be taken with If commands, as this code:

    Set PORTB.0 Off
    Set PORTB.1 Off
    If Temp > 10 Then Set PORTB.0 On: Set PORTB.1 On
    Wait 1 s

will be equivalent to this:

    Set PORTB.0 Off
    Set PORTB.1 Off
    If Temp > 10 Then
    Set PORTB.0 On
    Set PORTB.1 On
    End If
    Wait 1 s

Also, the commands used to start and end subroutines, data tables, and functions must be alone on a line. For example, this is WRONG:

    Sub Something: Set PORTB.0 Off: End Sub

See Also:

  • If — the single-line If form shown above
  • Subroutines — Sub/End Sub, which cannot share a line with other statements