PDA

View Full Version : Line concatenation



Demon
- 12th April 2015, 16:03
This is ok in PBP v2.60c.

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

Why is this not accepted?

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

Tabsoft
- 12th April 2015, 18:42
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

aerostar
- 12th April 2015, 18:52
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

Demon
- 12th April 2015, 19:13
Thanks Aero, that makes sense. I'll try it out when I get home.

Robert

Demon
- 13th April 2015, 01:31
PBP behaves just as documented. I should have looked under IF statement. :D


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

Ioannis
- 14th April 2015, 14:35
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