Line concatenation


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597

    Default Line concatenation

    This is ok in PBP v2.60c.
    Code:
    IF PORTB.0 = 0 THEN
     LCDOUT  $FE,$C0,"Row 1, Column 4"
    ENDIF
    Why is this not accepted?
    Code:
    IF PORTB.0 = 0 THEN : LCDOUT  $FE,$C0,"Row 1, Column 4" : ENDIF
    ERROR Line 50: Bad expression.
    ERROR Line 50: Bad expression or missing THEN.
    Yet the manual says I should be able to do it.
    2.18 Line-Concatenation ( : )
    Multiple commands may be written on a single line using colon characters to tell PBP where to insert a "virtual" line break. This can pack more code into less space, but it generally makes the program more difficult to read.
    x = x + 2 : HIGH led : LOW cs
    Unless IF statements are the exception to the rule?

    Robert

  2. #2
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: Line concatenation

    Robert,

    Looks like this may be an exception.

    I would suspect this has to do with the possible variants of the IF/THEN statement.
    1. Single line IF/THEN
    2. Multi-line IF/THEN
    3. Multi-line IF/THEN/ELSE
    4. Multi-line IF/THEN/ELSEIF/ELSE

    The parser may not be able to handle the decisions with these possible permutations AND the Line-Concatenation ( : ) to boot.

    I run PBP 3.0.7.4 and this compiles and runs fine.
    Notice the placement of the ":" character is after the full "then" portion.

    B0 var byte
    B1 var byte

    B0 = 0
    B1 = 0

    for B0 = 1 to 10
    if B0 // 2 = 0 then B1 = B1 + 2 : LCDOUT $FE,$C0,"B0=",dec B0," B1=",dec B1 : pause 1000
    next B0

    This outputs:
    B0=2 B1=2
    B0=4 B1=4
    B0=6 B1=6
    B0=8 B1=8
    B0=10 B1=10
    Regards,
    TABSoft

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Line concatenation

    Your If/Then is really one command not multiple commands.

    IF PORTB.0 = 0 THEN LCDOUT $FE,$C0,"Row 1, Column 4"

    IF PORTB.0 = 0 THEN is not a command

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: Line concatenation

    Thanks Aero, that makes sense. I'll try it out when I get home.

    Robert

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: Line concatenation

    PBP behaves just as documented. I should have looked under IF statement.

    5.35 IF..THEN
    IF Comp {AND/OR Comp...} THEN Label
    IF Comp {AND/OR Comp...} THEN Statement...
    IF Comp {AND/OR Comp...} THEN
    Statement...
    {ELSEIF Comp {AND/OR Comp...} THEN
    Statement...}
    {ELSE
    Statement...}
    ENDIF
    Robert

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,803


    Did you find this post helpful? Yes | No

    Default Re: Line concatenation

    After THEN a statement is required. On the first example is the line under THEN.

    On the second example you only have : and a statement is missing. Just a classic logical error

    Ioannis

Similar Threads

  1. Concatenation
    By galliumman in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 14th February 2013, 23:05
  2. Line following robot
    By samsoltats in forum mel PIC BASIC
    Replies: 2
    Last Post: - 3rd September 2010, 16:01
  3. Line continuation
    By stratus in forum mel PIC BASIC
    Replies: 3
    Last Post: - 14th June 2005, 08:17
  4. 2 Line Chars on a 2 Line LCD
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 16th November 2003, 00:44

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts