PDA

View Full Version : getting around the basic IF - THEN statement



dw_pic
- 2nd February 2006, 15:08
Hi all,

Prior to Picbasic Pro, the IF statement is limited as a simple GOTO.

It seems like I remember creating an AND statement that worked as a pseudo IF statement. like this.

B0 = 5 AND B1 = 25

in other words: If B1 = 25 Then make B0 5

Or perhaps there is another way to do this that you have found??
tnx,
dw

JEC
- 2nd February 2006, 16:43
You mean something like this?

If B1 =25 Then
B0 = 5
ENDIF

dw_pic
- 2nd February 2006, 16:50
That't the desired end result.

However, prior to PicBasic Pro compiler (which I don't yet have) statements, the IF statement was not this powerful. You are limited to a simple GOTO.

i.e.

B0 = 1
IF B0 = 1 THEN STEP_1
IF B0 = 5 THEN STEP_3

STEP_1:
'do something fun here

STEP_3
'do something crazy here

So, I seem to remember getting creative with the AND statement where I could modify variables without the IF statement.

i.e.

B0 = 5 and B1 = 25

Thanks
dw

nedtron
- 7th February 2006, 14:10
' * * * IF B0 = 25 THEN B1 = 5 * * *

IF B0 = 25 THEN SET_B1

IF B0 <> 25 THEN NOTHING

SET_B1:
B1 = 25

NOTHING:
' * * * Continue * * *